Skip to content

Commit

Permalink
fix: don't include deprecated rules in all config (#664)
Browse files Browse the repository at this point in the history
Resolves #663
  • Loading branch information
G-Rath authored Sep 12, 2020
1 parent d16b84c commit f636021
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
4 changes: 0 additions & 4 deletions src/__tests__/__snapshots__/rules.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/rules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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))
Expand Down
12 changes: 9 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ const recommendedRules = Object.entries(rules)
{},
);

const allRules = Object.keys(rules).reduce<
Record<string, TSESLint.Linter.RuleLevel>
>((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<string, TSESLint.Linter.RuleLevel>) => ({
plugins: ['jest'],
Expand Down

0 comments on commit f636021

Please sign in to comment.