@xaliksss/eslint-config 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -7
- package/dist/rules/eslint.js +10 -5
- package/dist/rules/import-x.js +4 -4
- package/dist/rules/stylistic.js +5 -4
- package/dist/rules/typescript.js +13 -3
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
2
2
|
import { defineConfig } from "eslint/config";
|
|
3
|
-
import importPlugin from "eslint-plugin-import-x";
|
|
3
|
+
import importPlugin, { createNodeResolver } from "eslint-plugin-import-x";
|
|
4
4
|
import nPlugin from "eslint-plugin-n";
|
|
5
5
|
import globals from "globals";
|
|
6
6
|
import tseslint from "typescript-eslint";
|
|
7
7
|
import { DEFAULT_CONFIG } from "./config.js";
|
|
8
8
|
import { eslintRules } from "./rules/eslint.js";
|
|
9
9
|
import { importRules } from "./rules/import-x.js";
|
|
10
|
+
import { nRules } from "./rules/n.js";
|
|
10
11
|
import { stylisticRules } from "./rules/stylistic.js";
|
|
11
12
|
import { typescriptRules, typescriptTypeAwareRules } from "./rules/typescript.js";
|
|
13
|
+
const extensions = {
|
|
14
|
+
js: [".js", ".mjs", ".cjs", ".jsx"],
|
|
15
|
+
ts: [".ts", ".mts", ".cts", ".tsx"],
|
|
16
|
+
};
|
|
12
17
|
export default function createConfig(_options = {}) {
|
|
13
18
|
const options = {
|
|
14
19
|
...DEFAULT_CONFIG,
|
|
15
20
|
..._options,
|
|
16
21
|
};
|
|
22
|
+
const cjsFiles = options.jsFiles.filter((pattern) => pattern.endsWith(".cjs"));
|
|
17
23
|
return defineConfig({
|
|
18
24
|
ignores: options.ignores,
|
|
19
25
|
},
|
|
@@ -33,24 +39,49 @@ export default function createConfig(_options = {}) {
|
|
|
33
39
|
"import-x": importPlugin,
|
|
34
40
|
n: nPlugin,
|
|
35
41
|
},
|
|
42
|
+
settings: {
|
|
43
|
+
// Без этого import-x не парсит .ts файлы: no-cycle, named и т.д. молча не работают
|
|
44
|
+
"import-x/extensions": [...extensions.js, ...extensions.ts],
|
|
45
|
+
"import-x/parsers": {
|
|
46
|
+
"@typescript-eslint/parser": extensions.ts,
|
|
47
|
+
},
|
|
48
|
+
// import "./a.js" -> a.ts
|
|
49
|
+
"import-x/resolver-next": [
|
|
50
|
+
createNodeResolver({
|
|
51
|
+
extensions: [...extensions.ts, ...extensions.js, ".json", ".node"],
|
|
52
|
+
extensionAlias: {
|
|
53
|
+
".js": [".ts", ".tsx", ".js", ".jsx"],
|
|
54
|
+
".mjs": [".mts", ".mjs"],
|
|
55
|
+
".cjs": [".cts", ".cjs"],
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
58
|
+
],
|
|
59
|
+
},
|
|
36
60
|
rules: {
|
|
37
61
|
...eslintRules,
|
|
38
62
|
...stylisticRules(options),
|
|
39
63
|
...importRules,
|
|
64
|
+
...nRules,
|
|
40
65
|
},
|
|
41
66
|
},
|
|
67
|
+
// CommonJS
|
|
68
|
+
...cjsFiles.length ? [{
|
|
69
|
+
files: cjsFiles,
|
|
70
|
+
languageOptions: {
|
|
71
|
+
sourceType: "commonjs",
|
|
72
|
+
},
|
|
73
|
+
rules: {
|
|
74
|
+
"import-x/no-commonjs": "off",
|
|
75
|
+
"import-x/unambiguous": "off",
|
|
76
|
+
},
|
|
77
|
+
}] : [],
|
|
42
78
|
// overrides для TS
|
|
43
79
|
{
|
|
44
80
|
files: options.tsFiles,
|
|
45
81
|
languageOptions: {
|
|
46
82
|
parser: tseslint.parser,
|
|
47
83
|
parserOptions: {
|
|
48
|
-
projectService:
|
|
49
|
-
allowDefaultProject: [
|
|
50
|
-
"eslint.config.ts",
|
|
51
|
-
"sandbox.ts",
|
|
52
|
-
],
|
|
53
|
-
},
|
|
84
|
+
projectService: true,
|
|
54
85
|
},
|
|
55
86
|
},
|
|
56
87
|
plugins: {
|
package/dist/rules/eslint.js
CHANGED
|
@@ -19,7 +19,7 @@ export const eslintRules = {
|
|
|
19
19
|
"no-dupe-else-if": "error",
|
|
20
20
|
"no-dupe-keys": "error", // [TS]
|
|
21
21
|
"no-duplicate-case": "error",
|
|
22
|
-
"no-duplicate-imports":
|
|
22
|
+
"no-duplicate-imports": "off", // есть import-x/no-duplicates
|
|
23
23
|
"no-empty-character-class": "error",
|
|
24
24
|
"no-empty-pattern": "error",
|
|
25
25
|
"no-ex-assign": "error",
|
|
@@ -35,6 +35,7 @@ export const eslintRules = {
|
|
|
35
35
|
"no-obj-calls": "error", // [TS]
|
|
36
36
|
"no-promise-executor-return": "error",
|
|
37
37
|
"no-prototype-builtins": "error",
|
|
38
|
+
"no-restricted-syntax": "off",
|
|
38
39
|
"no-self-assign": "error",
|
|
39
40
|
"no-self-compare": "error",
|
|
40
41
|
"no-setter-return": "error", // [TS]
|
|
@@ -51,7 +52,11 @@ export const eslintRules = {
|
|
|
51
52
|
"no-unsafe-negation": "error", // [TS]
|
|
52
53
|
"no-unsafe-optional-chaining": "error",
|
|
53
54
|
"no-unused-private-class-members": "error",
|
|
54
|
-
"no-unused-vars": "error",
|
|
55
|
+
"no-unused-vars": ["error", {
|
|
56
|
+
ignoreRestSiblings: true,
|
|
57
|
+
ignoreClassWithStaticInitBlock: true,
|
|
58
|
+
argsIgnorePattern: "^_",
|
|
59
|
+
}],
|
|
55
60
|
"no-use-before-define": ["error", {
|
|
56
61
|
functions: false,
|
|
57
62
|
classes: false,
|
|
@@ -108,15 +113,15 @@ export const eslintRules = {
|
|
|
108
113
|
"require-yield": "error",
|
|
109
114
|
"sort-imports": "off", // установлен другой плагин import
|
|
110
115
|
"sort-keys": "off",
|
|
111
|
-
"sort-vars": "
|
|
116
|
+
"sort-vars": "off", // не нужен при one-var: never
|
|
112
117
|
strict: "off",
|
|
113
118
|
"symbol-description": "error",
|
|
114
|
-
"vars-on-top": "
|
|
119
|
+
"vars-on-top": "off", // не нужен при no-var
|
|
115
120
|
yoda: "error",
|
|
116
121
|
"unicode-bom": "error",
|
|
117
122
|
"accessor-pairs": "error", // Спорно, возможно удалится
|
|
118
123
|
"arrow-body-style": "off",
|
|
119
|
-
"block-scoped-var": "
|
|
124
|
+
"block-scoped-var": "off", // не нужен при no-var
|
|
120
125
|
camelcase: "off", // есть naming-convention с более детальной настройкой
|
|
121
126
|
"capitalized-comments": "off",
|
|
122
127
|
"class-methods-use-this": "off",
|
package/dist/rules/import-x.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const importRules = {
|
|
2
2
|
"import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
3
|
-
"import-x/default": "error",
|
|
3
|
+
"import-x/default": "error", // [TS]
|
|
4
4
|
"import-x/dynamic-import-chunkname": "off",
|
|
5
5
|
"import-x/export": "error",
|
|
6
6
|
"import-x/exports-last": "off",
|
|
@@ -8,8 +8,8 @@ export const importRules = {
|
|
|
8
8
|
"import-x/first": "error",
|
|
9
9
|
"import-x/group-exports": "off",
|
|
10
10
|
"import-x/max-dependencies": "off",
|
|
11
|
-
"import-x/named": "error",
|
|
12
|
-
"import-x/namespace": "error",
|
|
11
|
+
"import-x/named": "error", // [TS]
|
|
12
|
+
"import-x/namespace": "error", // [TS]
|
|
13
13
|
"import-x/newline-after-import": ["error", { count: 1 }],
|
|
14
14
|
"import-x/no-absolute-path": "error",
|
|
15
15
|
"import-x/no-amd": "error",
|
|
@@ -22,7 +22,7 @@ export const importRules = {
|
|
|
22
22
|
}],
|
|
23
23
|
"import-x/no-default-export": "off",
|
|
24
24
|
"import-x/no-deprecated": "off", // С этим лучше справляется @typescript-eslint/no-deprecated
|
|
25
|
-
"import-x/no-duplicates": "
|
|
25
|
+
"import-x/no-duplicates": "error", // type и value импорты считаются отдельно (prefer-inline: false)
|
|
26
26
|
"import-x/no-dynamic-require": "error",
|
|
27
27
|
"import-x/no-empty-named-blocks": "error",
|
|
28
28
|
"import-x/no-extraneous-dependencies": "error",
|
package/dist/rules/stylistic.js
CHANGED
|
@@ -15,7 +15,7 @@ export const stylisticRules = (options) => {
|
|
|
15
15
|
"@stylistic/generator-star-spacing": "error",
|
|
16
16
|
"@stylistic/implicit-arrow-linebreak": "error",
|
|
17
17
|
"@stylistic/indent": ["error", "tab"],
|
|
18
|
-
"@stylistic/indent-binary-ops": ["error",
|
|
18
|
+
"@stylistic/indent-binary-ops": ["error", "tab"],
|
|
19
19
|
// JSX пока игнорирую. потом сделаю
|
|
20
20
|
"@stylistic/jsx-child-element-spacing": "off",
|
|
21
21
|
"@stylistic/jsx-closing-bracket-location": "off",
|
|
@@ -31,7 +31,7 @@ export const stylisticRules = (options) => {
|
|
|
31
31
|
"@stylistic/jsx-newline": "off",
|
|
32
32
|
"@stylistic/jsx-one-expression-per-line": "off",
|
|
33
33
|
"@stylistic/jsx-pascal-case": "off",
|
|
34
|
-
"@stylistic/jsx-props-style": "off",
|
|
34
|
+
"@stylistic/exp-jsx-props-style": "off", // experimental
|
|
35
35
|
"@stylistic/jsx-quotes": "off",
|
|
36
36
|
"@stylistic/jsx-self-closing-comp": "off",
|
|
37
37
|
"@stylistic/jsx-shorthand-boolean": "off",
|
|
@@ -77,9 +77,9 @@ export const stylisticRules = (options) => {
|
|
|
77
77
|
ImportAttributes: { singleLine: { spacing: "always" } }, // import ... with { a, b, c }
|
|
78
78
|
ObjectExpression: { singleLine: { spacing: "always" } }, // a = { a, b, c }
|
|
79
79
|
ObjectPattern: { singleLine: { spacing: "always" } }, // { a, b, c } = d
|
|
80
|
-
// [TODO]: beta 7. multiline -> multiLine
|
|
80
|
+
// [TODO]: ждем beta 7. multiline -> multiLine
|
|
81
81
|
TSInterfaceBody: { singleLine: { spacing: "always", maxItems: 1 } }, // interface A { a } | interface A { a,\n b }
|
|
82
|
-
// [TODO]: beta 7. multiline -> multiLine
|
|
82
|
+
// [TODO]: ждем beta 7. multiline -> multiLine
|
|
83
83
|
TSEnumBody: { singleLine: { maxItems: 0 } }, // enum {\n a,\n b }
|
|
84
84
|
TSTypeLiteral: { singleLine: { spacing: "always" } }, // a: { b: B, c: D }
|
|
85
85
|
JSONObjectExpression: { singleLine: { spacing: "always" } }, // "a": { "b": "c" }
|
|
@@ -142,6 +142,7 @@ export const stylisticRules = (options) => {
|
|
|
142
142
|
"?": "before",
|
|
143
143
|
":": "before",
|
|
144
144
|
"|": "before",
|
|
145
|
+
"&": "before",
|
|
145
146
|
},
|
|
146
147
|
}],
|
|
147
148
|
"@stylistic/padded-blocks": ["error", "never"],
|
package/dist/rules/typescript.js
CHANGED
|
@@ -18,6 +18,9 @@ export const typescriptRules = {
|
|
|
18
18
|
"no-unsafe-negation": "off",
|
|
19
19
|
"no-invalid-this": "off",
|
|
20
20
|
"no-redeclare": "off",
|
|
21
|
+
"import-x/default": "off",
|
|
22
|
+
"import-x/named": "off",
|
|
23
|
+
"import-x/namespace": "off",
|
|
21
24
|
"@typescript-eslint/adjacent-overload-signatures": "error",
|
|
22
25
|
"@typescript-eslint/array-type": ["error", { default: "array-simple" }],
|
|
23
26
|
"@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
|
|
@@ -137,11 +140,14 @@ export const typescriptTypeAwareRules = {
|
|
|
137
140
|
"@typescript-eslint/no-array-delete": "error",
|
|
138
141
|
"@typescript-eslint/no-base-to-string": "error",
|
|
139
142
|
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
143
|
+
"@typescript-eslint/no-duplicate-type-constituents": "error",
|
|
140
144
|
"@typescript-eslint/no-floating-promises": ["error", {
|
|
141
145
|
ignoreIIFE: true,
|
|
142
146
|
}],
|
|
143
147
|
"@typescript-eslint/no-for-in-array": "error",
|
|
144
|
-
"
|
|
148
|
+
"no-implied-eval": "off", // core ловит только строковые литералы
|
|
149
|
+
"no-new-func": "off",
|
|
150
|
+
"@typescript-eslint/no-implied-eval": "error", // + любые string по типу и new Function
|
|
145
151
|
"@typescript-eslint/no-meaningless-void-operator": "error",
|
|
146
152
|
"@typescript-eslint/no-misused-promises": ["error", {
|
|
147
153
|
checksVoidReturn: {
|
|
@@ -152,7 +158,9 @@ export const typescriptTypeAwareRules = {
|
|
|
152
158
|
"@typescript-eslint/no-mixed-enums": "error",
|
|
153
159
|
"@typescript-eslint/no-redundant-type-constituents": "error",
|
|
154
160
|
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "error",
|
|
155
|
-
"@typescript-eslint/no-unnecessary-condition": "error",
|
|
161
|
+
"@typescript-eslint/no-unnecessary-condition": ["error", {
|
|
162
|
+
allowConstantLoopConditions: "only-allowed-literals", // while (true)
|
|
163
|
+
}],
|
|
156
164
|
"@typescript-eslint/no-unnecessary-qualifier": "error",
|
|
157
165
|
"@typescript-eslint/no-unnecessary-template-expression": "error",
|
|
158
166
|
"@typescript-eslint/no-unnecessary-type-arguments": "error",
|
|
@@ -177,7 +185,9 @@ export const typescriptTypeAwareRules = {
|
|
|
177
185
|
"@typescript-eslint/prefer-destructuring": ["error", { array: true, object: false }],
|
|
178
186
|
"@typescript-eslint/prefer-find": "error",
|
|
179
187
|
"@typescript-eslint/prefer-includes": "error",
|
|
180
|
-
"@typescript-eslint/prefer-nullish-coalescing": "error",
|
|
188
|
+
"@typescript-eslint/prefer-nullish-coalescing": ["error", {
|
|
189
|
+
ignoreIfStatements: true, // if (!a) a = b; -> a ||= b делает logical-assignment-operators, дальше это правило предложит ??=
|
|
190
|
+
}],
|
|
181
191
|
"@typescript-eslint/prefer-optional-chain": "error",
|
|
182
192
|
"prefer-promise-reject-errors": "off",
|
|
183
193
|
"@typescript-eslint/prefer-promise-reject-errors": ["error", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xaliksss/eslint-config",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
"eslint-plugin-import-x": "^4.17.1",
|
|
29
29
|
"eslint-plugin-n": "^18.3.0",
|
|
30
30
|
"globals": "17.12.0",
|
|
31
|
-
"typescript-eslint": "8.70.
|
|
31
|
+
"typescript-eslint": "8.70.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
+
"@types/node": "24",
|
|
34
35
|
"jiti": "^2.7.0",
|
|
35
36
|
"typescript": "^6.0.3"
|
|
36
37
|
}
|