@xaliksss/eslint-config 4.0.3 → 5.0.0
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/config.d.ts +28 -0
- package/dist/config.js +9 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +57 -58
- package/dist/rules/eslint.js +7 -7
- package/dist/rules/import-x.d.ts +1 -1
- package/dist/rules/import-x.js +6 -9
- package/dist/rules/n.d.ts +1 -1
- package/dist/rules/n.js +0 -1
- package/dist/rules/stylistic.d.ts +2 -1
- package/dist/rules/stylistic.js +174 -148
- package/dist/rules/typescript.d.ts +1 -1
- package/dist/rules/typescript.js +9 -16
- package/package.json +37 -35
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface XaliksConfigOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Файлы, которые не должны быть обработаны плагином.
|
|
4
|
+
* @default ["**\/dist/**", "**\/node_modules/**"]
|
|
5
|
+
*/
|
|
6
|
+
ignores?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Файлы, которые должны быть обработаны плагином только для JS.
|
|
9
|
+
* @default ["**\/*.js", "**\/*.mjs", "**\/*.cjs", "**\/*.jsx"]
|
|
10
|
+
*/
|
|
11
|
+
jsFiles?: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Файлы, которые должны быть обработаны плагином только для TS.
|
|
14
|
+
* @default ["**\/*.ts", "**\/*.mts", "**\/*.cts", "**\/*.tsx"]
|
|
15
|
+
*/
|
|
16
|
+
tsFiles?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Максимальная длина строки.
|
|
19
|
+
* @default 120
|
|
20
|
+
*/
|
|
21
|
+
maxCodeLength?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare const DEFAULT_CONFIG: {
|
|
24
|
+
ignores: string[];
|
|
25
|
+
jsFiles: string[];
|
|
26
|
+
tsFiles: string[];
|
|
27
|
+
maxCodeLength: number;
|
|
28
|
+
};
|
package/dist/config.js
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export default
|
|
1
|
+
import type { XaliksConfigOptions } from "./config.js";
|
|
2
|
+
export default function createConfig(_options?: XaliksConfigOptions): import("eslint/config").ConfigObject[];
|
package/dist/index.js
CHANGED
|
@@ -1,65 +1,64 @@
|
|
|
1
|
-
import { defineConfig } from 'eslint/config';
|
|
2
|
-
import globals from "globals";
|
|
3
|
-
import tseslint from "typescript-eslint";
|
|
4
1
|
import stylisticPlugin from "@stylistic/eslint-plugin";
|
|
2
|
+
import { defineConfig } from "eslint/config";
|
|
5
3
|
import importPlugin from "eslint-plugin-import-x";
|
|
6
4
|
import nPlugin from "eslint-plugin-n";
|
|
5
|
+
import globals from "globals";
|
|
6
|
+
import tseslint from "typescript-eslint";
|
|
7
|
+
import { DEFAULT_CONFIG } from "./config.js";
|
|
7
8
|
import { eslintRules } from "./rules/eslint.js";
|
|
8
|
-
import { stylisticRules } from "./rules/stylistic.js";
|
|
9
9
|
import { importRules } from "./rules/import-x.js";
|
|
10
|
+
import { stylisticRules } from "./rules/stylistic.js";
|
|
10
11
|
import { typescriptRules, typescriptTypeAwareRules } from "./rules/typescript.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
export default function createConfig(_options = {}) {
|
|
13
|
+
const options = {
|
|
14
|
+
...DEFAULT_CONFIG,
|
|
15
|
+
..._options,
|
|
16
|
+
};
|
|
17
|
+
return defineConfig({
|
|
18
|
+
ignores: options.ignores,
|
|
19
|
+
},
|
|
20
|
+
// Общие правила для JS и TS
|
|
21
|
+
{
|
|
22
|
+
files: [...options.jsFiles, ...options.tsFiles],
|
|
23
|
+
languageOptions: {
|
|
24
|
+
ecmaVersion: "latest",
|
|
25
|
+
sourceType: "module",
|
|
26
|
+
globals: {
|
|
27
|
+
...globals.node,
|
|
28
|
+
NodeJS: "off",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
plugins: {
|
|
32
|
+
"@stylistic": stylisticPlugin,
|
|
33
|
+
"import-x": importPlugin,
|
|
34
|
+
n: nPlugin,
|
|
35
|
+
},
|
|
36
|
+
rules: {
|
|
37
|
+
...eslintRules,
|
|
38
|
+
...stylisticRules(options),
|
|
39
|
+
...importRules,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
// overrides для TS
|
|
43
|
+
{
|
|
44
|
+
files: options.tsFiles,
|
|
45
|
+
languageOptions: {
|
|
46
|
+
parser: tseslint.parser,
|
|
47
|
+
parserOptions: {
|
|
48
|
+
projectService: {
|
|
49
|
+
allowDefaultProject: [
|
|
50
|
+
"eslint.config.ts",
|
|
51
|
+
"sandbox.ts",
|
|
52
|
+
],
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
plugins: {
|
|
57
|
+
"@typescript-eslint": tseslint.plugin,
|
|
58
|
+
},
|
|
59
|
+
rules: {
|
|
60
|
+
...typescriptRules,
|
|
61
|
+
...typescriptTypeAwareRules,
|
|
29
62
|
},
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
"@stylistic": stylisticPlugin,
|
|
33
|
-
"import-x": importPlugin,
|
|
34
|
-
n: nPlugin,
|
|
35
|
-
},
|
|
36
|
-
rules: {
|
|
37
|
-
...eslintRules,
|
|
38
|
-
...stylisticRules,
|
|
39
|
-
...importRules,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
// overrides для TS
|
|
43
|
-
{
|
|
44
|
-
files: TS_FILES,
|
|
45
|
-
languageOptions: {
|
|
46
|
-
parser: tseslint.parser,
|
|
47
|
-
parserOptions: { project: false },
|
|
48
|
-
},
|
|
49
|
-
plugins: {
|
|
50
|
-
"@typescript-eslint": tseslint.plugin,
|
|
51
|
-
},
|
|
52
|
-
rules: typescriptRules,
|
|
53
|
-
},
|
|
54
|
-
// type-aware правила
|
|
55
|
-
{
|
|
56
|
-
files: TS_FILES,
|
|
57
|
-
languageOptions: {
|
|
58
|
-
parser: tseslint.parser,
|
|
59
|
-
parserOptions: { project: true },
|
|
60
|
-
},
|
|
61
|
-
plugins: {
|
|
62
|
-
"@typescript-eslint": tseslint.plugin,
|
|
63
|
-
},
|
|
64
|
-
rules: typescriptTypeAwareRules,
|
|
65
|
-
});
|
|
63
|
+
});
|
|
64
|
+
}
|
package/dist/rules/eslint.js
CHANGED
|
@@ -102,33 +102,33 @@ export const eslintRules = {
|
|
|
102
102
|
"prefer-spread": "error",
|
|
103
103
|
"prefer-template": "error",
|
|
104
104
|
"preserve-caught-error": "off", // Нужно указывать cause в new Error
|
|
105
|
-
|
|
105
|
+
radix: "off",
|
|
106
106
|
"require-await": "error",
|
|
107
107
|
"require-unicode-regexp": "off", // Обязательно указывать /u или /v в regex
|
|
108
108
|
"require-yield": "error",
|
|
109
109
|
"sort-imports": "off", // установлен другой плагин import
|
|
110
110
|
"sort-keys": "off",
|
|
111
111
|
"sort-vars": "error",
|
|
112
|
-
|
|
112
|
+
strict: "off",
|
|
113
113
|
"symbol-description": "error",
|
|
114
114
|
"vars-on-top": "error",
|
|
115
|
-
|
|
115
|
+
yoda: "error",
|
|
116
116
|
"unicode-bom": "error",
|
|
117
117
|
"accessor-pairs": "error", // Спорно, возможно удалится
|
|
118
118
|
"arrow-body-style": "off",
|
|
119
119
|
"block-scoped-var": "error",
|
|
120
|
-
|
|
120
|
+
camelcase: "off", // есть naming-convention с более детальной настройкой
|
|
121
121
|
"capitalized-comments": "off",
|
|
122
122
|
"class-methods-use-this": "off",
|
|
123
|
-
|
|
123
|
+
complexity: "off",
|
|
124
124
|
"consistent-return": "off",
|
|
125
125
|
"consistent-this": "off",
|
|
126
|
-
|
|
126
|
+
curly: ["error", "multi-line"],
|
|
127
127
|
"default-case": "off",
|
|
128
128
|
"default-case-last": "error",
|
|
129
129
|
"default-param-last": "error",
|
|
130
130
|
"dot-notation": "error",
|
|
131
|
-
|
|
131
|
+
eqeqeq: "error",
|
|
132
132
|
"func-name-matching": "error",
|
|
133
133
|
"func-names": "off",
|
|
134
134
|
"func-style": ["error", "declaration", { allowArrowFunctions: true }],
|
package/dist/rules/import-x.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Linter } from "eslint";
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
2
|
export declare const importRules: Linter.RulesRecord;
|
package/dist/rules/import-x.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Linter } from "eslint";
|
|
2
1
|
export const importRules = {
|
|
3
2
|
"import-x/consistent-type-specifier-style": ["error", "prefer-top-level"],
|
|
4
3
|
"import-x/default": "error",
|
|
@@ -11,7 +10,7 @@ export const importRules = {
|
|
|
11
10
|
"import-x/max-dependencies": "off",
|
|
12
11
|
"import-x/named": "error",
|
|
13
12
|
"import-x/namespace": "error",
|
|
14
|
-
"import-x/newline-after-import": ["error", { count: 1
|
|
13
|
+
"import-x/newline-after-import": ["error", { count: 1 }],
|
|
15
14
|
"import-x/no-absolute-path": "error",
|
|
16
15
|
"import-x/no-amd": "error",
|
|
17
16
|
"import-x/no-anonymous-default-export": "error",
|
|
@@ -19,7 +18,7 @@ export const importRules = {
|
|
|
19
18
|
"import-x/no-cycle": ["error", {
|
|
20
19
|
maxDepth: 4, // Возможно придется обновить на 1
|
|
21
20
|
ignoreExternal: true,
|
|
22
|
-
allowUnsafeDynamicCyclicDependency: false
|
|
21
|
+
allowUnsafeDynamicCyclicDependency: false,
|
|
23
22
|
}],
|
|
24
23
|
"import-x/no-default-export": "off",
|
|
25
24
|
"import-x/no-deprecated": "off", // С этим лучше справляется @typescript-eslint/no-deprecated
|
|
@@ -31,14 +30,14 @@ export const importRules = {
|
|
|
31
30
|
"import-x/no-internal-modules": "off",
|
|
32
31
|
"import-x/no-mutable-exports": "error",
|
|
33
32
|
"import-x/no-named-as-default-member": "error",
|
|
34
|
-
"import-x/no-named-as-default": "
|
|
33
|
+
"import-x/no-named-as-default": "off",
|
|
35
34
|
"import-x/no-named-default": "error",
|
|
36
35
|
"import-x/no-named-export": "off",
|
|
37
36
|
"import-x/no-namespace": "off",
|
|
38
37
|
"import-x/no-nodejs-modules": "off",
|
|
39
38
|
"import-x/no-relative-packages": "off",
|
|
40
39
|
"import-x/no-relative-parent-imports": "off",
|
|
41
|
-
"import-x/no-rename-default": "
|
|
40
|
+
"import-x/no-rename-default": "off",
|
|
42
41
|
"import-x/no-restricted-paths": "off", // в связке с no-restricted-imports от Eslint
|
|
43
42
|
"import-x/no-self-import": "error",
|
|
44
43
|
"import-x/no-unassigned-import": "off",
|
|
@@ -46,14 +45,12 @@ export const importRules = {
|
|
|
46
45
|
"import-x/no-unused-modules": "off", // с eslint v10 no-op, есть no-unused-vars
|
|
47
46
|
"import-x/no-useless-path-segments": "error",
|
|
48
47
|
"import-x/no-webpack-loader-syntax": "error",
|
|
49
|
-
"import-x/order": ["error",
|
|
50
|
-
{
|
|
48
|
+
"import-x/order": ["error", {
|
|
51
49
|
groups: ["builtin", "external", "type", "internal", "parent", "sibling", "index", "object"],
|
|
52
50
|
"newlines-between": "always",
|
|
53
51
|
alphabetize: { order: "asc" },
|
|
54
52
|
named: true,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
53
|
+
}],
|
|
57
54
|
"import-x/prefer-default-export": "off",
|
|
58
55
|
"import-x/prefer-namespace-import": "off",
|
|
59
56
|
"import-x/unambiguous": "error",
|
package/dist/rules/n.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Linter } from "eslint";
|
|
1
|
+
import type { Linter } from "eslint";
|
|
2
2
|
export declare const nRules: Linter.RulesRecord;
|
package/dist/rules/n.js
CHANGED
package/dist/rules/stylistic.js
CHANGED
|
@@ -1,149 +1,175 @@
|
|
|
1
|
-
export const stylisticRules = {
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
1
|
+
export const stylisticRules = (options) => {
|
|
2
|
+
return {
|
|
3
|
+
"@stylistic/arrow-parens": "error",
|
|
4
|
+
"@stylistic/arrow-spacing": "error",
|
|
5
|
+
"@stylistic/block-spacing": "error",
|
|
6
|
+
"@stylistic/brace-style": "error",
|
|
7
|
+
"@stylistic/comma-dangle": ["error", "always-multiline"],
|
|
8
|
+
"@stylistic/comma-spacing": "error",
|
|
9
|
+
"@stylistic/comma-style": "error",
|
|
10
|
+
"@stylistic/computed-property-spacing": "error",
|
|
11
|
+
"@stylistic/curly-newline": ["error", { consistent: true }],
|
|
12
|
+
"@stylistic/dot-location": ["error", "property"],
|
|
13
|
+
"@stylistic/eol-last": ["error", "always"],
|
|
14
|
+
"@stylistic/function-call-spacing": "error",
|
|
15
|
+
"@stylistic/generator-star-spacing": "error",
|
|
16
|
+
"@stylistic/implicit-arrow-linebreak": "error",
|
|
17
|
+
"@stylistic/indent": ["error", "tab"],
|
|
18
|
+
"@stylistic/indent-binary-ops": ["error", 1],
|
|
19
|
+
// JSX пока игнорирую. потом сделаю
|
|
20
|
+
"@stylistic/jsx-child-element-spacing": "off",
|
|
21
|
+
"@stylistic/jsx-closing-bracket-location": "off",
|
|
22
|
+
"@stylistic/jsx-closing-tag-location": "off",
|
|
23
|
+
"@stylistic/jsx-curly-brace-presence": "off",
|
|
24
|
+
"@stylistic/jsx-curly-newline": "off",
|
|
25
|
+
"@stylistic/jsx-curly-spacing": "off",
|
|
26
|
+
"@stylistic/jsx-equals-spacing": "off",
|
|
27
|
+
"@stylistic/jsx-first-prop-new-line": "off",
|
|
28
|
+
"@stylistic/jsx-function-call-newline": "off",
|
|
29
|
+
"@stylistic/jsx-indent-props": "off",
|
|
30
|
+
"@stylistic/jsx-max-props-per-line": "off",
|
|
31
|
+
"@stylistic/jsx-newline": "off",
|
|
32
|
+
"@stylistic/jsx-one-expression-per-line": "off",
|
|
33
|
+
"@stylistic/jsx-pascal-case": "off",
|
|
34
|
+
"@stylistic/jsx-props-style": "off",
|
|
35
|
+
"@stylistic/jsx-quotes": "off",
|
|
36
|
+
"@stylistic/jsx-self-closing-comp": "off",
|
|
37
|
+
"@stylistic/jsx-shorthand-boolean": "off",
|
|
38
|
+
"@stylistic/jsx-shorthand-fragment": "off",
|
|
39
|
+
"@stylistic/jsx-tag-spacing": "off",
|
|
40
|
+
"@stylistic/jsx-wrap-multilines": "off",
|
|
41
|
+
"@stylistic/key-spacing": "error",
|
|
42
|
+
"@stylistic/keyword-spacing": "error",
|
|
43
|
+
"@stylistic/line-comment-position": "off", // Без разницы где ставить комментарий
|
|
44
|
+
"@stylistic/linebreak-style": ["error", "unix"],
|
|
45
|
+
"@stylistic/lines-around-comment": "off", // Без разницы где ставить комментарий
|
|
46
|
+
"@stylistic/lines-between-class-members": ["error", {
|
|
47
|
+
enforce: [
|
|
48
|
+
{ blankLine: "always", prev: "method", next: "method" },
|
|
49
|
+
{ blankLine: "always", prev: "field", next: "method" },
|
|
50
|
+
{ blankLine: "always", prev: "method", next: "field" },
|
|
51
|
+
],
|
|
52
|
+
}, { exceptAfterOverload: true }],
|
|
53
|
+
"@stylistic/list-style": ["error", {
|
|
54
|
+
empty: "never",
|
|
55
|
+
overrides: {
|
|
56
|
+
// Сбрасываем defaults
|
|
57
|
+
"{}": "off",
|
|
58
|
+
"[]": "off",
|
|
59
|
+
"()": "off",
|
|
60
|
+
"<>": "off",
|
|
61
|
+
ArrayExpression: {}, // Создание массива a = [1, 2, 3] | function([1, 2, 3]),
|
|
62
|
+
ArrayPattern: {}, // Извлечение из массива [a, b] = c | function([a, b]) => a + b,
|
|
63
|
+
ArrowFunctionExpression: {}, // Параметры стрелоч. функции (a, b) => a + b
|
|
64
|
+
CallExpression: {}, // Вызов функции через () a(b, c)
|
|
65
|
+
FunctionDeclaration: {}, // Создание именованной функции function a(b, c)
|
|
66
|
+
FunctionExpression: {}, // Создание анонимной функции a = function(b, c)
|
|
67
|
+
IfStatement: {}, // Условие в if if (a)
|
|
68
|
+
NewExpression: {}, // Создание через new new a(b, c)
|
|
69
|
+
TSDeclareFunction: {}, // Оверлоад функции
|
|
70
|
+
TSFunctionType: {}, // Тип стрелочной нотации (a: B, c: D) => void
|
|
71
|
+
TSTupleType: {}, // Тип кортежа. Массив фикс. длины [a: B, c: D]
|
|
72
|
+
TSTypeParameterDeclaration: {}, // Типов объявлений функций type C<A, B>
|
|
73
|
+
TSTypeParameterInstantiation: {}, // Типы параметров a: Map<A, B>
|
|
74
|
+
JSONArrayExpression: {}, // "a": ["b", "c"]
|
|
75
|
+
ExportNamedDeclaration: { singleLine: { spacing: "always" } }, // export { a, b, c }
|
|
76
|
+
ImportDeclaration: { singleLine: { spacing: "always" } }, // import { a, b, c }
|
|
77
|
+
ImportAttributes: { singleLine: { spacing: "always" } }, // import ... with { a, b, c }
|
|
78
|
+
ObjectExpression: { singleLine: { spacing: "always" } }, // a = { a, b, c }
|
|
79
|
+
ObjectPattern: { singleLine: { spacing: "always" } }, // { a, b, c } = d
|
|
80
|
+
// [TODO]: beta 7. multiline -> multiLine
|
|
81
|
+
TSInterfaceBody: { singleLine: { spacing: "always", maxItems: 1 } }, // interface A { a } | interface A { a,\n b }
|
|
82
|
+
// [TODO]: beta 7. multiline -> multiLine
|
|
83
|
+
TSEnumBody: { singleLine: { maxItems: 0 } }, // enum {\n a,\n b }
|
|
84
|
+
TSTypeLiteral: { singleLine: { spacing: "always" } }, // a: { b: B, c: D }
|
|
85
|
+
JSONObjectExpression: { singleLine: { spacing: "always" } }, // "a": { "b": "c" }
|
|
86
|
+
},
|
|
87
|
+
}],
|
|
88
|
+
"@stylistic/max-len": ["error", {
|
|
89
|
+
code: options.maxCodeLength,
|
|
90
|
+
tabWidth: 1,
|
|
91
|
+
ignoreComments: true,
|
|
92
|
+
ignoreTrailingComments: true,
|
|
93
|
+
ignoreUrls: true,
|
|
94
|
+
ignoreStrings: true,
|
|
95
|
+
ignoreTemplateLiterals: true,
|
|
96
|
+
ignoreRegExpLiterals: true,
|
|
97
|
+
}],
|
|
98
|
+
"@stylistic/max-statements-per-line": ["error", { max: 1 }],
|
|
99
|
+
"@stylistic/member-delimiter-style": ["error", {
|
|
100
|
+
multiline: {
|
|
101
|
+
delimiter: "semi",
|
|
102
|
+
requireLast: true,
|
|
103
|
+
},
|
|
104
|
+
singleline: {
|
|
105
|
+
delimiter: "semi",
|
|
106
|
+
requireLast: false,
|
|
107
|
+
},
|
|
108
|
+
}],
|
|
109
|
+
"@stylistic/multiline-comment-style": "off",
|
|
110
|
+
"@stylistic/multiline-ternary": "off",
|
|
111
|
+
"@stylistic/new-parens": "error",
|
|
112
|
+
"@stylistic/newline-per-chained-call": "off",
|
|
113
|
+
"@stylistic/no-confusing-arrow": "off",
|
|
114
|
+
"@stylistic/no-extra-parens": ["error", "all", {
|
|
115
|
+
returnAssign: false, // return (a = b)
|
|
116
|
+
nestedBinaryExpressions: false, // (a || b) && c
|
|
117
|
+
ternaryOperandBinaryExpressions: false, // (a && b) ? foo : bar;
|
|
118
|
+
nestedConditionalExpressions: false, // (a ? b : c) ? d : e
|
|
119
|
+
ignoredNodes: [
|
|
120
|
+
"ArrowFunctionExpression[body.type=ConditionalExpression]", // x => (a ? b : c)
|
|
121
|
+
"SpreadElement[argument.type=ConditionalExpression]", // ...(a ? [1, 2, 3] : []),
|
|
122
|
+
"SpreadElement[argument.type=LogicalExpression]", // ...(isSummer && { watermelon: 30 }),
|
|
123
|
+
"SpreadElement[argument.type=AwaitExpression]", // ...(await promiseArray)
|
|
124
|
+
],
|
|
125
|
+
}],
|
|
126
|
+
"@stylistic/no-extra-semi": "error",
|
|
127
|
+
"@stylistic/no-floating-decimal": "error",
|
|
128
|
+
"@stylistic/no-mixed-operators": ["error", {
|
|
129
|
+
groups: [["&&", "||", "?:"]],
|
|
130
|
+
allowSamePrecedence: true,
|
|
131
|
+
}],
|
|
132
|
+
"@stylistic/no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
|
|
133
|
+
"@stylistic/no-multi-spaces": "error", // Для некоторых проектов можно разрешать const a = '' для красоты
|
|
134
|
+
"@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 1 }],
|
|
135
|
+
"@stylistic/no-tabs": "off",
|
|
136
|
+
"@stylistic/no-trailing-spaces": ["error", { ignoreComments: true }],
|
|
137
|
+
"@stylistic/no-whitespace-before-property": "error",
|
|
138
|
+
"@stylistic/nonblock-statement-body-position": "error",
|
|
139
|
+
"@stylistic/one-var-declaration-per-line": "off",
|
|
140
|
+
"@stylistic/operator-linebreak": ["error", "after", {
|
|
141
|
+
overrides: {
|
|
142
|
+
"?": "before",
|
|
143
|
+
":": "before",
|
|
144
|
+
"|": "before",
|
|
145
|
+
},
|
|
146
|
+
}],
|
|
147
|
+
"@stylistic/padded-blocks": ["error", "never"],
|
|
148
|
+
"@stylistic/padding-line-between-statements": "off", // Вообще шикарное правило, нужно долго настраивать, но мне лень
|
|
149
|
+
"@stylistic/quote-props": ["error", "as-needed"],
|
|
150
|
+
"@stylistic/quotes": ["error", "double"],
|
|
151
|
+
"@stylistic/rest-spread-spacing": ["error", "never"],
|
|
152
|
+
"@stylistic/semi": "error",
|
|
153
|
+
"@stylistic/semi-spacing": "error",
|
|
154
|
+
"@stylistic/semi-style": "error",
|
|
155
|
+
"@stylistic/space-before-blocks": "error",
|
|
156
|
+
"@stylistic/space-before-function-paren": ["error", {
|
|
157
|
+
anonymous: "always", // function () {}
|
|
158
|
+
named: "never", // function foo() {}
|
|
159
|
+
asyncArrow: "always", // async () => {}
|
|
160
|
+
}],
|
|
161
|
+
"@stylistic/space-in-parens": ["error", "never"],
|
|
162
|
+
"@stylistic/space-infix-ops": "error",
|
|
163
|
+
"@stylistic/space-unary-ops": "error",
|
|
164
|
+
"@stylistic/spaced-comment": "error",
|
|
165
|
+
"@stylistic/switch-colon-spacing": "error",
|
|
166
|
+
"@stylistic/template-curly-spacing": "error",
|
|
167
|
+
"@stylistic/template-tag-spacing": ["error", "never"],
|
|
168
|
+
"@stylistic/type-annotation-spacing": "error",
|
|
169
|
+
"@stylistic/type-generic-spacing": ["error", { before: false, after: false }], // foo<T>()
|
|
170
|
+
"@stylistic/type-named-tuple-spacing": "error",
|
|
171
|
+
"@stylistic/wrap-iife": ["error", "inside"],
|
|
172
|
+
"@stylistic/wrap-regex": "off",
|
|
173
|
+
"@stylistic/yield-star-spacing": "error",
|
|
174
|
+
};
|
|
149
175
|
};
|
package/dist/rules/typescript.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Linter } from "eslint";
|
|
2
1
|
export const typescriptRules = {
|
|
3
2
|
// TypeScript знает лучше
|
|
4
3
|
"constructor-super": "off",
|
|
@@ -49,6 +48,7 @@ export const typescriptRules = {
|
|
|
49
48
|
"@typescript-eslint/no-explicit-any": "error",
|
|
50
49
|
"@typescript-eslint/no-extra-non-null-assertion": "error",
|
|
51
50
|
"@typescript-eslint/no-extraneous-class": "off",
|
|
51
|
+
"@typescript-eslint/no-generated-empty-object-type": "error",
|
|
52
52
|
"@typescript-eslint/no-import-type-side-effects": "off", // есть import/consistent-type-specifier-style
|
|
53
53
|
"@typescript-eslint/no-inferrable-types": "error",
|
|
54
54
|
"@typescript-eslint/no-invalid-this": "off", // есть no-invalid-this
|
|
@@ -109,38 +109,31 @@ export const typescriptTypeAwareRules = {
|
|
|
109
109
|
"id-length": "off",
|
|
110
110
|
"no-underscore-dangle": "off",
|
|
111
111
|
camelcase: "off",
|
|
112
|
-
"@typescript-eslint/naming-convention": ["error",
|
|
113
|
-
{
|
|
112
|
+
"@typescript-eslint/naming-convention": ["error", {
|
|
114
113
|
selector: "default",
|
|
115
114
|
format: null,
|
|
116
115
|
leadingUnderscore: "allowSingleOrDouble",
|
|
117
|
-
},
|
|
118
|
-
{
|
|
116
|
+
}, {
|
|
119
117
|
selector: ["variableLike", "import"],
|
|
120
118
|
format: ["camelCase", "PascalCase"],
|
|
121
119
|
leadingUnderscore: "allowSingleOrDouble",
|
|
122
|
-
},
|
|
123
|
-
{
|
|
120
|
+
}, {
|
|
124
121
|
selector: ["method", "classProperty", "typeProperty"],
|
|
125
122
|
format: ["camelCase"],
|
|
126
123
|
leadingUnderscore: "allowSingleOrDouble",
|
|
127
|
-
},
|
|
128
|
-
{
|
|
124
|
+
}, {
|
|
129
125
|
selector: ["typeLike", "enumMember"],
|
|
130
126
|
format: ["PascalCase"],
|
|
131
127
|
leadingUnderscore: "forbid",
|
|
132
|
-
},
|
|
133
|
-
{
|
|
128
|
+
}, {
|
|
134
129
|
selector: "variable",
|
|
135
130
|
modifiers: ["const", "global"],
|
|
136
131
|
format: ["UPPER_CASE", "camelCase", "PascalCase"],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
132
|
+
}, {
|
|
139
133
|
selector: "variable",
|
|
140
134
|
modifiers: ["destructured"],
|
|
141
135
|
format: null, // const { user_id, created_at } = await response.json();
|
|
142
|
-
},
|
|
143
|
-
],
|
|
136
|
+
}],
|
|
144
137
|
"@typescript-eslint/no-array-delete": "error",
|
|
145
138
|
"@typescript-eslint/no-base-to-string": "error",
|
|
146
139
|
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
@@ -178,7 +171,7 @@ export const typescriptTypeAwareRules = {
|
|
|
178
171
|
"@typescript-eslint/non-nullable-type-assertion-style": "error",
|
|
179
172
|
"no-throw-literal": "off",
|
|
180
173
|
"@typescript-eslint/only-throw-error": ["error", {
|
|
181
|
-
allowRethrowing: true
|
|
174
|
+
allowRethrowing: true,
|
|
182
175
|
}],
|
|
183
176
|
"prefer-destructuring": "off",
|
|
184
177
|
"@typescript-eslint/prefer-destructuring": ["error", { array: true, object: false }],
|
package/package.json
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@xaliksss/eslint-config",
|
|
3
|
-
"version": "
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "Xaliks",
|
|
8
|
-
"url": "https://github.com/Xaliks"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/Xaliks/eslint-config.git"
|
|
13
|
-
},
|
|
14
|
-
"files": [
|
|
15
|
-
"dist"
|
|
16
|
-
],
|
|
17
|
-
"exports": {
|
|
18
|
-
".": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"build": "tsc"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
"eslint": "
|
|
27
|
-
"eslint
|
|
28
|
-
"eslint-plugin-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@xaliksss/eslint-config",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Xaliks",
|
|
8
|
+
"url": "https://github.com/Xaliks"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/Xaliks/eslint-config.git"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"inspect": "npx @eslint/config-inspector@latest"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@stylistic/eslint-plugin": "6.0.0-beta.6",
|
|
27
|
+
"eslint": "10.11.0",
|
|
28
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
29
|
+
"eslint-plugin-n": "^18.3.0",
|
|
30
|
+
"globals": "17.12.0",
|
|
31
|
+
"typescript-eslint": "8.70.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"jiti": "^2.7.0",
|
|
35
|
+
"typescript": "^6.0.3"
|
|
36
|
+
}
|
|
37
|
+
}
|