forked from cloud-gov/pages-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
62 lines (53 loc) · 1.69 KB
/
.eslintrc.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
const finalRules = {
/* airbnb config overrides */
'react/jsx-filename-extension': [0],
'import/no-extraneous-dependencies': [0],
'import/no-named-as-default': [0], // allow component to be the same as the default export
'class-methods-use-this': [0],
'no-throw-literal': [0],
'comma-dangle': ['error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],
};
const finalPlugins = [];
let scanjsRulesConfig = null;
try {
// eslint-disable-next-line global-require
const scanjsConfig = require('eslint-plugin-scanjs-rules');
scanjsRulesConfig = {};
// ScanJS rules we don't want to use:
const ignoredScanjsRules = [
// scanjs is looking for a different `connect` than the one we use often from react-redux
'call_connect',
];
// bring in all the scanjs rules (other than those we want ignored),
// prefixed with 'scanjs-rules',
// but convert them to eslint errors instead of warnings
Object.keys(scanjsConfig.rulesConfig)
.filter(rule => ignoredScanjsRules.indexOf(rule) === -1)
.forEach((rule) => {
scanjsRulesConfig[`scanjs-rules/${rule}`] = 1;
});
} catch (err) {
// eslint-disable-next-line no-console
console.log('eslint-plugin-scanjs-rules not found, will not include scanjs rules');
}
if (scanjsRulesConfig) {
finalPlugins.push('scanjs-rules', 'no-unsanitized');
const noUnsanitizedRules = {
'no-unsanitized/method': 2,
'no-unsanitized/property': 2,
};
Object.assign(finalRules, scanjsRulesConfig, noUnsanitizedRules);
}
module.exports = {
extends: 'airbnb',
plugins: finalPlugins,
rules: finalRules,
};