-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (34 loc) · 1.47 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
export { default as browser } from "./conf/browser.js";
export { default as common } from "./conf/common.js";
export { default as edge } from "./conf/edge.js";
export { default as modules } from "./conf/modules.js";
export { default as node } from "./conf/node.js";
export { default as prettier } from "./conf/prettier.js";
export { default as stylistic } from "./conf/stylistic.js";
export { default as typescript } from "./conf/typescript.js";
export { default as ignores } from "./conf/ignores.js";
/**
* @param {import("eslint").Linter.FlatConfig[]} config - eslint config
* @param {{ rule: string, option: ["off" | "warn" | "error", object] }[]} rulesAndOptions - rules and options to extend
* @param {boolean} replace - replace existing options
* @returns {import("eslint").Linter.FlatConfig[]}
* @example extend(config, [{ rule: "no-console", option: ["warn", { allow: ["warn", "error"] }] }])
*/
export function extend(config, rulesAndOptions, replace = false) {
return config.map(c => {
if (c.rules) {
for (const { rule, option } of rulesAndOptions) {
if (replace) {
c.rules[rule] = option;
} else {
const oldOption = c.rules[rule];
c.rules[rule] = [
option[0],
Array.isArray(oldOption) ? { ...oldOption[1], ...option[1] } : option[1]
];
}
}
}
return c;
});
}