-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
all.test.ts
46 lines (40 loc) · 1.44 KB
/
all.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import rules from '../../src/rules';
import allConfig from '../../src/configs/all.json';
import { TSESLint } from '@typescript-eslint/experimental-utils';
interface IndexRules {
[name: string]: TSESLint.RuleModule<string, any, any>;
}
interface JsonRules {
[name: string]: string;
}
describe('all.json config', () => {
const RULE_NAME_PREFIX = '@typescript-eslint/';
const typedRules: IndexRules = rules;
const notDeprecatedRuleNames = Object.keys(typedRules).reduce<string[]>(
(collection, name) => {
if (!typedRules[name].meta.deprecated) {
collection.push(`${RULE_NAME_PREFIX}${name}`);
}
return collection;
},
[],
);
// with end of Node.js 6 support, we can use Object.entries(allConfig.rules) here
const configRules: JsonRules = allConfig.rules;
const typescriptEslintConfigRules = Object.keys(configRules).filter(name =>
name.startsWith(RULE_NAME_PREFIX),
);
const typescriptEslintConfigRuleValues = typescriptEslintConfigRules.map(
name => configRules[name],
);
it('contains all @typescript-eslint/eslint-plugin rule modules, except the deprecated ones', () => {
expect(notDeprecatedRuleNames).toEqual(
expect.arrayContaining(typescriptEslintConfigRules),
);
});
it('has all containing @typescript-eslint/eslint-plugin rules enabled with "error"', () => {
expect(['error']).toEqual(
expect.arrayContaining(typescriptEslintConfigRuleValues),
);
});
});