Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(linter): remove leftovers after tslint support removal #12313

Merged
merged 1 commit into from Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generated/packages/express.json
Expand Up @@ -82,7 +82,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"unitTestRunner": {
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages/linter.json
Expand Up @@ -104,14 +104,14 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"config": {
"type": "string",
"description": "The name of the configuration file.",
"x-completion-type": "file",
"x-completion-glob": "(tslint.json|.eslintrc.json)"
"x-completion-glob": ".eslintrc.json)"
},
"tsConfig": {
"description": "The name of the TypeScript configuration file.",
Expand Down
5 changes: 2 additions & 3 deletions docs/generated/packages/nx-plugin.json
Expand Up @@ -50,9 +50,8 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"default": "eslint",
"x-deprecated": "TSLint support is deprecated and will be removed"
"enum": ["eslint"],
"default": "eslint"
},
"unitTestRunner": {
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/react-native.json
Expand Up @@ -375,7 +375,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"standaloneConfig": {
Expand Down
6 changes: 3 additions & 3 deletions docs/generated/packages/react.json
Expand Up @@ -645,7 +645,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"standaloneConfig": {
Expand Down Expand Up @@ -956,7 +956,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"skipFormat": {
Expand Down Expand Up @@ -1113,7 +1113,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"routing": {
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/web.json
Expand Up @@ -120,7 +120,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"skipFormat": {
Expand Down
4 changes: 2 additions & 2 deletions docs/generated/packages/workspace.json
Expand Up @@ -135,7 +135,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["tslint", "eslint"],
"enum": ["eslint"],
"default": "eslint"
},
"style": {
Expand Down Expand Up @@ -340,7 +340,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["tslint", "eslint"],
"enum": ["eslint"],
"default": "eslint"
},
"packageManager": {
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/src/generators/ng-add/schema.d.ts
Expand Up @@ -14,6 +14,6 @@ export interface GeneratorOptions {
skipInstall?: boolean;
skipPostInstall?: boolean;
style?: Styles;
linter?: Exclude<Linter, Linter.TsLint>;
linter?: Linter;
skipPackageJson?: boolean;
}
2 changes: 1 addition & 1 deletion packages/express/src/generators/application/schema.json
Expand Up @@ -33,7 +33,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"unitTestRunner": {
Expand Down
8 changes: 5 additions & 3 deletions packages/linter/src/executors/lint/schema.json
Expand Up @@ -8,14 +8,14 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"config": {
"type": "string",
"description": "The name of the configuration file.",
"x-completion-type": "file",
"x-completion-glob": "(tslint.json|.eslintrc.json)"
"x-completion-glob": ".eslintrc.json)"
},
"tsConfig": {
"description": "The name of the TypeScript configuration file.",
Expand Down Expand Up @@ -57,7 +57,9 @@
"tap"
]
},
{ "minLength": 1 }
{
"minLength": 1
}
]
},
"exclude": {
Expand Down
2 changes: 1 addition & 1 deletion packages/nest/src/generators/application/schema.d.ts
Expand Up @@ -5,7 +5,7 @@ export interface ApplicationGeneratorOptions {
name: string;
directory?: string;
frontendProject?: string;
linter?: Exclude<Linter, Linter.TsLint>;
linter?: Linter;
skipFormat?: boolean;
skipPackageJson?: boolean;
standaloneConfig?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/nest/src/generators/library/schema.d.ts
Expand Up @@ -8,7 +8,7 @@ export interface LibraryGeneratorOptions {
directory?: string;
global?: boolean;
importPath?: string;
linter?: Exclude<Linter, Linter.TsLint>;
linter?: Linter;
publishable?: boolean;
service?: boolean;
skipFormat?: boolean;
Expand Down
5 changes: 2 additions & 3 deletions packages/nx-plugin/src/generators/plugin/schema.json
Expand Up @@ -33,9 +33,8 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"default": "eslint",
"x-deprecated": "TSLint support is deprecated and will be removed"
"enum": ["eslint"],
"default": "eslint"
},
"unitTestRunner": {
"type": "string",
Expand Down
1 change: 0 additions & 1 deletion packages/nx/src/utils/versions.ts
Expand Up @@ -3,7 +3,6 @@ export const nxVersion = require('../../package.json').version;
export const angularCliVersion = '~14.2.0';
export const typescriptVersion = '~4.8.2';
export const prettierVersion = '^2.6.2';
export const tslintVersion = '~6.1.0';
export const typescriptESLintVersion = '^5.36.1';
export const eslintVersion = '~8.15.0';
export const eslintConfigPrettierVersion = '8.1.0';
Expand Down
Expand Up @@ -36,7 +36,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"standaloneConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/generators/host/schema.json
Expand Up @@ -68,7 +68,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"skipFormat": {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/generators/remote/schema.json
Expand Up @@ -68,7 +68,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"routing": {
Expand Down
Expand Up @@ -52,7 +52,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"standaloneConfig": {
Expand Down
7 changes: 5 additions & 2 deletions packages/web/src/generators/application/schema.json
Expand Up @@ -28,7 +28,10 @@
"message": "Which stylesheet format would you like to use?",
"type": "list",
"items": [
{ "value": "css", "label": "CSS" },
{
"value": "css",
"label": "CSS"
},
{
"value": "scss",
"label": "SASS(.scss) [ http://sass-lang.com ]"
Expand Down Expand Up @@ -59,7 +62,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["eslint", "tslint"],
"enum": ["eslint"],
"default": "eslint"
},
"skipFormat": {
Expand Down
Expand Up @@ -30,7 +30,7 @@ describe('updateEslint', () => {
it('should handle .eslintrc.json not existing', async () => {
await libraryGenerator(tree, {
name: 'my-lib',
linter: Linter.TsLint,
linter: Linter.None,
standaloneConfig: false,
});

Expand Down
91 changes: 2 additions & 89 deletions packages/workspace/src/generators/new/new.ts
Expand Up @@ -6,10 +6,8 @@ import {
getWorkspacePath as devkitGetWorkspacePath,
installPackagesTask,
names,
NxJsonConfiguration,
PackageManager,
Tree,
updateJson,
} from '@nrwl/devkit';

import { join } from 'path';
Expand All @@ -19,6 +17,7 @@ import { workspaceGenerator } from '../workspace/workspace';
import { nxVersion } from '../../utils/versions';
import { Preset } from '../utils/presets';
import { getNpmPackageVersion } from '../utils/get-npm-package-version';
import { Linter } from '../../utils/lint';

export interface Schema {
cli: 'nx' | 'angular';
Expand All @@ -31,7 +30,7 @@ export interface Schema {
nxCloud?: boolean;
preset: string;
defaultBase: string;
linter: 'tslint' | 'eslint';
linter: Linter;
packageManager?: PackageManager;
}

Expand Down Expand Up @@ -143,7 +142,6 @@ export async function newGenerator(host: Tree, options: Schema) {

await workspaceGenerator(host, { ...options, nxCloud: undefined } as any);

setDefaultLinter(host, options);
addPresetDependencies(host, options);
addCloudDependencies(host, options);

Expand Down Expand Up @@ -261,88 +259,3 @@ function normalizeOptions(options: NormalizedSchema): NormalizedSchema {

return options;
}

function setDefaultLinter(host: Tree, options: Schema) {
const { linter, preset } = options;
// Don't do anything if someone doesn't pick angular
if (preset !== Preset.Angular && preset !== Preset.AngularWithNest) {
return;
}

switch (linter) {
case 'eslint': {
setESLintDefault(host, options);
break;
}
case 'tslint': {
setTSLintDefault(host, options);
break;
}
}
}

/**
* This sets ESLint as the default for any schematics that default to TSLint
*/
function setESLintDefault(host: Tree, options: Schema) {
updateJson<NxJsonConfiguration>(
host,
join(options.directory, 'nx.json'),
(json) => {
setDefault(json, '@nrwl/angular', 'application', 'linter', 'eslint');
setDefault(json, '@nrwl/angular', 'library', 'linter', 'eslint');
setDefault(
json,
'@nrwl/angular',
'storybook-configuration',
'linter',
'eslint'
);
return json;
}
);
}

/**
* This sets TSLint as the default for any schematics that default to ESLint
*/
function setTSLintDefault(host: Tree, options: Schema) {
updateJson<NxJsonConfiguration>(
host,
join(options.directory, 'nx.json'),
(json) => {
setDefault(json, '@nrwl/workspace', 'library', 'linter', 'tslint');
setDefault(json, '@nrwl/cypress', 'cypress-project', 'linter', 'tslint');
setDefault(json, '@nrwl/cypress', 'cypress-project', 'linter', 'tslint');
setDefault(json, '@nrwl/node', 'application', 'linter', 'tslint');
setDefault(json, '@nrwl/node', 'library', 'linter', 'tslint');
setDefault(json, '@nrwl/nest', 'application', 'linter', 'tslint');
setDefault(json, '@nrwl/nest', 'library', 'linter', 'tslint');
setDefault(json, '@nrwl/express', 'application', 'linter', 'tslint');
setDefault(json, '@nrwl/express', 'library', 'linter', 'tslint');

return json;
}
);
}

function setDefault(
json: NxJsonConfiguration,
collectionName: string,
generatorName: string,
key: string,
value: any
) {
if (!json.generators) json.generators = {};
if (
json.generators[collectionName] &&
json.generators[collectionName][generatorName]
) {
json.generators[collectionName][generatorName][key] = value;
} else if (json.generators[`${collectionName}:${generatorName}`]) {
json.generators[`${collectionName}:${generatorName}`][key] = value;
} else {
json.generators[collectionName] = json.generators[collectionName] || {};
json.generators[collectionName][generatorName] = { [key]: value };
}
}
2 changes: 1 addition & 1 deletion packages/workspace/src/generators/new/schema.json
Expand Up @@ -55,7 +55,7 @@
"linter": {
"description": "The tool to use for running lint checks.",
"type": "string",
"enum": ["tslint", "eslint"],
"enum": ["eslint"],
"default": "eslint"
},
"packageManager": {
Expand Down