1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | 'use strict';
|
11 |
|
12 | function isOff(rule) {
|
13 | return rule === 0 || rule === 'off';
|
14 | }
|
15 |
|
16 | function changeErrorLevel(config, level) {
|
17 |
|
18 | config = JSON.parse(JSON.stringify(config))
|
19 |
|
20 | Object.keys(config.rules).forEach((rule) => {
|
21 | let val = config.rules[rule];
|
22 | if (Array.isArray(val)) {
|
23 | if (isOff(val[0])) {
|
24 | return;
|
25 | }
|
26 | val[0] = level;
|
27 | config.rules[rule] = level;
|
28 | return;
|
29 | }
|
30 | if (isOff(val)) {
|
31 | return;
|
32 | }
|
33 | config.rules[rule] = level;
|
34 | });
|
35 |
|
36 | return config;
|
37 | }
|
38 |
|
39 | module.exports = changeErrorLevel;
|