-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
50 lines (45 loc) · 1.18 KB
/
options.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
var R = require('ramda')
var path = require('path')
var eslint = require('eslint')
var pkg = require('./package.json')
var getRules = R.prop('rules')
var isObject = R.pipe(R.type, R.equals('Object'))
var isRulesObject = R.propSatisfies(isObject, 'rules')
var buildRules = R.ifElse(isRulesObject, getRules, R.always({}))
var getFix = R.propOr(true, 'fix')
var getRulesets = R.propOr('', 'use')
var addBaseRuleset = R.concat(['supermind'])
var prefixRulesets = R.map(R.concat('supermind/'))
var allowRulesets = R.intersection([
'flowtype',
'jsx-a11y',
'inferno',
'react'
])
var buildRulesets = R.compose(
addBaseRuleset,
prefixRulesets,
allowRulesets,
getRulesets
)
var buildConfig = function(config) {
return {
root: true,
extends: buildRulesets(config),
rules: buildRules(config)
}
}
module.exports = {
version: pkg.version,
homepage: pkg.homepage,
bugs: pkg.bugs.url,
eslint: eslint,
cmd: 'superlint',
tagline: 'Supermind linting standards',
parseOpts: function(options, config) {
var eslintConfig = options.eslintConfig = {}
eslintConfig.fix = options.fix = getFix(config)
eslintConfig.baseConfig = buildConfig(config)
return options
}
}