From 2ad3503022b0287c23e0db6dc09088556b28a454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=98=8E=E5=81=A5?= Date: Thu, 15 Dec 2022 17:04:50 +0800 Subject: [PATCH] feat(ts): enable `jest/unbound-method` (#141) --- packages/typescript/index.js | 9 +++++++++ packages/typescript/package.json | 3 ++- pnpm-lock.yaml | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/typescript/index.js b/packages/typescript/index.js index 4140783..29f15e9 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 284f920..16759b4 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 16b4ede..05b16db 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}