-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
configs.js
72 lines (63 loc) · 1.5 KB
/
configs.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
70
71
72
const { hasAnyDep } = require('./lib/utils')
const isModuleAvailable = require('./lib/is-module-available')
// Base rules
const rules = [
// 'array-func',
'const-case',
'eslint-comments',
'html',
'json',
// 'json-format',
'markdown',
'no-constructor-bind',
'no-use-extend-native',
'optimize-regex',
'promise',
'simple-import-sort',
'sonarjs',
'switch-case',
'unicorn',
// Security Rules
'no-secrets',
'no-unsanitized',
'pii',
'security',
'xss',
]
// Optionals rules besed on project dependencies
const depRules = [
['redux', 'fsa'],
'lodash',
['lodash', 'lodash-fp'],
'ramda',
'react-redux',
'redux-saga',
]
const testRules = [
'ava',
['chai', 'chai-expect'],
['chai', 'chai-friendly'],
'cypress',
'jasmine',
'jest',
['jest', 'jest-async'],
'jest-dom',
['@testing-library/jest-dom', 'jest-dom'],
'mocha',
['mocha', 'mocha-cleanup'],
'qunit',
['grunt-contrib-qunit', 'qunit'],
['@testing-library/dom', 'testing-library'],
]
depRules.forEach((depRule) => {
const rule = typeof depRule === 'string' ? [depRule, depRule] : depRule
if (hasAnyDep(rule[0])) rules.push(rule[1])
})
testRules.forEach((depRule) => {
const rule = typeof depRule === 'string' ? [depRule, depRule] : depRule
if (isModuleAvailable(rule[0])) rules.push(rule[1])
})
if (hasAnyDep('prettier')) rules.push('prettier')
// Extra required optional packages
const extraInstallPackage = [['prettier', 'eslint-config-prettier']]
module.exports = { rules, extraInstallPackage }