diff --git a/packages/typescript/index.js b/packages/typescript/index.js index 4140783702..29f15e9090 100644 --- a/packages/typescript/index.js +++ b/packages/typescript/index.js @@ -51,6 +51,15 @@ module.exports = { '@typescript-eslint/restrict-template-expressions': 'error', '@typescript-eslint/unbound-method': 'error', }, + }, { + // https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md + files: ['**/__tests__/**/*.ts', '**/*.spec.ts', '**/*.test.ts'], + plugins: ['jest'], + rules: { + // you should turn the original rule off *only* for test files + '@typescript-eslint/unbound-method': 'off', + 'jest/unbound-method': 'error', + }, }], ), rules: { diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 284f9204ea..16759b4abb 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -19,7 +19,8 @@ "dependencies": { "@antfu/eslint-config-basic": "workspace:*", "@typescript-eslint/eslint-plugin": "^5.46.0", - "@typescript-eslint/parser": "^5.46.0" + "@typescript-eslint/parser": "^5.46.0", + "eslint-plugin-jest": "^27.1.6" }, "devDependencies": { "eslint": "^8.29.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16b4ededac..05b16db9bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -122,10 +122,12 @@ importers: '@typescript-eslint/eslint-plugin': ^5.46.0 '@typescript-eslint/parser': ^5.46.0 eslint: ^8.29.0 + eslint-plugin-jest: ^27.1.6 dependencies: '@antfu/eslint-config-basic': link:../basic '@typescript-eslint/eslint-plugin': 5.46.0_jx43xxcguvnqqmtmaaygwl7cmu '@typescript-eslint/parser': 5.46.0_eslint@8.29.0 + eslint-plugin-jest: 27.1.6_az5lmaeuvswqhyu3aute3pgqim devDependencies: eslint: 8.29.0 @@ -1849,6 +1851,27 @@ packages: - supports-color dev: false + /eslint-plugin-jest/27.1.6_az5lmaeuvswqhyu3aute3pgqim: + resolution: {integrity: sha512-XA7RFLSrlQF9IGtAmhddkUkBuICCTuryfOTfCSWcZHiHb69OilIH05oozH2XA6CEOtztnOd0vgXyvxZodkxGjg==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + peerDependencies: + '@typescript-eslint/eslint-plugin': ^5.0.0 + eslint: ^7.0.0 || ^8.0.0 + jest: '*' + peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true + jest: + optional: true + dependencies: + '@typescript-eslint/eslint-plugin': 5.46.0_jx43xxcguvnqqmtmaaygwl7cmu + '@typescript-eslint/utils': 5.46.0_eslint@8.29.0 + eslint: 8.29.0 + transitivePeerDependencies: + - supports-color + - typescript + dev: false + /eslint-plugin-jsonc/2.5.0_eslint@8.29.0: resolution: {integrity: sha512-G257khwkrOQ5MJpSzz4yQh5K12W4xFZRcHmVlhVFWh2GCLDX+JwHnmkQoUoFDbOieSPBMsPFZDTJScwrXiWlIg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}