Skip to content

Commit 98dec37

Browse files
authored
chore: cleanup repo lint + typechecking (typescript-eslint#6473)
* chore: cleanup repo lint + typechecking * fixes 1 * fixes 2 * fixture * tests * pin tsnode * fix hardcoded paths
1 parent b88cd23 commit 98dec37

File tree

243 files changed

+2554
-1740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

243 files changed

+2554
-1740
lines changed

.eslintignore

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ __snapshots__
77
.docusaurus
88
build
99

10-
packages/eslint-plugin-tslint/tests
11-
12-
packages/website/**/*.js
13-
packages/website/**/*.d.ts
14-
packages/website-eslint/**/*.js
15-
packages/website-eslint/**/*.d.ts
16-
1710
# Files copied as part of the build
1811
packages/types/src/generated/**/*.ts
12+
13+
# Playground types downloaded from the web
14+
packages/website/src/vendor

.eslintrc.js

+34-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @ts-check
2+
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */
13
module.exports = {
24
root: true,
35
plugins: [
@@ -11,7 +13,7 @@ module.exports = {
1113
'simple-import-sort',
1214
],
1315
env: {
14-
es6: true,
16+
es2020: true,
1517
node: true,
1618
},
1719
extends: [
@@ -25,7 +27,6 @@ module.exports = {
2527
project: [
2628
'./tsconfig.eslint.json',
2729
'./packages/*/tsconfig.json',
28-
'./tests/integration/tsconfig.json',
2930
/**
3031
* We are currently in the process of transitioning to nx's out of the box structure and
3132
* so need to manually specify converted packages' tsconfig.build.json and tsconfig.spec.json
@@ -156,6 +157,7 @@ module.exports = {
156157
'eslint-disable-line',
157158
'eslint-disable-next-line',
158159
'eslint-enable',
160+
'global',
159161
],
160162
},
161163
],
@@ -202,6 +204,18 @@ module.exports = {
202204
'one-var': ['error', 'never'],
203205
},
204206
overrides: [
207+
{
208+
files: ['*.js'],
209+
extends: ['plugin:@typescript-eslint/disable-type-checked'],
210+
rules: {
211+
// turn off other type-aware rules
212+
'deprecation/deprecation': 'off',
213+
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
214+
215+
// turn off rules that don't apply to JS code
216+
'@typescript-eslint/explicit-function-return-type': 'off',
217+
},
218+
},
205219
// all test files
206220
{
207221
files: [
@@ -210,9 +224,8 @@ module.exports = {
210224
'./packages/*/tests/**/spec.ts',
211225
'./packages/*/tests/**/test.ts',
212226
'./packages/parser/tests/**/*.ts',
213-
'./tests/integration/**/*.test.ts',
214-
'./tests/integration/integration-test-base.ts',
215-
'./tests/integration/pack-packages.ts',
227+
'./packages/integration-tests/tools/integration-test-base.ts',
228+
'./packages/integration-tests/tools/pack-packages.ts',
216229
],
217230
env: {
218231
'jest/globals': true,
@@ -312,7 +325,12 @@ module.exports = {
312325
},
313326
// tools and tests
314327
{
315-
files: ['**/tools/**/*.*t*', '**/tests/**/*.ts'],
328+
files: [
329+
'**/tools/**/*.*t*',
330+
'**/tests/**/*.ts',
331+
'./packages/repo-tools/**/*.*t*',
332+
'./packages/integration-tests/**/*.*t*',
333+
],
316334
rules: {
317335
// allow console logs in tools and tests
318336
'no-console': 'off',
@@ -346,17 +364,18 @@ module.exports = {
346364
},
347365
},
348366
{
349-
files: ['./packages/website/'],
367+
files: ['./packages/website/**/*.{ts,tsx,mts,cts,js,jsx}'],
350368
extends: [
351369
'plugin:jsx-a11y/recommended',
352370
'plugin:react/recommended',
353371
'plugin:react-hooks/recommended',
354372
],
355373
plugins: ['jsx-a11y', 'react', 'react-hooks'],
356374
rules: {
375+
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
376+
'import/no-default-export': 'off',
357377
'react/jsx-no-target-blank': 'off',
358378
'react/no-unescaped-entities': 'off',
359-
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
360379
'react-hooks/exhaustive-deps': 'off', // TODO: enable it later
361380
},
362381
settings: {
@@ -373,5 +392,12 @@ module.exports = {
373392
'no-console': 'off',
374393
},
375394
},
395+
{
396+
files: ['./packages/website-eslint/src/mock/**/*.js'],
397+
rules: {
398+
// mocks have to mirror their original
399+
'import/no-default-export': 'off',
400+
},
401+
},
376402
],
377403
};

.prettierignore

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
1-
**/tests/fixtures/**/*
2-
!packages/scope-manager/tests/fixtures/**/*
3-
**/tests/fixture-project/**/*
41
**/dist
52
**/coverage
63
**/.vscode
74
**/.nyc_output
85
**/.vs
9-
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
10-
packages/eslint-plugin/src/configs/*.json
116
CONTRIBUTORS.md
127
packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts
8+
packages/eslint-plugin/tests/fixtures/indent/
139

14-
# prettier doesn't yet support auto-accessors
15-
packages/ast-spec/src/element/AccessorProperty/fixtures
10+
# prettier errors on this case because it's semantically valid
11+
packages/ast-spec/src/element/AccessorProperty/fixtures/modifier-abstract-with-value/fixture.ts
1612

1713
# Ignore CHANGELOG.md files to avoid issues with automated release job
1814
CHANGELOG.md
1915

2016
packages/website/.docusaurus
2117
packages/website/build
22-
packages/website/src/vendor

CONTRIBUTORS.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
<!-- ------------------------------------------
2+
| DO NOT MODIFY THIS FILE MANUALLY |
3+
| |
4+
| THIS FILE HAS BEEN AUTOMATICALLY GENERATED |
5+
| |
6+
| YOU CAN REGENERATE THIS FILE USING |
7+
| yarn generate-contributors |
8+
------------------------------------------- -->
9+
110
# Contributors
211

312
Thanks goes to these wonderful people:

docs/maintenance/versioning/dependant-version-upgrades.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ We generally start the process of supporting a new TypeScript version just after
8181
- Change the `SUPPORTED_TYPESCRIPT_VERSIONS` constant's `<` version to the next version of TypeScript
8282
- Change the `SUPPORTED_PRERELEASE_RANGES` constant to equal `['X.Y.2-rc']`
8383
- Rename and update `patches/typescript*` to the new TypeScript version
84-
- Run `yarn generate:lib` to update `scope-manager`
84+
- Run `yarn generate-lib` to update `scope-manager`
8585
1. Once all PRs needed for the RC update PR are merged, merge the RC update PR
8686
1. Once TypeScript releases the stable X.Y version, create and merge a PR with a title like `chore: bump TypeScript from X.YRC to X.Y` and the following changes:
8787
- In the root `package.json`, remove `|| X.Y.2-rc2` from the `dependency` on `typescript`, and bump its `<` version to the next version of TypeScript

nx.json

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"inputs": [
2828
"default",
2929
"{workspaceRoot}/.eslintrc.js",
30+
"{workspaceRoot}/yarn.lock",
3031
"{workspaceRoot}/.eslintignore"
3132
]
3233
}

package.json

+20-23
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@
3030
"check-spelling": "cspell --config=.cspell.json \"**/*.{md,mdx,ts,mts,cts,js,cjs,mjs,tsx,jsx}\" --no-progress --show-context --show-suggestions",
3131
"clean": "lerna clean -y && nx run-many --target=clean",
3232
"format": "prettier --write .",
33-
"generate-contributors": "yarn tsx ./tools/generate-contributors.ts",
34-
"generate-sponsors": "yarn tsx ./tools/generate-sponsors.ts",
35-
"generate-website-dts": "yarn tsx ./tools/generate-website-dts.ts",
36-
"generate-lib": "nx generate-lib @typescript-eslint/scope-manager",
37-
"lint-fix": "eslint . --fix",
33+
"generate-breaking-changes": "nx run eslint-plugin:generate-breaking-changes",
34+
"generate-configs": "nx run eslint-plugin:generate-configs",
35+
"generate-contributors": "nx run repo-tools:generate-contributors",
36+
"generate-sponsors": "nx run repo-tools:generate-sponsors",
37+
"generate-website-dts": "nx run website:generate-website-dts",
38+
"generate-lib": "nx run scope-manager:generate-lib",
39+
"lint-fix": "yarn lint --fix",
3840
"lint-markdown-fix": "yarn lint-markdown --fix",
3941
"lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
4042
"lint": "nx run-many --target=lint --parallel",
41-
"postinstall": "yarn tsx ./tools/postinstall.ts",
43+
"postinstall": "nx run repo-tools:postinstall-script",
4244
"pre-commit": "yarn lint-staged",
4345
"start": "nx run website:start",
44-
"test": "nx run-many --target=test --parallel",
45-
"test-integration": "yarn jest -c ./tests/integration/jest.config.js",
46+
"test": "nx run-many --target=test --parallel --exclude integration-tests",
47+
"test-integration": "nx run integration-tests:test",
4648
"typecheck": "nx run-many --target=typecheck --parallel"
4749
},
4850
"engines": {
@@ -68,7 +70,6 @@
6870
"@types/jest-specific-snapshot": "^0.5.5",
6971
"@types/lodash": "^4.14.182",
7072
"@types/marked": "^4.0.3",
71-
"@types/ncp": "^2.0.5",
7273
"@types/node": "^18.11.9",
7374
"@types/prettier": "^2.6.0",
7475
"@types/rimraf": "^3.0.2",
@@ -79,14 +80,16 @@
7980
"cross-fetch": "^3.1.5",
8081
"cspell": "^6.0.0",
8182
"downlevel-dts": "^0.11.0",
82-
"eslint": "^8.15.0",
83-
"eslint-plugin-deprecation": "^1.3.2",
83+
"eslint": "^8.34.0",
84+
"eslint-plugin-deprecation": "^1.3.3",
8485
"eslint-plugin-eslint-comments": "^3.2.0",
85-
"eslint-plugin-eslint-plugin": "^5.0.1",
86-
"eslint-plugin-import": "^2.26.0",
87-
"eslint-plugin-jest": "^27.0.0",
86+
"eslint-plugin-eslint-plugin": "^5.0.8",
87+
"eslint-plugin-import": "^2.27.5",
88+
"eslint-plugin-jest": "^27.2.1",
89+
"eslint-plugin-jsx-a11y": "^6.7.1",
90+
"eslint-plugin-react": "^7.32.2",
91+
"eslint-plugin-react-hooks": "^4.6.0",
8892
"eslint-plugin-simple-import-sort": "^10.0.0",
89-
"execa": "5.1.1",
9093
"glob": "^8.0.1",
9194
"husky": "^8.0.1",
9295
"jest": "^29.0.3",
@@ -97,10 +100,9 @@
97100
"lint-staged": "^13.0.0",
98101
"make-dir": "^3.1.0",
99102
"markdownlint-cli": "^0.33.0",
100-
"ncp": "^2.0.0",
101103
"nx": "15.6.3",
102104
"patch-package": "^6.4.7",
103-
"prettier": "2.8.1",
105+
"prettier": "^2.8.4",
104106
"pretty-format": "^29.0.3",
105107
"rimraf": "^4.0.0",
106108
"tmp": "^0.2.1",
@@ -110,17 +112,12 @@
110112
"typescript": ">=4.2.4 <5.0.0"
111113
},
112114
"resolutions": {
113-
"typescript": "~4.9.3",
115+
"typescript": "~4.9.5",
114116
"@types/node": "^18.11.9",
115-
"@jest/create-cache-key-function": "^29",
116117
"@jest/reporters": "^29",
117118
"@jest/test-result": "^29",
118119
"jest-config": "^29",
119-
"jest-diff": "^29",
120-
"jest-get-type": "^29",
121-
"jest-matcher-utils": "^29",
122120
"jest-resolve": "^29",
123-
"jest-snapshot": "^29",
124121
"jest-util": "^29",
125122
"pretty-format": "^29",
126123
"@swc/core-android-arm-eabi": "npm:dummypkg-a@1.0.0",

packages/ast-spec/project.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"executor": "@nrwl/linter:eslint",
1717
"outputs": ["{options.outputFile}"],
1818
"options": {
19-
"lintFilePatterns": ["packages/ast-spec/**/*.ts"]
19+
"lintFilePatterns": ["packages/ast-spec/**/*.{mts,cts,ts,tsx}"],
20+
"ignorePath": ".eslintignore"
2021
}
2122
}
2223
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Foo {
2-
accessor 1 = 2;
2+
accessor [1 + 1] = 2;
33
}

packages/ast-spec/src/element/AccessorProperty/fixtures/key-computed-complex/snapshots/1-TSESTree-AST.shot

+37-16
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,38 @@ Program {
1111
body: Array [
1212
AccessorProperty {
1313
type: "AccessorProperty",
14-
computed: false,
14+
computed: true,
1515
declare: false,
16-
key: Literal {
17-
type: "Literal",
18-
raw: "1",
19-
value: 1,
16+
key: BinaryExpression {
17+
type: "BinaryExpression",
18+
left: Literal {
19+
type: "Literal",
20+
raw: "1",
21+
value: 1,
22+
23+
range: [24, 25],
24+
loc: {
25+
start: { column: 12, line: 2 },
26+
end: { column: 13, line: 2 },
27+
},
28+
},
29+
operator: "+",
30+
right: Literal {
31+
type: "Literal",
32+
raw: "1",
33+
value: 1,
34+
35+
range: [28, 29],
36+
loc: {
37+
start: { column: 16, line: 2 },
38+
end: { column: 17, line: 2 },
39+
},
40+
},
2041

21-
range: [23, 24],
42+
range: [24, 29],
2243
loc: {
23-
start: { column: 11, line: 2 },
24-
end: { column: 12, line: 2 },
44+
start: { column: 12, line: 2 },
45+
end: { column: 17, line: 2 },
2546
},
2647
},
2748
override: false,
@@ -31,22 +52,22 @@ Program {
3152
raw: "2",
3253
value: 2,
3354

34-
range: [27, 28],
55+
range: [33, 34],
3556
loc: {
36-
start: { column: 15, line: 2 },
37-
end: { column: 16, line: 2 },
57+
start: { column: 21, line: 2 },
58+
end: { column: 22, line: 2 },
3859
},
3960
},
4061

41-
range: [14, 29],
62+
range: [14, 35],
4263
loc: {
4364
start: { column: 2, line: 2 },
44-
end: { column: 17, line: 2 },
65+
end: { column: 23, line: 2 },
4566
},
4667
},
4768
],
4869

49-
range: [10, 31],
70+
range: [10, 37],
5071
loc: {
5172
start: { column: 10, line: 1 },
5273
end: { column: 1, line: 3 },
@@ -64,7 +85,7 @@ Program {
6485
},
6586
superClass: null,
6687

67-
range: [0, 31],
88+
range: [0, 37],
6889
loc: {
6990
start: { column: 0, line: 1 },
7091
end: { column: 1, line: 3 },
@@ -73,7 +94,7 @@ Program {
7394
],
7495
sourceType: "script",
7596

76-
range: [0, 32],
97+
range: [0, 38],
7798
loc: {
7899
start: { column: 0, line: 1 },
79100
end: { column: 0, line: 4 },

0 commit comments

Comments
 (0)