Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't include deprecated rules in all config #664

Merged
merged 1 commit into from Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/__tests__/__snapshots__/rules.test.ts.snap
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
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
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