forked from you-dont-need/You-Dont-Need-Lodash-Underscore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (42 loc) · 1.13 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
'use strict';
const kebabCase = require('kebab-case');
const rules = require('./lib/rules/rules.json')
module.exports.rules = require('./lib/rules/all');
const all = Object.keys(rules);
const compatible = Object.keys(rules).filter(rule => rules[rule].compatible);
const incompatible = Object.keys(rules).filter(rule => !rules[rule].compatible);
const WARN = 1;
const ERROR = 2;
const configure = (list, level) => (
list.reduce((ret, rule) => (Object.assign({}, ret,
{ ['you-dont-need-lodash-underscore/' + (rules[rule].ruleName || kebabCase(rule))]: level })), {})
)
module.exports.configs = {
'all-warn': {
plugins: [
'you-dont-need-lodash-underscore'
],
rules: configure(all, WARN)
},
'all': {
plugins: [
'you-dont-need-lodash-underscore'
],
rules: configure(all, ERROR)
},
'compatible-warn': {
plugins: [
'you-dont-need-lodash-underscore'
],
rules: configure(compatible, WARN)
},
'compatible': {
plugins: [
'you-dont-need-lodash-underscore'
],
rules: Object.assign(
configure(compatible, ERROR),
configure(incompatible, WARN)
)
}
}