-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (46 loc) · 1.33 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
// based on eslint-plugin-react/index.js
'use strict';
const fromEntries = require('object.fromentries');
const entries = require('object.entries');
// TODO glob lib/rules/*.js
const allRulesList = [
// FIXME regression React.useMemo React.useRef
'react-use-state-to-solid-create-signal',
'react-use-effect-to-solid-create-effect',
'react-use-memo-to-solid-create-memo',
'react-import-remove',
'jsx-classname-to-class',
'react-types-to-solid-types',
'react-use-ref-to-solid-let',
'react-forward-ref-to-solid',
];
const allRules = {};
for (const name of allRulesList) {
allRules[name] = require(`./lib/rules/${name}.js`)
}
function filterRules(rules, predicate) {
return fromEntries(entries(rules).filter((entry) => predicate(entry[1])));
}
function configureAsError(rules) {
return fromEntries(Object.keys(rules).map((key) => [`react2solid/${key}`, 2]));
}
const activeRules = filterRules(allRules, (rule) => !rule.meta.deprecated);
const activeRulesConfig = configureAsError(activeRules);
const deprecatedRules = filterRules(allRules, (rule) => rule.meta.deprecated);
module.exports = {
deprecatedRules,
rules: allRules,
configs: {
all: {
plugins: [
'react2solid',
],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
rules: activeRulesConfig,
},
},
};