Skip to content

Commit 7aac80e

Browse files
committed
test: replace deprecated tslint linter with eslint
`tslint` is now replaced as the linter for the repository and `eslint` is used in its place. The eslint configuration maintains the existing behavioral rules as well as adding many recommended rules from both `eslint` and `@typescript-eslint` via their respective exported recommended configurations. By leveraging the recommended configurations, the repository's configuration has also been simplified. Development scripts and unit tests also can now have specific rule overrides which reduces the amount of manually introduced disabling comments throughout the code.
1 parent 88c0175 commit 7aac80e

File tree

6 files changed

+750
-141
lines changed

6 files changed

+750
-141
lines changed

.eslintignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/bazel-out/
2+
/dist-schema/
3+
/goldens/public-api
4+
/packages/angular_devkit/build_angular/test/
5+
/packages/angular_devkit/build_webpack/test/
6+
/packages/angular_devkit/schematics_cli/schematic/files/
7+
/tests/
8+
.yarn/
9+
dist/
10+
node_modules/
11+
third_party/

.eslintrc.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"es6": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"eslint:recommended",
9+
"plugin:import/typescript",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
12+
"prettier"
13+
],
14+
"parser": "@typescript-eslint/parser",
15+
"parserOptions": {
16+
"project": "tsconfig.json",
17+
"sourceType": "module"
18+
},
19+
"plugins": ["eslint-plugin-import", "header", "@typescript-eslint"],
20+
"rules": {
21+
"@typescript-eslint/consistent-type-assertions": "error",
22+
"@typescript-eslint/no-explicit-any": "error",
23+
"@typescript-eslint/no-non-null-assertion": "error",
24+
"@typescript-eslint/no-unnecessary-qualifier": "error",
25+
"@typescript-eslint/no-unused-expressions": "error",
26+
"curly": "error",
27+
"header/header": ["error", "block", [{ "pattern": "Copyright Google LLC" }]],
28+
"import/first": "error",
29+
"import/newline-after-import": "error",
30+
"import/no-absolute-path": "error",
31+
"import/no-duplicates": "error",
32+
"import/no-extraneous-dependencies": ["error", { "devDependencies": false }],
33+
"import/no-unassigned-import": ["error", { "allow": ["symbol-observable"] }],
34+
"import/order": [
35+
"error",
36+
{
37+
"alphabetize": { "order": "asc" },
38+
"groups": [["builtin", "external"], "parent", "sibling", "index"]
39+
}
40+
],
41+
"max-len": [
42+
"error",
43+
{
44+
"code": 140,
45+
"ignoreUrls": true
46+
}
47+
],
48+
"max-lines-per-function": ["error", { "max": 200 }],
49+
"no-caller": "error",
50+
"no-console": "error",
51+
"no-empty": ["error", { "allowEmptyCatch": true }],
52+
"no-eval": "error",
53+
"no-multiple-empty-lines": ["error"],
54+
"no-throw-literal": "error",
55+
"padding-line-between-statements": [
56+
"error",
57+
{
58+
"blankLine": "always",
59+
"prev": "*",
60+
"next": "return"
61+
}
62+
],
63+
"sort-imports": ["error", { "ignoreDeclarationSort": true }],
64+
"spaced-comment": [
65+
"error",
66+
"always",
67+
{
68+
"markers": ["/"]
69+
}
70+
],
71+
72+
/* TODO: evaluate usage of these rules and fix issues as needed */
73+
"no-case-declarations": "off",
74+
"no-fallthrough": "off",
75+
"no-underscore-dangle": "off",
76+
"no-useless-escape": "off",
77+
"@typescript-eslint/await-thenable": "off",
78+
"@typescript-eslint/ban-types": "off",
79+
"@typescript-eslint/explicit-module-boundary-types": "off",
80+
"@typescript-eslint/no-var-requires": "off",
81+
"@typescript-eslint/no-unsafe-assignment": "off",
82+
"@typescript-eslint/no-unsafe-call": "off",
83+
"@typescript-eslint/no-unsafe-member-access": "off",
84+
"@typescript-eslint/no-unsafe-return": "off",
85+
"@typescript-eslint/prefer-regexp-exec": "off",
86+
"@typescript-eslint/require-await": "off",
87+
"@typescript-eslint/restrict-plus-operands": "off",
88+
"@typescript-eslint/restrict-template-expressions": "off"
89+
},
90+
"overrides": [
91+
{
92+
"files": ["!packages/**", "**/*_spec.ts"],
93+
"rules": {
94+
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
95+
"max-lines-per-function": "off",
96+
"no-console": "off"
97+
}
98+
}
99+
]
100+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ yarn-error.log*
4444
.ng-dev.user*
4545
.husky/_
4646
.bazelrc.user
47+
.eslintcache
4748

4849
# Mac OSX Finder files.
4950
**/.DS_Store

package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"build-tsc": "tsc -p tsconfig.json",
2626
"debug:test": "node --inspect-brk ./bin/devkit-admin test",
2727
"debug:test-large": "node --inspect-brk ./bin/devkit-admin test --large --spec-reporter",
28-
"lint": "tslint --project tsconfig.json",
28+
"lint": "eslint --cache --max-warnings=0 \"**/*.ts\"",
2929
"templates": "node ./bin/devkit-admin templates",
3030
"validate": "node ./bin/devkit-admin validate",
3131
"postinstall": "yarn webdriver-update && yarn ngcc && yarn husky install",
@@ -122,6 +122,8 @@
122122
"@types/text-table": "^0.2.1",
123123
"@types/uuid": "^8.0.0",
124124
"@types/webpack-dev-server": "^3.1.7",
125+
"@typescript-eslint/eslint-plugin": "4.22.0",
126+
"@typescript-eslint/parser": "4.22.0",
125127
"@yarnpkg/lockfile": "1.1.0",
126128
"ajv": "8.2.0",
127129
"ajv-formats": "2.0.2",
@@ -143,6 +145,10 @@
143145
"cssnano": "5.0.2",
144146
"debug": "^4.1.1",
145147
"enhanced-resolve": "5.8.0",
148+
"eslint": "7.25.0",
149+
"eslint-config-prettier": "8.3.0",
150+
"eslint-plugin-header": "3.1.1",
151+
"eslint-plugin-import": "2.22.1",
146152
"express": "4.17.1",
147153
"fast-json-stable-stringify": "2.1.0",
148154
"find-cache-dir": "3.3.1",

tslint.json

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)