diff --git a/eslint.config.js b/eslint.config.js index 2213ef1a12166..6dfa1d61adf90 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -74,50 +74,100 @@ module.exports = [ "import/no-extraneous-dependencies": "error", }, }, - { - files: ["**/*.ts"], - languageOptions: { - parser: parserTypeScriptESLint, - parserOptions: { - project: "./tsconfig.json", - }, - }, - plugins: { - "@typescript-eslint": pluginTypeScriptESLint, - }, - rules: { - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": "error", - "no-dupe-class-members": "off", - "@typescript-eslint/no-dupe-class-members": "error", - "no-undef": "off", - "no-redeclare": "off", - "@typescript-eslint/ban-ts-comment": [ - "error", - { - "ts-ignore": { descriptionFormat: "^\\(Babel 7 vs Babel 8\\) .+$" }, + ...compat + .extends( + "plugin:@typescript-eslint/recommended-type-checked", + "plugin:@typescript-eslint/stylistic-type-checked" + ) + .map(config => { + return { + ...config, + files: ["**/*.ts"], + languageOptions: { + parser: parserTypeScriptESLint, + parserOptions: { + project: "./tsconfig.eslint.json", + }, }, - ], - "@typescript-eslint/consistent-type-imports": [ - "error", - { disallowTypeAnnotations: false }, - ], - "@typescript-eslint/no-use-before-define": [ - "error", - { - functions: false, - classes: false, - allowNamedExports: true, + plugins: { + "@typescript-eslint": pluginTypeScriptESLint, }, - ], - "@typescript-eslint/no-unnecessary-type-assertion": "error", - "@typescript-eslint/no-confusing-void-expression": [ - "error", - { ignoreArrowShorthand: true }, - ], - "@typescript-eslint/no-import-type-side-effects": "error", - }, - }, + rules: { + ...config.rules, + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "error", + "no-dupe-class-members": "off", + "@typescript-eslint/no-dupe-class-members": "error", + "no-undef": "off", + "no-redeclare": "off", + "@typescript-eslint/ban-ts-comment": [ + "error", + { + "ts-ignore": { + descriptionFormat: "^\\(Babel 7 vs Babel 8\\) .+$", + }, + }, + ], + "@typescript-eslint/consistent-type-imports": [ + "error", + { disallowTypeAnnotations: false }, + ], + "@typescript-eslint/no-use-before-define": [ + "error", + { + functions: false, + classes: false, + allowNamedExports: true, + }, + ], + "@typescript-eslint/no-confusing-void-expression": [ + "error", + { ignoreArrowShorthand: true }, + ], + "@typescript-eslint/no-import-type-side-effects": "error", + + // Todo: Investigate, for each of these, whether we want them + "@typescript-eslint/array-type": "off", + "@typescript-eslint/await-thenable": "off", + "@typescript-eslint/ban-types": "off", + "@typescript-eslint/consistent-generic-constructors": "off", + "@typescript-eslint/consistent-indexed-object-style": "off", + "@typescript-eslint/consistent-type-definitions": "off", + "@typescript-eslint/dot-notation": "off", + "@typescript-eslint/no-base-to-string": "off", + "@typescript-eslint/no-duplicate-type-constituents": "off", + "@typescript-eslint/no-empty-function": "off", + "@typescript-eslint/no-empty-interface": "off", + "@typescript-eslint/no-misused-promises": "off", + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-redundant-type-constituents": "off", + "@typescript-eslint/no-this-alias": "off", + "@typescript-eslint/no-unnecessary-type-assertion": "off", + "@typescript-eslint/no-unsafe-assignment": "off", + "@typescript-eslint/no-unsafe-call": "off", + "@typescript-eslint/no-unsafe-declaration-merging": "off", + "@typescript-eslint/no-unsafe-member-access": "off", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/prefer-for-of": "off", + "@typescript-eslint/prefer-function-type": "off", + "@typescript-eslint/prefer-nullish-coalescing": "off", + "@typescript-eslint/prefer-optional-chain": "off", + "@typescript-eslint/prefer-string-starts-ends-with": "off", + "@typescript-eslint/require-await": "off", + "@typescript-eslint/restrict-plus-operands": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/sort-type-constituents": "off", + "@typescript-eslint/triple-slash-reference": "off", + "@typescript-eslint/unbound-method": "off", + "prefer-rest-params": "off", + + // https://github.com/typescript-eslint/typescript-eslint/issues/5014 + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-unsafe-argument": "off", + "@typescript-eslint/no-unsafe-return": "off", + }, + }; + }), { files: sourceFiles("js,ts,cjs,mjs"), languageOptions: { diff --git a/package.json b/package.json index 263ac3bd8ace3..6e777eb44a159 100644 --- a/package.json +++ b/package.json @@ -43,8 +43,8 @@ "@rollup/plugin-replace": "^5.0.2", "@types/jest": "^29.5.2", "@types/node": "^20.3.3", - "@typescript-eslint/eslint-plugin": "^5.61.0", - "@typescript-eslint/parser": "^5.61.0", + "@typescript-eslint/eslint-plugin": "^6.0.0", + "@typescript-eslint/parser": "^6.0.0", "babel-plugin-transform-charcodes": "^0.2.0", "c8": "^7.12.0", "chalk": "^5.0.0", diff --git a/packages/babel-types/src/converters/toStatement.ts b/packages/babel-types/src/converters/toStatement.ts index 9f33510b5dc93..3a074de4f4719 100644 --- a/packages/babel-types/src/converters/toStatement.ts +++ b/packages/babel-types/src/converters/toStatement.ts @@ -43,7 +43,7 @@ function toStatement(node: t.Node, ignore?: boolean): t.Statement | false { // @ts-expect-error todo(flow->ts): node.id might be missing if (mustHaveId && !node.id) { - newType = false as false; + newType = false; } if (!newType) { diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json new file mode 100644 index 0000000000000..c3b912f7c61e5 --- /dev/null +++ b/tsconfig.eslint.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "allowJs": true, + "strict": true + } +} diff --git a/yarn.lock b/yarn.lock index d19e9f1dcf4fb..d9937a5d809fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4012,21 +4012,21 @@ __metadata: languageName: node linkType: hard -"@eslint-community/eslint-utils@npm:^4.2.0": - version: 4.3.0 - resolution: "@eslint-community/eslint-utils@npm:4.3.0" +"@eslint-community/eslint-utils@npm:^4.2.0, @eslint-community/eslint-utils@npm:^4.3.0": + version: 4.4.0 + resolution: "@eslint-community/eslint-utils@npm:4.4.0" dependencies: eslint-visitor-keys: ^3.3.0 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 - checksum: f487760a692f0f1fef76e248ad72976919576ba57edc2b1b1dc1d182553bae6b5bf7b078e654da85d04f0af8a485d20bd26280002768f4fbcd2e330078340cb0 + checksum: cdfe3ae42b4f572cbfb46d20edafe6f36fc5fb52bf2d90875c58aefe226892b9677fef60820e2832caf864a326fe4fc225714c46e8389ccca04d5f9288aabd22 languageName: node linkType: hard -"@eslint-community/regexpp@npm:^4.4.0": - version: 4.4.0 - resolution: "@eslint-community/regexpp@npm:4.4.0" - checksum: 2d127af0c752b80e8a782eacfe996a86925d21de92da3ffc6f9e615e701145e44a62e26bdd88bfac2cd76779c39ba8d9875a91046ec5e7e5f23cb647c247ea6a +"@eslint-community/regexpp@npm:^4.4.0, @eslint-community/regexpp@npm:^4.5.0": + version: 4.5.1 + resolution: "@eslint-community/regexpp@npm:4.5.1" + checksum: 6d901166d64998d591fab4db1c2f872981ccd5f6fe066a1ad0a93d4e11855ecae6bfb76660869a469563e8882d4307228cebd41142adb409d182f2966771e57e languageName: node linkType: hard @@ -4849,10 +4849,10 @@ __metadata: languageName: node linkType: hard -"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": - version: 7.0.11 - resolution: "@types/json-schema@npm:7.0.11" - checksum: 527bddfe62db9012fccd7627794bd4c71beb77601861055d87e3ee464f2217c85fca7a4b56ae677478367bbd248dbde13553312b7d4dbc702a2f2bbf60c4018d +"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.11, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": + version: 7.0.12 + resolution: "@types/json-schema@npm:7.0.12" + checksum: 00239e97234eeb5ceefb0c1875d98ade6e922bfec39dd365ec6bd360b5c2f825e612ac4f6e5f1d13601b8b30f378f15e6faa805a3a732f4a1bbe61915163d293 languageName: node linkType: hard @@ -4942,44 +4942,48 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^5.61.0": - version: 5.61.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.61.0" +"@typescript-eslint/eslint-plugin@npm:^6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/eslint-plugin@npm:6.0.0" dependencies: - "@eslint-community/regexpp": ^4.4.0 - "@typescript-eslint/scope-manager": 5.61.0 - "@typescript-eslint/type-utils": 5.61.0 - "@typescript-eslint/utils": 5.61.0 + "@eslint-community/regexpp": ^4.5.0 + "@typescript-eslint/scope-manager": 6.0.0 + "@typescript-eslint/type-utils": 6.0.0 + "@typescript-eslint/utils": 6.0.0 + "@typescript-eslint/visitor-keys": 6.0.0 debug: ^4.3.4 + grapheme-splitter: ^1.0.4 graphemer: ^1.4.0 - ignore: ^5.2.0 + ignore: ^5.2.4 + natural-compare: ^1.4.0 natural-compare-lite: ^1.4.0 - semver: ^7.3.7 - tsutils: ^3.21.0 + semver: ^7.5.0 + ts-api-utils: ^1.0.1 peerDependencies: - "@typescript-eslint/parser": ^5.0.0 - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + "@typescript-eslint/parser": ^6.0.0 || ^6.0.0-alpha + eslint: ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: d9e891fb43ccb75322fc40d58d02479f98bd3c962db71075438868b13f579643d714a24b5477a827be7ca2e7e9f6058c406241b6696a6395c6fcbd6de76e015c + checksum: 863f30b8ceb24d104fc8a41774e4f597a35525533aa99721198293b51628a2d986dcc6413893f27eb9db5a49c2fd2cc91d3aece8ed23d590f3eb4e9939c3d6ad languageName: node linkType: hard -"@typescript-eslint/parser@npm:^5.61.0": - version: 5.61.0 - resolution: "@typescript-eslint/parser@npm:5.61.0" +"@typescript-eslint/parser@npm:^6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/parser@npm:6.0.0" dependencies: - "@typescript-eslint/scope-manager": 5.61.0 - "@typescript-eslint/types": 5.61.0 - "@typescript-eslint/typescript-estree": 5.61.0 + "@typescript-eslint/scope-manager": 6.0.0 + "@typescript-eslint/types": 6.0.0 + "@typescript-eslint/typescript-estree": 6.0.0 + "@typescript-eslint/visitor-keys": 6.0.0 debug: ^4.3.4 peerDependencies: - eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 + eslint: ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: 2422bca03ecc6830700aaa739ec46b8e9ab6c0a47a67f140dc6b62a42a8b98997e73bce52c6a010b8a9b461211c46ba865d5b7f680a7823cf5c245d3b61f7fd5 + checksum: a22f0c8f67eb244134f9d79d78faf1b6e2c0965495d78eef94a5680868f3d0fd9446a3ce5dc1e36dde02587da5d962944f3d83679c712d0b819ac99cdb9f7143 languageName: node linkType: hard @@ -4993,20 +4997,30 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.61.0": - version: 5.61.0 - resolution: "@typescript-eslint/type-utils@npm:5.61.0" +"@typescript-eslint/scope-manager@npm:6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/scope-manager@npm:6.0.0" dependencies: - "@typescript-eslint/typescript-estree": 5.61.0 - "@typescript-eslint/utils": 5.61.0 + "@typescript-eslint/types": 6.0.0 + "@typescript-eslint/visitor-keys": 6.0.0 + checksum: 450015be6454f953d0ea0da020ab47597e96a7a15c1002eed16c57430783bd7b045513d57a126606fb35e8971f1ce65fbefd845e3b5496bf75284cbe1681d0b9 + languageName: node + linkType: hard + +"@typescript-eslint/type-utils@npm:6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/type-utils@npm:6.0.0" + dependencies: + "@typescript-eslint/typescript-estree": 6.0.0 + "@typescript-eslint/utils": 6.0.0 debug: ^4.3.4 - tsutils: ^3.21.0 + ts-api-utils: ^1.0.1 peerDependencies: - eslint: "*" + eslint: ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: f0203fd48c6218f004dd73a9a71ba4cf97f015d0f13a7b3c821a3ba7ec814839bae270a1db589184ca7091fe54815a3171d1993e8a25200bf33e131bd6e855d4 + checksum: 53f46237891cfa738f6a4bc766a4dbb8d745b1cb9cbe2d2b40f2a4abcf0327d4aa92d9ce5361e87cd26d82e0159f358e28b0c67759eb053c4fd752654dc9dcb1 languageName: node linkType: hard @@ -5017,6 +5031,13 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/types@npm:6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/types@npm:6.0.0" + checksum: a2e232b66b0b057152f4a94d7e0be75f32e389c9c1ec9ed9901ed5aab6e5df08c07bde9865710e315d835e4400ec2232f9c3c525b6edf8a85675ebfbfb69d3a5 + languageName: node + linkType: hard + "@typescript-eslint/typescript-estree@npm:5.61.0": version: 5.61.0 resolution: "@typescript-eslint/typescript-estree@npm:5.61.0" @@ -5035,9 +5056,45 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.61.0, @typescript-eslint/utils@npm:^5.10.0": - version: 5.61.0 - resolution: "@typescript-eslint/utils@npm:5.61.0" +"@typescript-eslint/typescript-estree@npm:6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/typescript-estree@npm:6.0.0" + dependencies: + "@typescript-eslint/types": 6.0.0 + "@typescript-eslint/visitor-keys": 6.0.0 + debug: ^4.3.4 + globby: ^11.1.0 + is-glob: ^4.0.3 + semver: ^7.5.0 + ts-api-utils: ^1.0.1 + peerDependenciesMeta: + typescript: + optional: true + checksum: 6214ff9cc3c4fd7fe03f846e96a498ecf85916083bb60d419bc5a12142cff912670032b1de5ea52ab353ca7eeb4e1cc8fa475a22958b010043c88e274df49859 + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/utils@npm:6.0.0" + dependencies: + "@eslint-community/eslint-utils": ^4.3.0 + "@types/json-schema": ^7.0.11 + "@types/semver": ^7.3.12 + "@typescript-eslint/scope-manager": 6.0.0 + "@typescript-eslint/types": 6.0.0 + "@typescript-eslint/typescript-estree": 6.0.0 + eslint-scope: ^5.1.1 + semver: ^7.5.0 + peerDependencies: + eslint: ^7.0.0 || ^8.0.0 + checksum: 94b9b616282f6fa1ae50ba371a482a3c8c50268ef8039b4e86d29c445e95025c819358a5cc9955c4668482d97ef026e7a49e7f4b3a4685347136ef5bbd297e4d + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:^5.10.0": + version: 5.55.0 + resolution: "@typescript-eslint/utils@npm:5.55.0" dependencies: "@eslint-community/eslint-utils": ^4.2.0 "@types/json-schema": ^7.0.9 @@ -5049,7 +5106,7 @@ __metadata: semver: ^7.3.7 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: 24efc1964e6c92db96fe0d9a390550e4f27e8f353e51a9b46bda03e6692ea5d40f398d539235a4ff0894e9e45dfcfb51df953ade2ae9d17a1421449625ce6f5a + checksum: 368cfc3fb9d6af6901e739e2e41c3f7f1c1244576607445f4f59d95eccb237f73e1a75e7f0816ec9a32a0f1ec6bb4a3602a99e17e70fe184e62f7c69dcbe4b8d languageName: node linkType: hard @@ -5063,6 +5120,16 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/visitor-keys@npm:6.0.0": + version: 6.0.0 + resolution: "@typescript-eslint/visitor-keys@npm:6.0.0" + dependencies: + "@typescript-eslint/types": 6.0.0 + eslint-visitor-keys: ^3.4.1 + checksum: b0d9848a4490174db1d25b5f336548bb11dde4e0ce664c3dc341bed89fb3a3ada091aeb7f5d2d371433815332d93339c6cb77f7a24469c329c3d055b15237bfa + languageName: node + linkType: hard + "@unicode/unicode-15.0.0@npm:^1.3.1": version: 1.3.1 resolution: "@unicode/unicode-15.0.0@npm:1.3.1" @@ -6294,8 +6361,8 @@ __metadata: "@rollup/plugin-replace": ^5.0.2 "@types/jest": ^29.5.2 "@types/node": ^20.3.3 - "@typescript-eslint/eslint-plugin": ^5.61.0 - "@typescript-eslint/parser": ^5.61.0 + "@typescript-eslint/eslint-plugin": ^6.0.0 + "@typescript-eslint/parser": ^6.0.0 babel-plugin-transform-charcodes: ^0.2.0 c8: ^7.12.0 chalk: ^5.0.0 @@ -9594,6 +9661,13 @@ fsevents@^1.2.7: languageName: node linkType: hard +"grapheme-splitter@npm:^1.0.4": + version: 1.0.4 + resolution: "grapheme-splitter@npm:1.0.4" + checksum: 0c22ec54dee1b05cd480f78cf14f732cb5b108edc073572c4ec205df4cd63f30f8db8025afc5debc8835a8ddeacf648a1c7992fe3dcd6ad38f9a476d84906620 + languageName: node + linkType: hard + "graphemer@npm:^1.4.0": version: 1.4.0 resolution: "graphemer@npm:1.4.0" @@ -9963,10 +10037,10 @@ fsevents@^1.2.7: languageName: node linkType: hard -"ignore@npm:^5.1.1, ignore@npm:^5.2.0": - version: 5.2.0 - resolution: "ignore@npm:5.2.0" - checksum: 6b1f926792d614f64c6c83da3a1f9c83f6196c2839aa41e1e32dd7b8d174cef2e329d75caabb62cb61ce9dc432f75e67d07d122a037312db7caa73166a1bdb77 +"ignore@npm:^5.1.1, ignore@npm:^5.2.0, ignore@npm:^5.2.4": + version: 5.2.4 + resolution: "ignore@npm:5.2.4" + checksum: 3d4c309c6006e2621659311783eaea7ebcd41fe4ca1d78c91c473157ad6666a57a2df790fe0d07a12300d9aac2888204d7be8d59f9aaf665b1c7fcdb432517ef languageName: node linkType: hard @@ -14151,14 +14225,14 @@ fsevents@^1.2.7: languageName: node linkType: hard -"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7": - version: 7.3.7 - resolution: "semver@npm:7.3.7" +"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.0": + version: 7.5.2 + resolution: "semver@npm:7.5.2" dependencies: lru-cache: ^6.0.0 bin: semver: bin/semver.js - checksum: 2fa3e877568cd6ce769c75c211beaed1f9fce80b28338cadd9d0b6c40f2e2862bafd62c19a6cff42f3d54292b7c623277bcab8816a2b5521cf15210d43e75232 + checksum: 3fdf5d1e6f170fe8bcc41669e31787649af91af7f54f05c71d0865bb7aa27e8b92f68b3e6b582483e2c1c648008bc84249d2cd86301771fe5cbf7621d1fe5375 languageName: node linkType: hard @@ -15290,6 +15364,15 @@ fsevents@^1.2.7: languageName: node linkType: hard +"ts-api-utils@npm:^1.0.1": + version: 1.0.1 + resolution: "ts-api-utils@npm:1.0.1" + peerDependencies: + typescript: ">=4.2.0" + checksum: 78794fc7270d295b36c1ac613465b5dc7e7226907a533125b30f177efef9dd630d4e503b00be31b44335eb2ebf9e136ebe97353f8fc5d383885d5fead9d54c09 + languageName: node + linkType: hard + "ts-node@npm:^10.9.1": version: 10.9.1 resolution: "ts-node@npm:10.9.1"