@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.
@@ -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
@@ -0,0 +1,9 @@
1
+ export const DEFAULT_CONFIG = {
2
+ ignores: [
3
+ "**/dist/**",
4
+ "**/node_modules/**",
5
+ ],
6
+ jsFiles: ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.jsx"],
7
+ tsFiles: ["**/*.ts", "**/*.mts", "**/*.cts", "**/*.tsx"],
8
+ maxCodeLength: 120,
9
+ };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: import("eslint/config").ConfigObject[];
2
- export default _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
- const IGNORES = [
12
- "**/dist/**",
13
- "**/node_modules/**",
14
- ];
15
- const JS_FILES = ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.jsx"];
16
- const TS_FILES = ["**/*.ts", "**/*.mts", "**/*.cts", "**/*.tsx"];
17
- export default defineConfig({
18
- ignores: IGNORES,
19
- },
20
- // Общие правила для JS и TS
21
- {
22
- files: [...JS_FILES, ...TS_FILES],
23
- languageOptions: {
24
- ecmaVersion: "latest",
25
- sourceType: "module",
26
- globals: {
27
- ...globals.node,
28
- NodeJS: "off",
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
- plugins: {
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
+ }
@@ -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
- "radix": "off",
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
- "strict": "off",
112
+ strict: "off",
113
113
  "symbol-description": "error",
114
114
  "vars-on-top": "error",
115
- "yoda": "error",
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
- "camelcase": "off", // есть naming-convention с более детальной настройкой
120
+ camelcase: "off", // есть naming-convention с более детальной настройкой
121
121
  "capitalized-comments": "off",
122
122
  "class-methods-use-this": "off",
123
- "complexity": "off",
123
+ complexity: "off",
124
124
  "consistent-return": "off",
125
125
  "consistent-this": "off",
126
- "curly": ["error", "multi-line"],
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
- "eqeqeq": "error",
131
+ eqeqeq: "error",
132
132
  "func-name-matching": "error",
133
133
  "func-names": "off",
134
134
  "func-style": ["error", "declaration", { allowArrowFunctions: true }],
@@ -1,2 +1,2 @@
1
- import { Linter } from "eslint";
1
+ import type { Linter } from "eslint";
2
2
  export declare const importRules: Linter.RulesRecord;
@@ -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, considerComments: true }],
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": "error",
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": "error",
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
@@ -1,4 +1,3 @@
1
- import { Linter } from "eslint";
2
1
  export const nRules = {
3
2
  "n/callback-return": "error",
4
3
  "n/exports-style": ["error", "exports"],
@@ -1,2 +1,3 @@
1
+ import type { XaliksConfigOptions } from "../config.js";
1
2
  import type { Linter } from "eslint";
2
- export declare const stylisticRules: Linter.RulesRecord;
3
+ export declare const stylisticRules: (options: XaliksConfigOptions) => Linter.RulesRecord;
@@ -1,149 +1,175 @@
1
- export const stylisticRules = {
2
- "@stylistic/array-bracket-newline": ["error", "consistent"],
3
- "@stylistic/array-bracket-spacing": "error",
4
- "@stylistic/array-element-newline": ["error", "consistent"],
5
- "@stylistic/arrow-parens": "error",
6
- "@stylistic/arrow-spacing": "error",
7
- "@stylistic/block-spacing": "error",
8
- "@stylistic/brace-style": "error",
9
- "@stylistic/comma-dangle": ["error", "always-multiline"],
10
- "@stylistic/comma-spacing": "error",
11
- "@stylistic/comma-style": "error",
12
- "@stylistic/computed-property-spacing": "error",
13
- "@stylistic/curly-newline": ["error", { consistent: true }],
14
- "@stylistic/dot-location": ["error", "property"],
15
- "@stylistic/eol-last": "error",
16
- "@stylistic/function-call-argument-newline": ["error", "consistent"],
17
- "@stylistic/function-call-spacing": "error",
18
- "@stylistic/function-paren-newline": ["error", "consistent"],
19
- "@stylistic/generator-star-spacing": "error",
20
- "@stylistic/implicit-arrow-linebreak": "error",
21
- "@stylistic/indent": ["error", "tab"],
22
- "@stylistic/indent-binary-ops": ["error", 1],
23
- // JSX пока игнорирую. потом сделаю
24
- "@stylistic/jsx-child-element-spacing": "off",
25
- "@stylistic/jsx-closing-bracket-location": "off",
26
- "@stylistic/jsx-closing-tag-location": "off",
27
- "@stylistic/jsx-curly-brace-presence": "off",
28
- "@stylistic/jsx-curly-newline": "off",
29
- "@stylistic/jsx-curly-spacing": "off",
30
- "@stylistic/jsx-equals-spacing": "off",
31
- "@stylistic/jsx-first-prop-new-line": "off",
32
- "@stylistic/jsx-function-call-newline": "off",
33
- "@stylistic/jsx-indent-props": "off",
34
- "@stylistic/jsx-max-props-per-line": "off",
35
- "@stylistic/jsx-newline": "off",
36
- "@stylistic/jsx-one-expression-per-line": "off",
37
- "@stylistic/jsx-pascal-case": "off",
38
- "@stylistic/jsx-props-style": "off",
39
- "@stylistic/jsx-quotes": "off",
40
- "@stylistic/jsx-self-closing-comp": "off",
41
- "@stylistic/jsx-shorthand-boolean": "off",
42
- "@stylistic/jsx-shorthand-fragment": "off",
43
- "@stylistic/jsx-tag-spacing": "off",
44
- "@stylistic/jsx-wrap-multilines": "off",
45
- "@stylistic/key-spacing": "error",
46
- "@stylistic/keyword-spacing": "error",
47
- "@stylistic/line-comment-position": "off", // Без разницы где ставить комментарий
48
- "@stylistic/linebreak-style": ["error", "unix"],
49
- "@stylistic/lines-around-comment": "off", // Без разницы где ставить комментарий
50
- "@stylistic/lines-between-class-members": ["error",
51
- {
52
- enforce: [
53
- { blankLine: "always", prev: "method", next: "method" },
54
- { blankLine: "always", prev: "field", next: "method" },
55
- { blankLine: "always", prev: "method", next: "field" },
56
- ],
57
- },
58
- { exceptAfterOverload: true }
59
- ],
60
- "@stylistic/max-len": ["error", {
61
- code: 120,
62
- tabWidth: 1,
63
- ignoreComments: true,
64
- ignoreTrailingComments: true,
65
- ignoreUrls: true,
66
- ignoreStrings: true,
67
- ignoreTemplateLiterals: true,
68
- ignoreRegExpLiterals: true
69
- }],
70
- "@stylistic/max-statements-per-line": ["error", { max: 1 }],
71
- "@stylistic/member-delimiter-style": ["error", {
72
- multiline: {
73
- delimiter: "semi",
74
- requireLast: true,
75
- },
76
- singleline: {
77
- delimiter: "semi",
78
- requireLast: false,
79
- },
80
- }],
81
- "@stylistic/multiline-comment-style": "off",
82
- "@stylistic/multiline-ternary": "off",
83
- "@stylistic/new-parens": "error",
84
- "@stylistic/newline-per-chained-call": "off",
85
- "@stylistic/no-confusing-arrow": "off",
86
- "@stylistic/no-extra-parens": ["error", "all", {
87
- returnAssign: false, // return (a = b)
88
- nestedBinaryExpressions: false, // (a || b) && c
89
- ternaryOperandBinaryExpressions: false, // (a && b) ? foo : bar;
90
- nestedConditionalExpressions: false, // (a ? b : c) ? d : e
91
- ignoredNodes: [
92
- "ArrowFunctionExpression[body.type=ConditionalExpression]", // x => (a ? b : c)
93
- "SpreadElement[argument.type=ConditionalExpression]", // ...(a ? [1, 2, 3] : []),
94
- "SpreadElement[argument.type=LogicalExpression]", // ...(isSummer && { watermelon: 30 }),
95
- "SpreadElement[argument.type=AwaitExpression]", // ...(await promiseArray)
96
- ],
97
- }],
98
- "@stylistic/no-extra-semi": "error",
99
- "@stylistic/no-floating-decimal": "error",
100
- "@stylistic/no-mixed-operators": ["error", {
101
- groups: [["&&", "||", "?:"]],
102
- allowSamePrecedence: true,
103
- }],
104
- "@stylistic/no-mixed-spaces-and-tabs": "off", // разобраться
105
- "@stylistic/no-multi-spaces": "error",
106
- "@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 1 }],
107
- "@stylistic/no-tabs": "off",
108
- "@stylistic/no-trailing-spaces": ["error", { ignoreComments: true }],
109
- "@stylistic/no-whitespace-before-property": "error",
110
- "@stylistic/nonblock-statement-body-position": "error",
111
- "@stylistic/object-curly-newline": "error",
112
- "@stylistic/object-curly-spacing": ["error", "always"],
113
- "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
114
- "@stylistic/one-var-declaration-per-line": "off",
115
- "@stylistic/operator-linebreak": ["error", "after", {
116
- overrides: {
117
- "?": "before",
118
- ":": "before",
119
- "|": "before",
120
- },
121
- }],
122
- "@stylistic/padded-blocks": ["error", "never"],
123
- "@stylistic/padding-line-between-statements": "off", // Вообще шикарное правило, нужно долго настраивать, но мне лень
124
- "@stylistic/quote-props": ["error", "as-needed"],
125
- "@stylistic/quotes": ["error", "double"],
126
- "@stylistic/rest-spread-spacing": ["error", "never"],
127
- "@stylistic/semi": "error",
128
- "@stylistic/semi-spacing": "error",
129
- "@stylistic/semi-style": "error",
130
- "@stylistic/space-before-blocks": "error",
131
- "@stylistic/space-before-function-paren": ["error", {
132
- anonymous: "always", // function () {}
133
- named: "never", // function foo() {}
134
- asyncArrow: "always", // async () => {}
135
- }],
136
- "@stylistic/space-in-parens": ["error", "never"],
137
- "@stylistic/space-infix-ops": "error",
138
- "@stylistic/space-unary-ops": "error",
139
- "@stylistic/spaced-comment": "error",
140
- "@stylistic/switch-colon-spacing": "error",
141
- "@stylistic/template-curly-spacing": "error",
142
- "@stylistic/template-tag-spacing": ["error", "never"],
143
- "@stylistic/type-annotation-spacing": "error",
144
- "@stylistic/type-generic-spacing": "error",
145
- "@stylistic/type-named-tuple-spacing": "error",
146
- "@stylistic/wrap-iife": ["error", "inside"],
147
- "@stylistic/wrap-regex": "off",
148
- "@stylistic/yield-star-spacing": "error",
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
  };
@@ -1,3 +1,3 @@
1
- import { Linter } from "eslint";
1
+ import type { Linter } from "eslint";
2
2
  export declare const typescriptRules: Linter.RulesRecord;
3
3
  export declare const typescriptTypeAwareRules: Linter.RulesRecord;
@@ -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.0.3",
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
- "license": "MIT",
24
- "dependencies": {
25
- "@stylistic/eslint-plugin": "5.10.0",
26
- "eslint": "10.10.0",
27
- "eslint-plugin-import-x": "^4.17.1",
28
- "eslint-plugin-n": "^18.3.0",
29
- "globals": "17.12.0",
30
- "typescript-eslint": "8.69.0"
31
- },
32
- "devDependencies": {
33
- "typescript": "^6.0.3"
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
+ }