-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
109 lines (98 loc) · 2.73 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const pluginCspell = require("@cspell/eslint-plugin");
const pluginTypeScript = require("@typescript-eslint/eslint-plugin");
const typescriptEslintParser = require("@typescript-eslint/parser");
const pluginPrettier = require("eslint-config-prettier");
const pluginImport = require("eslint-plugin-import");
const pluginSonarJs = require("eslint-plugin-sonarjs");
const pluginUnusedImport = require("eslint-plugin-unused-imports");
/** @type { import("eslint").Linter.FlatConfig } */
const ignorePattern = {
ignores: ["**/dist", "**/node_modules", "**/*.config.{,m,c}js"],
};
/** @type { import("eslint").Linter.FlatConfig } */
const importResolver = {
files: ["**/*.{,m,c}{t,j}s"],
plugins: {
import: pluginImport,
"unused-imports": pluginUnusedImport,
},
settings: {
"import/resolver": {
node: {
extensions: ["**/*.{,m,c}{t,j}s"],
},
typescript: {
project: ["**/tsconfig.json"],
},
},
},
rules: {
...pluginImport.configs["recommended"].rules,
...pluginImport.configs["typescript"].rules,
"import/namespace": "off",
"import/default": "off",
"import/no-named-as-default-member": "off",
"import/no-named-as-default": "off",
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index",
"object",
],
"newlines-between": "always",
alphabetize: { order: "asc", caseInsensitive: false },
},
],
"unused-imports/no-unused-imports": "error",
},
};
/** @type { import("eslint").Linter.FlatConfig } */
const baseRules = [ignorePattern, importResolver];
/** @type { import("eslint").Linter.FlatConfig } */
const tsRules = {
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: typescriptEslintParser,
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
},
plugins: {
"@typescript-eslint": pluginTypeScript,
"@cspell": pluginCspell,
sonarjs: pluginSonarJs,
},
rules: {
...pluginTypeScript.configs["eslint-recommended"].rules,
...pluginTypeScript.configs["recommended"].rules,
...pluginSonarJs.configs["recommended"].rules,
...pluginCspell.configs["recommended"].rules,
...pluginPrettier.rules,
"object-shorthand": ["error", "never"],
"@typescript-eslint/no-unused-vars": [
"error",
{
vars: "all",
args: "none",
},
],
},
};
/** @type { import("eslint").Linter.FlatConfig } */
const specRules = {
files: ["**/*.spec.{,c,m}{j,t}s"],
plugins: {
sonarjs: pluginSonarJs,
},
rules: {
"sonarjs/no-duplicate-string": "off",
},
};
module.exports = [...baseRules, tsRules, specRules];