diff --git a/integration_test/__snapshots__/nuxt-auth.spec.ts.snap b/integration_test/__snapshots__/nuxt-auth.spec.ts.snap index b1132a62..99030c6f 100644 --- a/integration_test/__snapshots__/nuxt-auth.spec.ts.snap +++ b/integration_test/__snapshots__/nuxt-auth.spec.ts.snap @@ -133,9 +133,6 @@ exports[`nuxt-auth > nuxt-auth 1`] = ` "**/*.?([cm])tsx", "**/*.vue", ], - "plugins": [ - "typescript", - ], "rules": { "@typescript-eslint/ban-ts-comment": [ "error", @@ -211,6 +208,16 @@ exports[`nuxt-auth > nuxt-auth 1`] = ` "no-with": "off", }, }, + { + "files": [ + "**/*.?([cm])ts", + "**/*.?([cm])tsx", + "**/*.vue", + ], + "plugins": [ + "typescript", + ], + }, { "files": [ "**/__tests__/**/*.?([cm])[jt]s?(x)", @@ -1004,9 +1011,6 @@ exports[`nuxt-auth --js-plugins > nuxt-auth--js-plugins 1`] = ` "**/*.?([cm])tsx", "**/*.vue", ], - "plugins": [ - "typescript", - ], "rules": { "@typescript-eslint/ban-ts-comment": [ "error", @@ -1082,6 +1086,16 @@ exports[`nuxt-auth --js-plugins > nuxt-auth--js-plugins 1`] = ` "no-with": "off", }, }, + { + "files": [ + "**/*.?([cm])ts", + "**/*.?([cm])tsx", + "**/*.vue", + ], + "plugins": [ + "typescript", + ], + }, { "files": [ "**/__tests__/**/*.?([cm])[jt]s?(x)", @@ -2260,9 +2274,6 @@ exports[`nuxt-auth --type-aware > nuxt-auth--type-aware 1`] = ` "**/*.?([cm])tsx", "**/*.vue", ], - "plugins": [ - "typescript", - ], "rules": { "@typescript-eslint/ban-ts-comment": [ "error", @@ -2338,6 +2349,16 @@ exports[`nuxt-auth --type-aware > nuxt-auth--type-aware 1`] = ` "no-with": "off", }, }, + { + "files": [ + "**/*.?([cm])ts", + "**/*.?([cm])tsx", + "**/*.vue", + ], + "plugins": [ + "typescript", + ], + }, { "files": [ "**/__tests__/**/*.?([cm])[jt]s?(x)", @@ -3123,9 +3144,6 @@ exports[`nuxt-auth merge > nuxt-auth--merge 1`] = ` "**/*.?([cm])tsx", "**/*.vue", ], - "plugins": [ - "typescript", - ], "rules": { "@typescript-eslint/ban-ts-comment": [ "error", @@ -3202,6 +3220,16 @@ exports[`nuxt-auth merge > nuxt-auth--merge 1`] = ` "no-with": "off", }, }, + { + "files": [ + "**/*.?([cm])ts", + "**/*.?([cm])tsx", + "**/*.vue", + ], + "plugins": [ + "typescript", + ], + }, { "files": [ "**/__tests__/**/*.?([cm])[jt]s?(x)", diff --git a/integration_test/__snapshots__/pupeeteer.spec.ts.snap b/integration_test/__snapshots__/pupeeteer.spec.ts.snap index a30713f1..94650845 100644 --- a/integration_test/__snapshots__/pupeeteer.spec.ts.snap +++ b/integration_test/__snapshots__/pupeeteer.spec.ts.snap @@ -60,61 +60,35 @@ exports[`puppeteer > puppeteer 1`] = ` "**/*.ts", ], "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "plugins": [ - "typescript", - ], - "rules": { + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/array-type": [ + "error", + { + "default": "array-simple", + }, + ], "@typescript-eslint/ban-ts-comment": "error", + "@typescript-eslint/ban-tslint-comment": "error", + "@typescript-eslint/consistent-generic-constructors": "error", + "@typescript-eslint/consistent-indexed-object-style": "error", + "@typescript-eslint/consistent-type-definitions": [ + "error", + "interface", + ], + "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", "@typescript-eslint/no-duplicate-enum-values": "error", "@typescript-eslint/no-empty-object-type": "error", - "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-extra-non-null-assertion": "error", + "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/no-inferrable-types": "error", "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-namespace": "error", "@typescript-eslint/no-non-null-asserted-optional-chain": "error", + "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-require-imports": "error", "@typescript-eslint/no-this-alias": "error", "@typescript-eslint/no-unnecessary-type-constraint": "error", @@ -122,22 +96,17 @@ exports[`puppeteer > puppeteer 1`] = ` "@typescript-eslint/no-unsafe-function-type": "error", "@typescript-eslint/no-wrapper-object-types": "error", "@typescript-eslint/prefer-as-const": "error", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/prefer-function-type": "error", "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/prefer-ts-expect-error": "error", "@typescript-eslint/triple-slash-reference": "error", "no-array-constructor": "error", - "no-unused-expressions": "error", - "no-unused-vars": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { "no-class-assign": "off", "no-const-assign": "off", "no-dupe-class-members": "off", "no-dupe-keys": "off", + "no-empty-function": "off", "no-func-assign": "off", "no-import-assign": "off", "no-new-native-nonconstructor": "off", @@ -146,6 +115,14 @@ exports[`puppeteer > puppeteer 1`] = ` "no-setter-return": "off", "no-this-before-super": "off", "no-unsafe-negation": "off", + "no-unused-expressions": "error", + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + }, + ], "no-with": "off", "prefer-rest-params": "error", "prefer-spread": "error", @@ -158,19 +135,6 @@ exports[`puppeteer > puppeteer 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/ban-tslint-comment": "error", - "@typescript-eslint/consistent-generic-constructors": "error", - "@typescript-eslint/consistent-indexed-object-style": "error", - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/no-confusing-non-null-assertion": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/prefer-function-type": "error", - "no-empty-function": "error", - }, }, { "files": [ @@ -179,35 +143,14 @@ exports[`puppeteer > puppeteer 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/array-type": [ - "error", - { - "default": "array-simple", - }, - ], - "@typescript-eslint/consistent-type-definitions": [ - "error", - "interface", - ], - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-import-type-side-effects": "error", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unsafe-function-type": "error", - "@typescript-eslint/no-wrapper-object-types": "error", - "@typescript-eslint/prefer-ts-expect-error": "error", - "no-empty-function": "off", - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - }, - ], - }, + }, + { + "files": [ + "**/*.ts", + ], + "plugins": [ + "typescript", + ], }, { "files": [ @@ -413,61 +356,36 @@ exports[`puppeteer --js-plugins > puppeteer--js-plugins 1`] = ` "**/*.ts", ], "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "plugins": [ - "typescript", - ], - "rules": { + "@puppeteer/use-using": "error", + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/array-type": [ + "error", + { + "default": "array-simple", + }, + ], "@typescript-eslint/ban-ts-comment": "error", + "@typescript-eslint/ban-tslint-comment": "error", + "@typescript-eslint/consistent-generic-constructors": "error", + "@typescript-eslint/consistent-indexed-object-style": "error", + "@typescript-eslint/consistent-type-definitions": [ + "error", + "interface", + ], + "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", "@typescript-eslint/no-duplicate-enum-values": "error", "@typescript-eslint/no-empty-object-type": "error", - "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-extra-non-null-assertion": "error", + "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/no-inferrable-types": "error", "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-namespace": "error", "@typescript-eslint/no-non-null-asserted-optional-chain": "error", + "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-require-imports": "error", "@typescript-eslint/no-this-alias": "error", "@typescript-eslint/no-unnecessary-type-constraint": "error", @@ -475,22 +393,17 @@ exports[`puppeteer --js-plugins > puppeteer--js-plugins 1`] = ` "@typescript-eslint/no-unsafe-function-type": "error", "@typescript-eslint/no-wrapper-object-types": "error", "@typescript-eslint/prefer-as-const": "error", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/prefer-function-type": "error", "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/prefer-ts-expect-error": "error", "@typescript-eslint/triple-slash-reference": "error", "no-array-constructor": "error", - "no-unused-expressions": "error", - "no-unused-vars": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { "no-class-assign": "off", "no-const-assign": "off", "no-dupe-class-members": "off", "no-dupe-keys": "off", + "no-empty-function": "off", "no-func-assign": "off", "no-import-assign": "off", "no-new-native-nonconstructor": "off", @@ -499,6 +412,14 @@ exports[`puppeteer --js-plugins > puppeteer--js-plugins 1`] = ` "no-setter-return": "off", "no-this-before-super": "off", "no-unsafe-negation": "off", + "no-unused-expressions": "error", + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + }, + ], "no-with": "off", "prefer-rest-params": "error", "prefer-spread": "error", @@ -511,19 +432,14 @@ exports[`puppeteer --js-plugins > puppeteer--js-plugins 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/ban-tslint-comment": "error", - "@typescript-eslint/consistent-generic-constructors": "error", - "@typescript-eslint/consistent-indexed-object-style": "error", - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/no-confusing-non-null-assertion": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/prefer-function-type": "error", - "no-empty-function": "error", - }, + }, + { + "files": [ + "**/*.ts", + ], + "plugins": [ + "typescript", + ], }, { "files": [ @@ -535,36 +451,6 @@ exports[`puppeteer --js-plugins > puppeteer--js-plugins 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@puppeteer/use-using": "error", - "@typescript-eslint/array-type": [ - "error", - { - "default": "array-simple", - }, - ], - "@typescript-eslint/consistent-type-definitions": [ - "error", - "interface", - ], - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-import-type-side-effects": "error", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unsafe-function-type": "error", - "@typescript-eslint/no-wrapper-object-types": "error", - "@typescript-eslint/prefer-ts-expect-error": "error", - "no-empty-function": "off", - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - }, - ], - }, }, { "files": [ @@ -768,93 +654,74 @@ exports[`puppeteer --type-aware > puppeteer--type-aware 1`] = ` "packages/ng-schematics/src/**/files/", "examples/puppeteer-in-browser/out/**/*", "examples/puppeteer-in-browser/node_modules/**/*", - "examples/puppeteer-in-extension/out/**/*", - "examples/puppeteer-in-extension/node_modules/**/*", - ], - "overrides": [ - { - "files": [ - "**/*.ts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, + "examples/puppeteer-in-extension/out/**/*", + "examples/puppeteer-in-extension/node_modules/**/*", + ], + "overrides": [ { "files": [ "**/*.ts", ], - "plugins": [ - "typescript", - ], "rules": { + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/array-type": [ + "error", + { + "default": "array-simple", + }, + ], "@typescript-eslint/ban-ts-comment": "error", + "@typescript-eslint/ban-tslint-comment": "error", + "@typescript-eslint/consistent-generic-constructors": "error", + "@typescript-eslint/consistent-indexed-object-style": "error", + "@typescript-eslint/consistent-type-definitions": [ + "error", + "interface", + ], + "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", "@typescript-eslint/no-duplicate-enum-values": "error", "@typescript-eslint/no-empty-object-type": "error", - "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-extra-non-null-assertion": "error", + "@typescript-eslint/no-floating-promises": [ + "error", + { + "ignoreIIFE": true, + "ignoreVoid": true, + }, + ], + "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/no-inferrable-types": "error", "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-namespace": "error", "@typescript-eslint/no-non-null-asserted-optional-chain": "error", + "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-require-imports": "error", "@typescript-eslint/no-this-alias": "error", + "@typescript-eslint/no-unnecessary-template-expression": "error", "@typescript-eslint/no-unnecessary-type-constraint": "error", "@typescript-eslint/no-unsafe-declaration-merging": "error", "@typescript-eslint/no-unsafe-function-type": "error", "@typescript-eslint/no-wrapper-object-types": "error", "@typescript-eslint/prefer-as-const": "error", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/prefer-function-type": "error", "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/prefer-ts-expect-error": "error", + "@typescript-eslint/return-await": [ + "error", + "always", + ], "@typescript-eslint/triple-slash-reference": "error", "no-array-constructor": "error", - "no-unused-expressions": "error", - "no-unused-vars": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { "no-class-assign": "off", "no-const-assign": "off", "no-dupe-class-members": "off", "no-dupe-keys": "off", + "no-empty-function": "off", "no-func-assign": "off", "no-import-assign": "off", "no-new-native-nonconstructor": "off", @@ -863,6 +730,14 @@ exports[`puppeteer --type-aware > puppeteer--type-aware 1`] = ` "no-setter-return": "off", "no-this-before-super": "off", "no-unsafe-negation": "off", + "no-unused-expressions": "error", + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + }, + ], "no-with": "off", "prefer-rest-params": "error", "prefer-spread": "error", @@ -875,19 +750,6 @@ exports[`puppeteer --type-aware > puppeteer--type-aware 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/ban-tslint-comment": "error", - "@typescript-eslint/consistent-generic-constructors": "error", - "@typescript-eslint/consistent-indexed-object-style": "error", - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/no-confusing-non-null-assertion": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/prefer-function-type": "error", - "no-empty-function": "error", - }, }, { "files": [ @@ -896,47 +758,14 @@ exports[`puppeteer --type-aware > puppeteer--type-aware 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/array-type": [ - "error", - { - "default": "array-simple", - }, - ], - "@typescript-eslint/consistent-type-definitions": [ - "error", - "interface", - ], - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-floating-promises": [ - "error", - { - "ignoreIIFE": true, - "ignoreVoid": true, - }, - ], - "@typescript-eslint/no-import-type-side-effects": "error", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unnecessary-template-expression": "error", - "@typescript-eslint/no-unsafe-function-type": "error", - "@typescript-eslint/no-wrapper-object-types": "error", - "@typescript-eslint/prefer-ts-expect-error": "error", - "@typescript-eslint/return-await": [ - "error", - "always", - ], - "no-empty-function": "off", - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - }, - ], - }, + }, + { + "files": [ + "**/*.ts", + ], + "plugins": [ + "typescript", + ], }, { "files": [ @@ -1146,61 +975,35 @@ exports[`puppeteer merge > puppeteer--merge 1`] = ` "**/*.ts", ], "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "plugins": [ - "typescript", - ], - "rules": { + "@typescript-eslint/adjacent-overload-signatures": "error", + "@typescript-eslint/array-type": [ + "error", + { + "default": "array-simple", + }, + ], "@typescript-eslint/ban-ts-comment": "error", + "@typescript-eslint/ban-tslint-comment": "error", + "@typescript-eslint/consistent-generic-constructors": "error", + "@typescript-eslint/consistent-indexed-object-style": "error", + "@typescript-eslint/consistent-type-definitions": [ + "error", + "interface", + ], + "@typescript-eslint/consistent-type-imports": "error", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "error", + "@typescript-eslint/no-confusing-non-null-assertion": "error", "@typescript-eslint/no-duplicate-enum-values": "error", "@typescript-eslint/no-empty-object-type": "error", - "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-extra-non-null-assertion": "error", + "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/no-inferrable-types": "error", "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-namespace": "error", "@typescript-eslint/no-non-null-asserted-optional-chain": "error", + "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-require-imports": "error", "@typescript-eslint/no-this-alias": "error", "@typescript-eslint/no-unnecessary-type-constraint": "error", @@ -1208,22 +1011,17 @@ exports[`puppeteer merge > puppeteer--merge 1`] = ` "@typescript-eslint/no-unsafe-function-type": "error", "@typescript-eslint/no-wrapper-object-types": "error", "@typescript-eslint/prefer-as-const": "error", + "@typescript-eslint/prefer-for-of": "error", + "@typescript-eslint/prefer-function-type": "error", "@typescript-eslint/prefer-namespace-keyword": "error", + "@typescript-eslint/prefer-ts-expect-error": "error", "@typescript-eslint/triple-slash-reference": "error", "no-array-constructor": "error", - "no-unused-expressions": "error", - "no-unused-vars": "error", - }, - }, - { - "files": [ - "**/*.ts", - ], - "rules": { "no-class-assign": "off", "no-const-assign": "off", "no-dupe-class-members": "off", "no-dupe-keys": "off", + "no-empty-function": "off", "no-func-assign": "off", "no-import-assign": "off", "no-new-native-nonconstructor": "off", @@ -1232,6 +1030,14 @@ exports[`puppeteer merge > puppeteer--merge 1`] = ` "no-setter-return": "off", "no-this-before-super": "off", "no-unsafe-negation": "off", + "no-unused-expressions": "error", + "no-unused-vars": [ + "error", + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_", + }, + ], "no-with": "off", "prefer-rest-params": "error", "prefer-spread": "error", @@ -1244,19 +1050,6 @@ exports[`puppeteer merge > puppeteer--merge 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/adjacent-overload-signatures": "error", - "@typescript-eslint/array-type": "error", - "@typescript-eslint/ban-tslint-comment": "error", - "@typescript-eslint/consistent-generic-constructors": "error", - "@typescript-eslint/consistent-indexed-object-style": "error", - "@typescript-eslint/consistent-type-definitions": "error", - "@typescript-eslint/no-confusing-non-null-assertion": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/prefer-for-of": "error", - "@typescript-eslint/prefer-function-type": "error", - "no-empty-function": "error", - }, }, { "files": [ @@ -1265,35 +1058,14 @@ exports[`puppeteer merge > puppeteer--merge 1`] = ` "plugins": [ "typescript", ], - "rules": { - "@typescript-eslint/array-type": [ - "error", - { - "default": "array-simple", - }, - ], - "@typescript-eslint/consistent-type-definitions": [ - "error", - "interface", - ], - "@typescript-eslint/consistent-type-imports": "error", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/explicit-module-boundary-types": "error", - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-import-type-side-effects": "error", - "@typescript-eslint/no-non-null-assertion": "off", - "@typescript-eslint/no-unsafe-function-type": "error", - "@typescript-eslint/no-wrapper-object-types": "error", - "@typescript-eslint/prefer-ts-expect-error": "error", - "no-empty-function": "off", - "no-unused-vars": [ - "error", - { - "argsIgnorePattern": "^_", - "varsIgnorePattern": "^_", - }, - ], - }, + }, + { + "files": [ + "**/*.ts", + ], + "plugins": [ + "typescript", + ], }, { "files": [ diff --git a/integration_test/__snapshots__/typescript.spec.ts.snap b/integration_test/__snapshots__/typescript.spec.ts.snap index efa429ac..bed684bd 100644 --- a/integration_test/__snapshots__/typescript.spec.ts.snap +++ b/integration_test/__snapshots__/typescript.spec.ts.snap @@ -50,31 +50,6 @@ exports[`typescript > typescript 1`] = ` "prefer-spread": "error", }, }, - { - "files": [ - "**/*.ts", - "**/*.tsx", - "**/*.mts", - "**/*.cts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, { "files": [ "**/*.mjs", @@ -445,31 +420,6 @@ exports[`typescript --js-plugins > typescript--js-plugins 1`] = ` "prefer-spread": "error", }, }, - { - "files": [ - "**/*.ts", - "**/*.tsx", - "**/*.mts", - "**/*.cts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, { "files": [ "**/*.mjs", @@ -837,31 +787,6 @@ exports[`typescript --type-aware > typescript--type-aware 1`] = ` "prefer-spread": "error", }, }, - { - "files": [ - "**/*.ts", - "**/*.tsx", - "**/*.mts", - "**/*.cts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, { "files": [ "**/*.mjs", @@ -956,12 +881,15 @@ exports[`typescript --type-aware > typescript--type-aware 1`] = ` "@typescript-eslint/no-unsafe-assignment": "off", "@typescript-eslint/no-unsafe-call": "off", "@typescript-eslint/no-unsafe-enum-comparison": "off", + "@typescript-eslint/no-unsafe-function-type": "off", "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/no-unsafe-return": "off", "@typescript-eslint/no-unsafe-type-assertion": "off", "@typescript-eslint/no-unsafe-unary-minus": "off", + "@typescript-eslint/no-wrapper-object-types": "off", "@typescript-eslint/non-nullable-type-assertion-style": "off", "@typescript-eslint/only-throw-error": "off", + "@typescript-eslint/prefer-function-type": "off", "@typescript-eslint/prefer-includes": "off", "@typescript-eslint/prefer-promise-reject-errors": "off", "@typescript-eslint/prefer-reduce-type-parameter": "off", @@ -977,16 +905,6 @@ exports[`typescript --type-aware > typescript--type-aware 1`] = ` "@typescript-eslint/switch-exhaustiveness-check": "off", "@typescript-eslint/unbound-method": "off", "@typescript-eslint/use-unknown-in-catch-callback-variable": "off", - }, - }, - { - "files": [ - "src/lib/*.d.ts", - ], - "rules": { - "@typescript-eslint/no-unsafe-function-type": "off", - "@typescript-eslint/no-wrapper-object-types": "off", - "@typescript-eslint/prefer-function-type": "off", "no-restricted-globals": "off", "no-shadow-restricted-names": "off", "no-unused-vars": "off", @@ -1238,31 +1156,6 @@ exports[`typescript merge > typescript--merge 1`] = ` "prefer-spread": "error", }, }, - { - "files": [ - "**/*.ts", - "**/*.tsx", - "**/*.mts", - "**/*.cts", - ], - "rules": { - "no-class-assign": "off", - "no-const-assign": "off", - "no-dupe-class-members": "off", - "no-dupe-keys": "off", - "no-func-assign": "off", - "no-import-assign": "off", - "no-new-native-nonconstructor": "off", - "no-obj-calls": "off", - "no-redeclare": "off", - "no-setter-return": "off", - "no-this-before-super": "off", - "no-unsafe-negation": "off", - "no-with": "off", - "prefer-rest-params": "error", - "prefer-spread": "error", - }, - }, { "files": [ "**/*.mjs", diff --git a/src/cleanup.ts b/src/cleanup.ts index 443cb9d2..e3333489 100644 --- a/src/cleanup.ts +++ b/src/cleanup.ts @@ -73,7 +73,7 @@ const cleanUpUselessOverridesEntries = (config: OxlintConfig): void => { } for (const [overrideIndex, override] of config.overrides.entries()) { - // the only key left is + // If there's only one key left, it can be deleted. An override needs files+plugins or files+rules to make sense. if (Object.keys(override).length === 1) { delete config.overrides[overrideIndex]; } diff --git a/src/plugin_rules.spec.ts b/src/plugin_rules.spec.ts index 9257ca32..a32810b2 100644 --- a/src/plugin_rules.spec.ts +++ b/src/plugin_rules.spec.ts @@ -147,6 +147,49 @@ describe('rules and plugins', () => { }); }); + test('cleanUpUselessOverridesRules with multiple overrides for same files (last-wins)', () => { + const config: OxlintConfig = { + rules: { + 'react/react-in-jsx-scope': 'off', + }, + overrides: [ + { + files: ['**/*.ts', '**/*.tsx'], + rules: { + 'react/foobar': 'error', + 'react/react-in-jsx-scope': 'error', + }, + }, + { + files: ['**/*.ts', '**/*.tsx'], + rules: { + 'react/react-in-jsx-scope': 'off', + }, + }, + ], + }; + + cleanUpUselessOverridesRules(config); + + // The final rule wins over the first, so react-in-jsx-scope should end up as "off". + expect(config).toStrictEqual({ + rules: { + 'react/react-in-jsx-scope': 'off', + }, + overrides: [ + { + files: ['**/*.ts', '**/*.tsx'], + rules: { + 'react/foobar': 'error', + }, + }, + { + files: ['**/*.ts', '**/*.tsx'], + }, + ], + }); + }); + test('cleanUpRulesWhichAreCoveredByCategory', () => { const config: OxlintConfig = { categories: { diff --git a/src/plugins_rules.ts b/src/plugins_rules.ts index 2e3dad94..dc2cc4b0 100644 --- a/src/plugins_rules.ts +++ b/src/plugins_rules.ts @@ -179,25 +179,72 @@ export const cleanUpUselessOverridesPlugins = (config: OxlintConfig): void => { } } }; + export const cleanUpUselessOverridesRules = (config: OxlintConfig): void => { if (config.rules === undefined || config.overrides === undefined) { return; } - for (const override of config.overrides) { - if (override.rules === undefined) { + // Build a map of files pattern -> {firstOverrideIndex, finalMergedRules} + const filesPatternMap = new Map< + string, + { + firstIndex: number; + finalRules: Record; + indicesToRemove: number[]; + } + >(); + + // First pass: merge all overrides with same files pattern + for (const [i, override] of config.overrides.entries()) { + if (override.files === undefined) { continue; } - for (const [rule, settings] of Object.entries(override.rules)) { - // when they are the same, delete inside override - if (config.rules[rule] === settings) { - delete override.rules[rule]; + const filesKey = JSON.stringify(override.files); + let entry = filesPatternMap.get(filesKey); + + if (!entry) { + entry = { + firstIndex: i, + finalRules: {}, + indicesToRemove: [], + }; + filesPatternMap.set(filesKey, entry); + } else { + // Mark this duplicate for removal + entry.indicesToRemove.push(i); + } + + // Merge rules with last-wins semantics + if (override.rules) { + Object.assign(entry.finalRules, override.rules); + } + } + + // Second pass: update first occurrence with merged rules and mark duplicates for deletion + for (const entry of filesPatternMap.values()) { + const firstOverride = config.overrides[entry.firstIndex]; + + // Update the first override with the final merged rules + firstOverride.rules = entry.finalRules; + + // Remove rules that match root config + if (firstOverride.rules) { + for (const [rule, settings] of Object.entries(firstOverride.rules)) { + if (config.rules[rule] === settings) { + delete firstOverride.rules[rule]; + } + } + + if (Object.keys(firstOverride.rules).length === 0) { + delete firstOverride.rules; } } - if (Object.keys(override.rules).length === 0) { - delete override.rules; + // Mark duplicate overrides for removal by clearing their rules + for (const indexToRemove of entry.indicesToRemove) { + delete config.overrides[indexToRemove].rules; } } };