fix(linter): remove leftovers after tslint support removal (#12313)
This commit is contained in:
parent
2f0d61f2dd
commit
d91c7ca4ec
@ -82,7 +82,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"unitTestRunner": {
|
||||
|
||||
@ -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.",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -375,7 +375,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"standaloneConfig": {
|
||||
|
||||
@ -645,7 +645,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"standaloneConfig": {
|
||||
@ -956,7 +956,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"skipFormat": {
|
||||
@ -1113,7 +1113,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"routing": {
|
||||
|
||||
@ -120,7 +120,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"skipFormat": {
|
||||
|
||||
@ -135,7 +135,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["tslint", "eslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"style": {
|
||||
@ -340,7 +340,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["tslint", "eslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"packageManager": {
|
||||
|
||||
@ -14,6 +14,6 @@ export interface GeneratorOptions {
|
||||
skipInstall?: boolean;
|
||||
skipPostInstall?: boolean;
|
||||
style?: Styles;
|
||||
linter?: Exclude<Linter, Linter.TsLint>;
|
||||
linter?: Linter;
|
||||
skipPackageJson?: boolean;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"unitTestRunner": {
|
||||
|
||||
@ -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.",
|
||||
@ -57,7 +57,9 @@
|
||||
"tap"
|
||||
]
|
||||
},
|
||||
{ "minLength": 1 }
|
||||
{
|
||||
"minLength": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
"exclude": {
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"standaloneConfig": {
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"skipFormat": {
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"routing": {
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"standaloneConfig": {
|
||||
|
||||
@ -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 ]"
|
||||
@ -59,7 +62,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["eslint", "tslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"skipFormat": {
|
||||
|
||||
@ -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,
|
||||
});
|
||||
|
||||
|
||||
@ -6,10 +6,8 @@ import {
|
||||
getWorkspacePath as devkitGetWorkspacePath,
|
||||
installPackagesTask,
|
||||
names,
|
||||
NxJsonConfiguration,
|
||||
PackageManager,
|
||||
Tree,
|
||||
updateJson,
|
||||
} from '@nrwl/devkit';
|
||||
|
||||
import { join } from 'path';
|
||||
@ -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';
|
||||
@ -31,7 +30,7 @@ export interface Schema {
|
||||
nxCloud?: boolean;
|
||||
preset: string;
|
||||
defaultBase: string;
|
||||
linter: 'tslint' | 'eslint';
|
||||
linter: Linter;
|
||||
packageManager?: PackageManager;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["tslint", "eslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"packageManager": {
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
"linter": {
|
||||
"description": "The tool to use for running lint checks.",
|
||||
"type": "string",
|
||||
"enum": ["tslint", "eslint"],
|
||||
"enum": ["eslint"],
|
||||
"default": "eslint"
|
||||
},
|
||||
"style": {
|
||||
@ -36,7 +36,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 ]"
|
||||
|
||||
@ -11,13 +11,10 @@ import {
|
||||
typescriptESLintVersion,
|
||||
eslintConfigPrettierVersion,
|
||||
nxVersion,
|
||||
tslintVersion,
|
||||
angularCliVersion,
|
||||
} from './versions';
|
||||
import { offsetFromRoot } from '@nrwl/devkit';
|
||||
|
||||
export const enum Linter {
|
||||
TsLint = 'tslint',
|
||||
EsLint = 'eslint',
|
||||
None = 'none',
|
||||
}
|
||||
@ -28,15 +25,7 @@ export function generateProjectLint(
|
||||
linter: Linter,
|
||||
eslintFilePatterns: string[]
|
||||
) {
|
||||
if (linter === Linter.TsLint) {
|
||||
return {
|
||||
builder: '@angular-devkit/build-angular:tslint',
|
||||
options: {
|
||||
tsConfig: [tsConfigPath],
|
||||
exclude: ['**/node_modules/**', `!${projectRoot}/**/*`],
|
||||
},
|
||||
};
|
||||
} else if (linter === Linter.EsLint) {
|
||||
if (linter === Linter.EsLint) {
|
||||
return {
|
||||
builder: '@nrwl/linter:eslint',
|
||||
options: {
|
||||
@ -71,39 +60,6 @@ export function addLintFiles(
|
||||
|
||||
const chainedCommands = [];
|
||||
|
||||
if (linter === 'tslint') {
|
||||
chainedCommands.push((host: Tree) => {
|
||||
if (!host.exists('/tslint.json')) {
|
||||
host.create('/tslint.json', globalTsLint);
|
||||
}
|
||||
if (!options.onlyGlobal) {
|
||||
host.create(
|
||||
join(projectRoot as any, `tslint.json`),
|
||||
JSON.stringify({
|
||||
extends: `${offsetFromRoot(projectRoot)}tslint.json`,
|
||||
// Include project files to be linted since the global one excludes all files.
|
||||
linterOptions: {
|
||||
exclude: ['!**/*'],
|
||||
},
|
||||
rules: {},
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
chainedCommands.push(
|
||||
addDepsToPackageJson(
|
||||
{},
|
||||
{
|
||||
tslint: tslintVersion,
|
||||
'@angular-devkit/build-angular': angularCliVersion,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
return chain(chainedCommands);
|
||||
}
|
||||
|
||||
if (linter === 'eslint') {
|
||||
if (!host.exists('/.eslintrc.json')) {
|
||||
host.create('/.eslintrc.json', globalESLint);
|
||||
@ -210,74 +166,6 @@ export function addLintFiles(
|
||||
};
|
||||
}
|
||||
|
||||
const globalTsLint = `
|
||||
{
|
||||
"rulesDirectory": ["node_modules/@nrwl/workspace/src/tslint"],
|
||||
"linterOptions": {
|
||||
"exclude": ["**/*"]
|
||||
},
|
||||
"rules": {
|
||||
"arrow-return-shorthand": true,
|
||||
"callable-types": true,
|
||||
"class-name": true,
|
||||
"deprecation": {
|
||||
"severity": "warn"
|
||||
},
|
||||
"forin": true,
|
||||
"import-blacklist": [true, "rxjs/Rx"],
|
||||
"interface-over-type-literal": true,
|
||||
"member-access": false,
|
||||
"member-ordering": [
|
||||
true,
|
||||
{
|
||||
"order": [
|
||||
"static-field",
|
||||
"instance-field",
|
||||
"static-method",
|
||||
"instance-method"
|
||||
]
|
||||
}
|
||||
],
|
||||
"no-arg": true,
|
||||
"no-bitwise": true,
|
||||
"no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
|
||||
"no-construct": true,
|
||||
"no-debugger": true,
|
||||
"no-duplicate-super": true,
|
||||
"no-empty": false,
|
||||
"no-empty-interface": true,
|
||||
"no-eval": true,
|
||||
"no-inferrable-types": [true, "ignore-params"],
|
||||
"no-misused-new": true,
|
||||
"no-non-null-assertion": true,
|
||||
"no-shadowed-variable": true,
|
||||
"no-string-literal": false,
|
||||
"no-string-throw": true,
|
||||
"no-switch-case-fall-through": true,
|
||||
"no-unnecessary-initializer": true,
|
||||
"no-unused-expression": true,
|
||||
"no-var-keyword": true,
|
||||
"object-literal-sort-keys": false,
|
||||
"prefer-const": true,
|
||||
"radix": true,
|
||||
"triple-equals": [true, "allow-null-check"],
|
||||
"unified-signatures": true,
|
||||
"variable-name": false,
|
||||
|
||||
"nx-enforce-module-boundaries": [
|
||||
true,
|
||||
{
|
||||
"enforceBuildableLibDependency": true,
|
||||
"allow": [],
|
||||
"depConstraints": [
|
||||
{ "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const globalESLint = JSON.stringify({
|
||||
root: true,
|
||||
ignorePatterns: ['**/*'],
|
||||
|
||||
@ -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';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user