From ad56eed9aedeb6520c0ba703e930c94dc54b2e90 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:15:58 +0000 Subject: [PATCH 1/3] chore(deps): update dependency eslint-plugin-jest to v27 --- package-lock.json | 70 +++++++++++++++++++++++------------------------ package.json | 4 +-- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 40a000c..37a55b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -29,7 +29,7 @@ "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-flowtype": "^8.0.2", "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-jest": "^27.0.0", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-node": "^11.1.0", @@ -55,7 +55,7 @@ "eslint-plugin-eslint-comments": ">= 3", "eslint-plugin-flowtype": "^8.0.0", "eslint-plugin-import": ">= 2.21", - "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-jest": "^27.0.0", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-jsx-a11y": "^6.0.0", "eslint-plugin-node": ">= 2.21", @@ -3569,20 +3569,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -4425,19 +4411,19 @@ "dev": true }, "node_modules/eslint-plugin-jest": { - "version": "26.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.9.0.tgz", - "integrity": "sha512-TWJxWGp1J628gxh2KhaH1H1paEdgE2J61BBF1I59c6xWeL5+D1BzMxGDN/nXAfX+aSkR5u80K+XhskK6Gwq9ng==", + "version": "27.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.1.1.tgz", + "integrity": "sha512-vuSuXGKHHi/UAffIM46QKm4g0tQP+6n52nRxUpMq6x6x9rhnv5WM7ktSu3h9cTnXE4b0Y0ODQTgRlCm9rdRLvg==", "dev": true, "dependencies": { "@typescript-eslint/utils": "^5.10.0" }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" }, "peerDependencies": { "@typescript-eslint/eslint-plugin": "^5.0.0", - "eslint": "^6.0.0 || ^7.0.0 || ^8.0.0" + "eslint": "^7.0.0 || ^8.0.0" }, "peerDependenciesMeta": { "@typescript-eslint/eslint-plugin": { @@ -13612,6 +13598,20 @@ "node": ">=10" } }, + "node_modules/yargs/node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/yargs/node_modules/yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", @@ -16262,17 +16262,6 @@ "string-width": "^4.2.0" } }, - "cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - } - }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -17011,9 +17000,9 @@ } }, "eslint-plugin-jest": { - "version": "26.9.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-26.9.0.tgz", - "integrity": "sha512-TWJxWGp1J628gxh2KhaH1H1paEdgE2J61BBF1I59c6xWeL5+D1BzMxGDN/nXAfX+aSkR5u80K+XhskK6Gwq9ng==", + "version": "27.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-27.1.1.tgz", + "integrity": "sha512-vuSuXGKHHi/UAffIM46QKm4g0tQP+6n52nRxUpMq6x6x9rhnv5WM7ktSu3h9cTnXE4b0Y0ODQTgRlCm9rdRLvg==", "dev": true, "requires": { "@typescript-eslint/utils": "^5.10.0" @@ -23555,6 +23544,17 @@ "yargs-parser": "^21.0.0" }, "dependencies": { + "cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + } + }, "yargs-parser": { "version": "21.1.1", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", diff --git a/package.json b/package.json index 61b98bc..9365b93 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-flowtype": "^8.0.2", "eslint-plugin-import": "^2.22.1", - "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-jest": "^27.0.0", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-jsx-a11y": "^6.3.1", "eslint-plugin-node": "^11.1.0", @@ -97,7 +97,7 @@ "eslint-plugin-eslint-comments": ">= 3", "eslint-plugin-flowtype": "^8.0.0", "eslint-plugin-import": ">= 2.21", - "eslint-plugin-jest": "^26.0.0", + "eslint-plugin-jest": "^27.0.0", "eslint-plugin-jest-formatting": "^3.0.0", "eslint-plugin-jsx-a11y": "^6.0.0", "eslint-plugin-node": ">= 2.21", From 35788e1797137f01a222c3802413605d63a033ee Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 15 Oct 2022 11:30:08 +1300 Subject: [PATCH 2/3] test: default to using `@typescript-eslint/parser` for rules that optionally support type services --- test/configs.spec.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/configs.spec.ts b/test/configs.spec.ts index da129b7..f2dddc7 100644 --- a/test/configs.spec.ts +++ b/test/configs.spec.ts @@ -121,6 +121,9 @@ describe('for each config file', () => { expect.hasAssertions(); const baseConfig: ESLint.Linter.Config = { + // default to using the @typescript-eslint/parser in case we have any + // rules that can use the type services, like `jest/unbound-method` + parser: '@typescript-eslint/parser', ...config, parserOptions: { // @babel/eslint-parser From d89cbce81df861fbcc69a9c92b6f9cefd4c8c13e Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sat, 15 Oct 2022 11:55:22 +1300 Subject: [PATCH 3/3] fix: update config of `jest/no-restricted-matchers` to continue banning all variations of matchers --- jest.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/jest.js b/jest.js index 295acb2..9b8b15a 100644 --- a/jest.js +++ b/jest.js @@ -1,3 +1,23 @@ +/** + * Generates a config for `jest/no-restricted-matchers` that bans all variations + * of the given base matchers + * + * @param {Record} matchers + * + * @return {Record} + */ +const banMatchers = matchers => { + return Object.fromEntries( + Object.entries(matchers).flatMap(([matcher, message]) => [ + [matcher, message], + [`resolves.${matcher}`, message], + [`resolves.not.${matcher}`, message], + [`rejects.not.${matcher}`, message], + [`not.${matcher}`, message] + ]) + ); +}; + /** @type {import('eslint').Linter.Config} */ const config = { plugins: ['jest', 'jest-formatting'], @@ -20,13 +40,13 @@ const config = { 'jest/no-large-snapshots': 'warn', 'jest/no-restricted-matchers': [ 'error', - { + banMatchers({ toThrowErrorMatchingSnapshot: 'Use `toThrowErrorMatchingInlineSnapshot()` instead', toMatchSnapshot: 'Use `toMatchInlineSnapshot()` instead', toBeTruthy: 'Avoid `toBeTruthy`', toBeFalsy: 'Avoid `toBeFalsy`' - } + }) ], 'jest/no-test-return-statement': 'error', 'jest/prefer-called-with': 'error',