diff --git a/.changeset/metal-hornets-jam.md b/.changeset/metal-hornets-jam.md new file mode 100644 index 00000000..d5e2cbf9 --- /dev/null +++ b/.changeset/metal-hornets-jam.md @@ -0,0 +1,5 @@ +--- +"@git-validator/eslint-config": patch +--- + +feat(eslint-config): enable `@typescript-eslint/unbound-method` diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 369ca0e3..f938b61f 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -24,6 +24,7 @@ "@typescript-eslint/parser": "^6.7.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-import": "^2.28.1", + "eslint-plugin-jest": "^27.4.0", "eslint-plugin-n": "^16.1.0", "eslint-plugin-promise": "^6.1.1", "eslint-plugin-react-hooks": "^4.6.0", diff --git a/packages/eslint-config/src/base.js b/packages/eslint-config/src/base.js index 5fd8f6d2..0b7fb6e7 100644 --- a/packages/eslint-config/src/base.js +++ b/packages/eslint-config/src/base.js @@ -1,6 +1,7 @@ import gitValidatorPlugin from "@git-validator/eslint-plugin"; import tsPlugin from "@typescript-eslint/eslint-plugin"; import importPlugin from "eslint-plugin-import"; +import jestPlugin from "eslint-plugin-jest"; import nPlugin from "eslint-plugin-n"; import promisePlugin from "eslint-plugin-promise"; import reactHooksPlugin from "eslint-plugin-react-hooks"; @@ -34,6 +35,7 @@ export default [ "@git-validator": gitValidatorPlugin, "@typescript-eslint": tsPlugin, "react-hooks": reactHooksPlugin, + jest: jestPlugin, }, }, ]; diff --git a/packages/eslint-config/src/index.js b/packages/eslint-config/src/index.js index c7b18260..d1cead09 100644 --- a/packages/eslint-config/src/index.js +++ b/packages/eslint-config/src/index.js @@ -3,4 +3,4 @@ import base from "./base.js"; import jsConfig from "./js-config/index.js"; import tsConfig from "./ts-config.js"; -export default [...base, jsConfig, tsConfig, prettierConfig]; +export default [...base, jsConfig, ...tsConfig, prettierConfig]; diff --git a/packages/eslint-config/src/js-config/index.js b/packages/eslint-config/src/js-config/index.js index 749eb9de..28654a37 100644 --- a/packages/eslint-config/src/js-config/index.js +++ b/packages/eslint-config/src/js-config/index.js @@ -33,7 +33,7 @@ export default { ], "import/no-self-import": "error", "import/no-dynamic-require": "error", - "import/no-relative-packages": "error", + "import/no-relative-packages": "error", // forbid to import module from other monorepo packages by relative paths "import/no-mutable-exports": "error", // forbid code like `export let count = 3` // "import/no-named-as-default-member": "error", // forbid code like `import foo from './foo.js'; const bar = foo.bar;` "n/prefer-global/process": ["error", "never"], diff --git a/packages/eslint-config/src/ts-config.js b/packages/eslint-config/src/ts-config.js index 54fbea6c..a001597c 100644 --- a/packages/eslint-config/src/ts-config.js +++ b/packages/eslint-config/src/ts-config.js @@ -99,49 +99,58 @@ function getStrictRules() { return {}; } -export default { - files: ["**/*.ts", "**/*.cts", "**/*.mts", "**/*.tsx"], - languageOptions: { - parser: tsParser, - parserOptions: { - tsconfigRootDir: process.cwd(), - project: tsconfig, +export default [ + { + files: ["**/*.ts", "**/*.cts", "**/*.mts", "**/*.tsx"], + languageOptions: { + parser: tsParser, + parserOptions: { + tsconfigRootDir: process.cwd(), + project: tsconfig, + }, }, - }, - rules: { - ...jsConfig.rules, - ...getTsRules(), - "no-undef": "off", // https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + rules: { + ...jsConfig.rules, + ...getTsRules(), + "no-undef": "off", // https://typescript-eslint.io/linting/troubleshooting/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors - // ban some syntaxes to reduce mistakes - "@typescript-eslint/ban-types": "error", - "@typescript-eslint/consistent-type-assertions": [ - "error", - { assertionStyle: "as", objectLiteralTypeAssertions: "never" }, - ], - "@typescript-eslint/method-signature-style": "error", - "@typescript-eslint/no-duplicate-enum-values": "error", - "@typescript-eslint/no-duplicate-type-constituents": "error", - "@typescript-eslint/no-inferrable-types": "error", - "@typescript-eslint/no-require-imports": "error", - "@typescript-eslint/no-namespace": "error", - "@typescript-eslint/no-misused-new": "error", - "@typescript-eslint/no-mixed-enums": "error", - "@typescript-eslint/no-import-type-side-effects": "error", - "@typescript-eslint/no-floating-promises": ["error", { ignoreVoid: false }], - "@typescript-eslint/no-misused-promises": [ - "error", - { checksVoidReturn: { returns: false, arguments: false, variables: false } }, - ], - "@typescript-eslint/await-thenable": "error", - "@typescript-eslint/no-unnecessary-type-assertion": "error", - "@typescript-eslint/no-unnecessary-condition": "error", - // "@typescript-eslint/unbound-method": "error", + // ban some syntaxes to reduce mistakes + "@typescript-eslint/ban-types": "error", + "@typescript-eslint/consistent-type-assertions": [ + "error", + { assertionStyle: "as", objectLiteralTypeAssertions: "never" }, + ], + "@typescript-eslint/method-signature-style": "error", + "@typescript-eslint/no-duplicate-enum-values": "error", + "@typescript-eslint/no-duplicate-type-constituents": "error", + "@typescript-eslint/no-inferrable-types": "error", + "@typescript-eslint/no-require-imports": "error", + "@typescript-eslint/no-namespace": "error", + "@typescript-eslint/no-misused-new": "error", + "@typescript-eslint/no-mixed-enums": "error", + "@typescript-eslint/no-import-type-side-effects": "error", + "@typescript-eslint/no-floating-promises": ["error", { ignoreVoid: false }], + "@typescript-eslint/no-misused-promises": [ + "error", + { checksVoidReturn: { returns: false, arguments: false, variables: false } }, + ], + "@typescript-eslint/await-thenable": "error", + "@typescript-eslint/no-unnecessary-type-assertion": "error", + "@typescript-eslint/no-unnecessary-condition": "error", + "@typescript-eslint/unbound-method": "error", - "@git-validator/no-const-enum": "error", - "@git-validator/no-declares-in-ts-file": "error", - "@git-validator/no-export-assignment": "error", + "@git-validator/no-const-enum": "error", + "@git-validator/no-declares-in-ts-file": "error", + "@git-validator/no-export-assignment": "error", - ...getStrictRules(), + ...getStrictRules(), + }, + }, + { + files: ["**/*.{test,spec}.?([cm])ts", "**/*.{test,spec}.tsx"], + rules: { + "@typescript-eslint/unbound-method": "off", + "jest/unbound-method": "error", + }, }, -}; +];