Skip to content

Commit

Permalink
feat(eslint-config): enable @typescript-eslint/unbound-method
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Sep 23, 2023
1 parent 22b78b8 commit 2bda39a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-hornets-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@git-validator/eslint-config": patch
---

feat(eslint-config): enable `@typescript-eslint/unbound-method`
1 change: 1 addition & 0 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-config/src/base.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -34,6 +35,7 @@ export default [
"@git-validator": gitValidatorPlugin,
"@typescript-eslint": tsPlugin,
"react-hooks": reactHooksPlugin,
jest: jestPlugin,
},
},
];
2 changes: 1 addition & 1 deletion packages/eslint-config/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
2 changes: 1 addition & 1 deletion packages/eslint-config/src/js-config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
91 changes: 50 additions & 41 deletions packages/eslint-config/src/ts-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
};
];

0 comments on commit 2bda39a

Please sign in to comment.