Skip to content

Commit

Permalink
chore: cleanup repo lint + typechecking (#6473)
Browse files Browse the repository at this point in the history
* chore: cleanup repo lint + typechecking

* fixes 1

* fixes 2

* fixture

* tests

* pin tsnode

* fix hardcoded paths
  • Loading branch information
bradzacher committed Feb 16, 2023
1 parent b88cd23 commit 98dec37
Show file tree
Hide file tree
Showing 243 changed files with 2,554 additions and 1,740 deletions.
10 changes: 3 additions & 7 deletions .eslintignore
Expand Up @@ -7,12 +7,8 @@ __snapshots__
.docusaurus
build

packages/eslint-plugin-tslint/tests

packages/website/**/*.js
packages/website/**/*.d.ts
packages/website-eslint/**/*.js
packages/website-eslint/**/*.d.ts

# Files copied as part of the build
packages/types/src/generated/**/*.ts

# Playground types downloaded from the web
packages/website/src/vendor
42 changes: 34 additions & 8 deletions .eslintrc.js
@@ -1,3 +1,5 @@
// @ts-check
/** @type {import('@typescript-eslint/utils').TSESLint.Linter.Config} */
module.exports = {
root: true,
plugins: [
Expand All @@ -11,7 +13,7 @@ module.exports = {
'simple-import-sort',
],
env: {
es6: true,
es2020: true,
node: true,
},
extends: [
Expand All @@ -25,7 +27,6 @@ module.exports = {
project: [
'./tsconfig.eslint.json',
'./packages/*/tsconfig.json',
'./tests/integration/tsconfig.json',
/**
* We are currently in the process of transitioning to nx's out of the box structure and
* so need to manually specify converted packages' tsconfig.build.json and tsconfig.spec.json
Expand Down Expand Up @@ -156,6 +157,7 @@ module.exports = {
'eslint-disable-line',
'eslint-disable-next-line',
'eslint-enable',
'global',
],
},
],
Expand Down Expand Up @@ -202,6 +204,18 @@ module.exports = {
'one-var': ['error', 'never'],
},
overrides: [
{
files: ['*.js'],
extends: ['plugin:@typescript-eslint/disable-type-checked'],
rules: {
// turn off other type-aware rules
'deprecation/deprecation': 'off',
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',

// turn off rules that don't apply to JS code
'@typescript-eslint/explicit-function-return-type': 'off',
},
},
// all test files
{
files: [
Expand All @@ -210,9 +224,8 @@ module.exports = {
'./packages/*/tests/**/spec.ts',
'./packages/*/tests/**/test.ts',
'./packages/parser/tests/**/*.ts',
'./tests/integration/**/*.test.ts',
'./tests/integration/integration-test-base.ts',
'./tests/integration/pack-packages.ts',
'./packages/integration-tests/tools/integration-test-base.ts',
'./packages/integration-tests/tools/pack-packages.ts',
],
env: {
'jest/globals': true,
Expand Down Expand Up @@ -312,7 +325,12 @@ module.exports = {
},
// tools and tests
{
files: ['**/tools/**/*.*t*', '**/tests/**/*.ts'],
files: [
'**/tools/**/*.*t*',
'**/tests/**/*.ts',
'./packages/repo-tools/**/*.*t*',
'./packages/integration-tests/**/*.*t*',
],
rules: {
// allow console logs in tools and tests
'no-console': 'off',
Expand Down Expand Up @@ -346,17 +364,18 @@ module.exports = {
},
},
{
files: ['./packages/website/'],
files: ['./packages/website/**/*.{ts,tsx,mts,cts,js,jsx}'],
extends: [
'plugin:jsx-a11y/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
plugins: ['jsx-a11y', 'react', 'react-hooks'],
rules: {
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
'import/no-default-export': 'off',
'react/jsx-no-target-blank': 'off',
'react/no-unescaped-entities': 'off',
'@typescript-eslint/internal/prefer-ast-types-enum': 'off',
'react-hooks/exhaustive-deps': 'off', // TODO: enable it later
},
settings: {
Expand All @@ -373,5 +392,12 @@ module.exports = {
'no-console': 'off',
},
},
{
files: ['./packages/website-eslint/src/mock/**/*.js'],
rules: {
// mocks have to mirror their original
'import/no-default-export': 'off',
},
},
],
};
11 changes: 3 additions & 8 deletions .prettierignore
@@ -1,22 +1,17 @@
**/tests/fixtures/**/*
!packages/scope-manager/tests/fixtures/**/*
**/tests/fixture-project/**/*
**/dist
**/coverage
**/.vscode
**/.nyc_output
**/.vs
packages/eslint-plugin-tslint/tests/test-tslint-rules-directory/alwaysFailRule.js
packages/eslint-plugin/src/configs/*.json
CONTRIBUTORS.md
packages/ast-spec/src/*/*/fixtures/_error_/*/fixture.ts
packages/eslint-plugin/tests/fixtures/indent/

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

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

packages/website/.docusaurus
packages/website/build
packages/website/src/vendor
9 changes: 9 additions & 0 deletions CONTRIBUTORS.md
@@ -1,3 +1,12 @@
<!-- ------------------------------------------
| DO NOT MODIFY THIS FILE MANUALLY |
| |
| THIS FILE HAS BEEN AUTOMATICALLY GENERATED |
| |
| YOU CAN REGENERATE THIS FILE USING |
| yarn generate-contributors |
------------------------------------------- -->

# Contributors

Thanks goes to these wonderful people:
Expand Down
2 changes: 1 addition & 1 deletion docs/maintenance/versioning/dependant-version-upgrades.mdx
Expand Up @@ -81,7 +81,7 @@ We generally start the process of supporting a new TypeScript version just after
- Change the `SUPPORTED_TYPESCRIPT_VERSIONS` constant's `<` version to the next version of TypeScript
- Change the `SUPPORTED_PRERELEASE_RANGES` constant to equal `['X.Y.2-rc']`
- Rename and update `patches/typescript*` to the new TypeScript version
- Run `yarn generate:lib` to update `scope-manager`
- Run `yarn generate-lib` to update `scope-manager`
1. Once all PRs needed for the RC update PR are merged, merge the RC update PR
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:
- 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
Expand Down
1 change: 1 addition & 0 deletions nx.json
Expand Up @@ -27,6 +27,7 @@
"inputs": [
"default",
"{workspaceRoot}/.eslintrc.js",
"{workspaceRoot}/yarn.lock",
"{workspaceRoot}/.eslintignore"
]
}
Expand Down
43 changes: 20 additions & 23 deletions package.json
Expand Up @@ -30,19 +30,21 @@
"check-spelling": "cspell --config=.cspell.json \"**/*.{md,mdx,ts,mts,cts,js,cjs,mjs,tsx,jsx}\" --no-progress --show-context --show-suggestions",
"clean": "lerna clean -y && nx run-many --target=clean",
"format": "prettier --write .",
"generate-contributors": "yarn tsx ./tools/generate-contributors.ts",
"generate-sponsors": "yarn tsx ./tools/generate-sponsors.ts",
"generate-website-dts": "yarn tsx ./tools/generate-website-dts.ts",
"generate-lib": "nx generate-lib @typescript-eslint/scope-manager",
"lint-fix": "eslint . --fix",
"generate-breaking-changes": "nx run eslint-plugin:generate-breaking-changes",
"generate-configs": "nx run eslint-plugin:generate-configs",
"generate-contributors": "nx run repo-tools:generate-contributors",
"generate-sponsors": "nx run repo-tools:generate-sponsors",
"generate-website-dts": "nx run website:generate-website-dts",
"generate-lib": "nx run scope-manager:generate-lib",
"lint-fix": "yarn lint --fix",
"lint-markdown-fix": "yarn lint-markdown --fix",
"lint-markdown": "markdownlint \"**/*.md\" --config=.markdownlint.json --ignore-path=.markdownlintignore",
"lint": "nx run-many --target=lint --parallel",
"postinstall": "yarn tsx ./tools/postinstall.ts",
"postinstall": "nx run repo-tools:postinstall-script",
"pre-commit": "yarn lint-staged",
"start": "nx run website:start",
"test": "nx run-many --target=test --parallel",
"test-integration": "yarn jest -c ./tests/integration/jest.config.js",
"test": "nx run-many --target=test --parallel --exclude integration-tests",
"test-integration": "nx run integration-tests:test",
"typecheck": "nx run-many --target=typecheck --parallel"
},
"engines": {
Expand All @@ -68,7 +70,6 @@
"@types/jest-specific-snapshot": "^0.5.5",
"@types/lodash": "^4.14.182",
"@types/marked": "^4.0.3",
"@types/ncp": "^2.0.5",
"@types/node": "^18.11.9",
"@types/prettier": "^2.6.0",
"@types/rimraf": "^3.0.2",
Expand All @@ -79,14 +80,16 @@
"cross-fetch": "^3.1.5",
"cspell": "^6.0.0",
"downlevel-dts": "^0.11.0",
"eslint": "^8.15.0",
"eslint-plugin-deprecation": "^1.3.2",
"eslint": "^8.34.0",
"eslint-plugin-deprecation": "^1.3.3",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^5.0.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.0.0",
"eslint-plugin-eslint-plugin": "^5.0.8",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"execa": "5.1.1",
"glob": "^8.0.1",
"husky": "^8.0.1",
"jest": "^29.0.3",
Expand All @@ -97,10 +100,9 @@
"lint-staged": "^13.0.0",
"make-dir": "^3.1.0",
"markdownlint-cli": "^0.33.0",
"ncp": "^2.0.0",
"nx": "15.6.3",
"patch-package": "^6.4.7",
"prettier": "2.8.1",
"prettier": "^2.8.4",
"pretty-format": "^29.0.3",
"rimraf": "^4.0.0",
"tmp": "^0.2.1",
Expand All @@ -110,17 +112,12 @@
"typescript": ">=4.2.4 <5.0.0"
},
"resolutions": {
"typescript": "~4.9.3",
"typescript": "~4.9.5",
"@types/node": "^18.11.9",
"@jest/create-cache-key-function": "^29",
"@jest/reporters": "^29",
"@jest/test-result": "^29",
"jest-config": "^29",
"jest-diff": "^29",
"jest-get-type": "^29",
"jest-matcher-utils": "^29",
"jest-resolve": "^29",
"jest-snapshot": "^29",
"jest-util": "^29",
"pretty-format": "^29",
"@swc/core-android-arm-eabi": "npm:dummypkg-a@1.0.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/ast-spec/project.json
Expand Up @@ -16,7 +16,8 @@
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["packages/ast-spec/**/*.ts"]
"lintFilePatterns": ["packages/ast-spec/**/*.{mts,cts,ts,tsx}"],
"ignorePath": ".eslintignore"
}
}
}
Expand Down
@@ -1,3 +1,3 @@
class Foo {
accessor 1 = 2;
accessor [1 + 1] = 2;
}
Expand Up @@ -11,17 +11,38 @@ Program {
body: Array [
AccessorProperty {
type: "AccessorProperty",
computed: false,
computed: true,
declare: false,
key: Literal {
type: "Literal",
raw: "1",
value: 1,
key: BinaryExpression {
type: "BinaryExpression",
left: Literal {
type: "Literal",
raw: "1",
value: 1,
range: [24, 25],
loc: {
start: { column: 12, line: 2 },
end: { column: 13, line: 2 },
},
},
operator: "+",
right: Literal {
type: "Literal",
raw: "1",
value: 1,
range: [28, 29],
loc: {
start: { column: 16, line: 2 },
end: { column: 17, line: 2 },
},
},
range: [23, 24],
range: [24, 29],
loc: {
start: { column: 11, line: 2 },
end: { column: 12, line: 2 },
start: { column: 12, line: 2 },
end: { column: 17, line: 2 },
},
},
override: false,
Expand All @@ -31,22 +52,22 @@ Program {
raw: "2",
value: 2,
range: [27, 28],
range: [33, 34],
loc: {
start: { column: 15, line: 2 },
end: { column: 16, line: 2 },
start: { column: 21, line: 2 },
end: { column: 22, line: 2 },
},
},
range: [14, 29],
range: [14, 35],
loc: {
start: { column: 2, line: 2 },
end: { column: 17, line: 2 },
end: { column: 23, line: 2 },
},
},
],
range: [10, 31],
range: [10, 37],
loc: {
start: { column: 10, line: 1 },
end: { column: 1, line: 3 },
Expand All @@ -64,7 +85,7 @@ Program {
},
superClass: null,
range: [0, 31],
range: [0, 37],
loc: {
start: { column: 0, line: 1 },
end: { column: 1, line: 3 },
Expand All @@ -73,7 +94,7 @@ Program {
],
sourceType: "script",
range: [0, 32],
range: [0, 38],
loc: {
start: { column: 0, line: 1 },
end: { column: 0, line: 4 },
Expand Down

0 comments on commit 98dec37

Please sign in to comment.