-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.js
85 lines (78 loc) · 2.39 KB
/
eslint.config.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
73
74
75
76
77
78
79
80
81
82
83
84
85
import comments from "@eslint-community/eslint-plugin-eslint-comments";
import js from "@stylistic/eslint-plugin-js";
import arrayFunc from "eslint-plugin-array-func";
import i from "eslint-plugin-i";
import noUseExtendNative from "eslint-plugin-no-use-extend-native";
import * as regexp from "eslint-plugin-regexp";
import * as sonarjs from "eslint-plugin-sonarjs";
import unicorn from "eslint-plugin-unicorn";
import vitest from "eslint-plugin-vitest";
import globals from "globals";
import {load} from "js-yaml";
import {readFileSync} from "node:fs";
import {deepMerge} from "deepie-merge";
import vitestGlobalsPlugin from "eslint-plugin-vitest-globals";
const eslintrc = load(readFileSync(new URL(".eslintrc.yaml", import.meta.url), "utf8"));
const vitestGlobals = vitestGlobalsPlugin.environments.env.globals;
const common = {
ignores: [
"**/vendor/**",
"**/*.snap",
"!.storybook",
],
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
globals: {
...globals.browser,
...globals.node,
},
},
linterOptions: {
reportUnusedDisableDirectives: "warn"
},
plugins: {
comments,
js,
arrayFunc,
i,
noUseExtendNative,
regexp,
sonarjs,
unicorn,
vitest,
vitestGlobals,
globals,
},
settings: {
"import/extensions": [".js", ".jsx", ".ts", ".tsx"],
},
};
const confs = [];
for (const {files, rules} of eslintrc.overrides) {
const conf = deepMerge(common, {files, rules});
if (files.some(file => file.includes("worker"))) {
conf.languageOptions.globals = {...conf.languageOptions.globals, ...globals.worker};
} else if (files.some(file => file.includes("test"))) {
conf.languageOptions.globals = {...conf.languageOptions.globals, ...vitestGlobals};
} else if (files.some(file => file.includes("config"))) {
conf.rules["i/no-unused-modules"] = [2, {missingExports: true, unusedExports: false}];
} else if (files.some(file => file.includes("storybook"))) {
conf.rules["i/no-unused-modules"] = [0, {missingExports: true, unusedExports: false}];
}
confs.push(conf);
}
// const baseDirectory = dirname(fileURLToPath(import.meta.url));
// export default (new FlatCompat({baseDirectory})).extends("eslint-config-silverwind");
export default [
deepMerge(common, {
files: [
"**/*.js",
"**/*.jsx",
"**/*.ts",
"**/*.tsx",
],
rules: eslintrc.rules,
}),
...confs,
];