-
-
Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathindex.js
69 lines (59 loc) · 1.59 KB
/
index.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import createDeprecatedRules from './rules/utils/create-deprecated-rules.js';
import flatConfigBase from './configs/flat-config-base.js';
import rules from './rules/index.js';
import packageJson from './package.json' with {type: 'json'};
const deprecatedRules = createDeprecatedRules({
// {ruleId: ReplacementRuleId | ReplacementRuleId[]}, if no replacement, use `{ruleId: []}`
'no-instanceof-array': 'unicorn/no-instanceof-builtins',
});
const externalRules = {
// Covered by `unicorn/no-negated-condition`
'no-negated-condition': 'off',
// Covered by `unicorn/no-nested-ternary`
'no-nested-ternary': 'off',
};
const recommendedRules = Object.fromEntries(
Object.entries(rules).map(([id, rule]) => [
`unicorn/${id}`,
rule.meta.docs.recommended ? 'error' : 'off',
]),
);
const allRules = Object.fromEntries(
Object.keys(rules).map(id => [
`unicorn/${id}`,
'error',
]),
);
const createConfig = (rules, flatConfigName) => ({
...flatConfigBase,
name: flatConfigName,
plugins: {
unicorn,
},
rules: {
...externalRules,
...rules,
},
});
const unicorn = {
meta: {
name: packageJson.name,
version: packageJson.version,
},
rules: {
...rules,
...deprecatedRules,
},
};
const configs = {
recommended: createConfig(recommendedRules, 'unicorn/recommended'),
all: createConfig(allRules, 'unicorn/all'),
// TODO: Remove this at some point. Kept for now to avoid breaking users.
'flat/recommended': createConfig(recommendedRules, 'unicorn/flat/recommended'),
'flat/all': createConfig(allRules, 'unicorn/flat/all'),
};
const allConfigs = {
...unicorn,
configs,
};
export default allConfigs;