From f636021c16215a713845c699858a2978211df49d Mon Sep 17 00:00:00 2001 From: Gareth Jones Date: Sun, 13 Sep 2020 11:22:10 +1200 Subject: [PATCH] fix: don't include deprecated rules in `all` config (#664) Resolves #663 --- src/__tests__/__snapshots__/rules.test.ts.snap | 4 ---- src/__tests__/rules.test.ts | 7 +++++-- src/index.ts | 12 +++++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/__tests__/__snapshots__/rules.test.ts.snap b/src/__tests__/__snapshots__/rules.test.ts.snap index 887ab1c99..3d7972b03 100644 --- a/src/__tests__/__snapshots__/rules.test.ts.snap +++ b/src/__tests__/__snapshots__/rules.test.ts.snap @@ -20,7 +20,6 @@ Object { "jest/no-disabled-tests": "error", "jest/no-done-callback": "error", "jest/no-duplicate-hooks": "error", - "jest/no-expect-resolves": "error", "jest/no-export": "error", "jest/no-focused-tests": "error", "jest/no-hooks": "error", @@ -35,12 +34,9 @@ Object { "jest/no-standalone-expect": "error", "jest/no-test-prefixes": "error", "jest/no-test-return-statement": "error", - "jest/no-truthy-falsy": "error", - "jest/no-try-expect": "error", "jest/prefer-called-with": "error", "jest/prefer-expect-assertions": "error", "jest/prefer-hooks-on-top": "error", - "jest/prefer-inline-snapshots": "error", "jest/prefer-spy-on": "error", "jest/prefer-strict-equal": "error", "jest/prefer-to-be-null": "error", diff --git a/src/__tests__/rules.test.ts b/src/__tests__/rules.test.ts index 550353f1c..d37e1bd4a 100644 --- a/src/__tests__/rules.test.ts +++ b/src/__tests__/rules.test.ts @@ -2,8 +2,11 @@ import { existsSync } from 'fs'; import { resolve } from 'path'; import plugin from '../'; -const ruleNames = Object.keys(plugin.rules); const numberOfRules = 44; +const ruleNames = Object.keys(plugin.rules); +const deprecatedRules = Object.entries(plugin.rules) + .filter(([, rule]) => rule.meta.deprecated) + .map(([name]) => name); describe('rules', () => { it('should have a corresponding doc for each rule', () => { @@ -54,7 +57,7 @@ describe('rules', () => { 'style', ]); expect(Object.keys(recommendedConfigs.all.rules)).toHaveLength( - ruleNames.length, + ruleNames.length - deprecatedRules.length, ); const allConfigRules = Object.values(recommendedConfigs) .map(config => Object.keys(config.rules)) diff --git a/src/index.ts b/src/index.ts index 79923412b..1b9e77f35 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,9 +48,15 @@ const recommendedRules = Object.entries(rules) {}, ); -const allRules = Object.keys(rules).reduce< - Record ->((rules, key) => ({ ...rules, [`jest/${key}`]: 'error' }), {}); +const allRules = Object.entries(rules) + .filter(([, rule]) => !rule.meta.deprecated) + .reduce( + (acc, [name]) => ({ + ...acc, + [`jest/${name}`]: 'error', + }), + {}, + ); const createConfig = (rules: Record) => ({ plugins: ['jest'],