@kouts/eslint-config 3.1.4 → 3.1.6
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.cjs +32 -607
- package/dist/index.d.cts +5 -26
- package/dist/index.d.ts +5 -26
- package/dist/index.js +27 -604
- package/package.json +20 -26
package/dist/index.cjs
CHANGED
|
@@ -2,613 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
var js = require('@eslint/js');
|
|
4
4
|
var pluginHtml = require('eslint-plugin-html');
|
|
5
|
+
var importX = require('eslint-plugin-import-x');
|
|
5
6
|
var pluginPrettier = require('eslint-plugin-prettier/recommended');
|
|
6
7
|
var pluginSimpleImportSort = require('eslint-plugin-simple-import-sort');
|
|
7
|
-
var
|
|
8
|
-
var node_path = require('node:path');
|
|
9
|
-
var gitignoreToMinimatch = require('@humanwhocodes/gitignore-to-minimatch');
|
|
10
|
-
var stylistic = require('@stylistic/eslint-plugin');
|
|
11
|
-
var importX = require('eslint-plugin-import-x');
|
|
12
|
-
var pluginN = require('eslint-plugin-n');
|
|
13
|
-
var pluginPromise = require('eslint-plugin-promise');
|
|
14
|
-
var findUp = require('find-up');
|
|
15
|
-
var globals = require('globals');
|
|
16
|
-
var tseslint = require('typescript-eslint');
|
|
8
|
+
var neostandard = require('neostandard');
|
|
17
9
|
var pluginVitest = require('@vitest/eslint-plugin');
|
|
18
10
|
var pluginVue = require('eslint-plugin-vue');
|
|
19
11
|
|
|
20
|
-
const plugins = {
|
|
21
|
-
"@stylistic": stylistic,
|
|
22
|
-
"import-x": importX,
|
|
23
|
-
n: pluginN,
|
|
24
|
-
promise: pluginPromise,
|
|
25
|
-
// react: pluginReact,
|
|
26
|
-
"typescript-eslint": tseslint
|
|
27
|
-
};
|
|
28
|
-
const base = {
|
|
29
|
-
name: "neostandard/base",
|
|
30
|
-
languageOptions: {
|
|
31
|
-
ecmaVersion: 2022,
|
|
32
|
-
sourceType: "module",
|
|
33
|
-
globals: {
|
|
34
|
-
...globals.es2022,
|
|
35
|
-
...globals.node,
|
|
36
|
-
document: "readonly",
|
|
37
|
-
navigator: "readonly",
|
|
38
|
-
window: "readonly"
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
plugins: {
|
|
42
|
-
n: plugins.n
|
|
43
|
-
},
|
|
44
|
-
rules: {
|
|
45
|
-
"no-var": "warn",
|
|
46
|
-
"object-shorthand": ["warn", "properties"],
|
|
47
|
-
"accessor-pairs": ["error", { setWithoutGet: true, enforceForClassMembers: true }],
|
|
48
|
-
"array-callback-return": [
|
|
49
|
-
"error",
|
|
50
|
-
{
|
|
51
|
-
allowImplicit: false,
|
|
52
|
-
checkForEach: false
|
|
53
|
-
}
|
|
54
|
-
],
|
|
55
|
-
camelcase: [
|
|
56
|
-
"error",
|
|
57
|
-
{
|
|
58
|
-
allow: ["^UNSAFE_"],
|
|
59
|
-
properties: "never",
|
|
60
|
-
ignoreGlobals: true
|
|
61
|
-
}
|
|
62
|
-
],
|
|
63
|
-
"constructor-super": "error",
|
|
64
|
-
curly: ["error", "multi-line"],
|
|
65
|
-
"default-case-last": "error",
|
|
66
|
-
"dot-notation": ["error", { allowKeywords: true }],
|
|
67
|
-
eqeqeq: ["error", "always", { null: "ignore" }],
|
|
68
|
-
"new-cap": ["error", { newIsCap: true, capIsNew: false, properties: true }],
|
|
69
|
-
"no-array-constructor": "error",
|
|
70
|
-
"no-async-promise-executor": "error",
|
|
71
|
-
"no-caller": "error",
|
|
72
|
-
"no-case-declarations": "error",
|
|
73
|
-
"no-class-assign": "error",
|
|
74
|
-
"no-compare-neg-zero": "error",
|
|
75
|
-
"no-cond-assign": "error",
|
|
76
|
-
"no-const-assign": "error",
|
|
77
|
-
"no-constant-condition": ["error", { checkLoops: false }],
|
|
78
|
-
"no-control-regex": "error",
|
|
79
|
-
"no-debugger": "error",
|
|
80
|
-
"no-delete-var": "error",
|
|
81
|
-
"no-dupe-args": "error",
|
|
82
|
-
"no-dupe-class-members": "error",
|
|
83
|
-
"no-dupe-keys": "error",
|
|
84
|
-
"no-duplicate-case": "error",
|
|
85
|
-
"no-useless-backreference": "error",
|
|
86
|
-
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
87
|
-
"no-empty-character-class": "error",
|
|
88
|
-
"no-empty-pattern": "error",
|
|
89
|
-
"no-eval": "error",
|
|
90
|
-
"no-ex-assign": "error",
|
|
91
|
-
"no-extend-native": "error",
|
|
92
|
-
"no-extra-bind": "error",
|
|
93
|
-
"no-extra-boolean-cast": "error",
|
|
94
|
-
"no-fallthrough": "error",
|
|
95
|
-
"no-func-assign": "error",
|
|
96
|
-
"no-global-assign": "error",
|
|
97
|
-
"no-implied-eval": "error",
|
|
98
|
-
"no-import-assign": "error",
|
|
99
|
-
"no-invalid-regexp": "error",
|
|
100
|
-
"no-irregular-whitespace": "error",
|
|
101
|
-
"no-iterator": "error",
|
|
102
|
-
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
103
|
-
"no-lone-blocks": "error",
|
|
104
|
-
"no-loss-of-precision": "error",
|
|
105
|
-
"no-misleading-character-class": "error",
|
|
106
|
-
"no-prototype-builtins": "error",
|
|
107
|
-
"no-useless-catch": "error",
|
|
108
|
-
"no-multi-str": "error",
|
|
109
|
-
"no-new": "error",
|
|
110
|
-
"no-new-func": "error",
|
|
111
|
-
"no-object-constructor": "error",
|
|
112
|
-
"no-new-native-nonconstructor": "error",
|
|
113
|
-
"no-new-wrappers": "error",
|
|
114
|
-
"no-obj-calls": "error",
|
|
115
|
-
"no-octal": "error",
|
|
116
|
-
"no-octal-escape": "error",
|
|
117
|
-
"no-proto": "error",
|
|
118
|
-
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
119
|
-
"no-regex-spaces": "error",
|
|
120
|
-
"no-return-assign": ["error", "except-parens"],
|
|
121
|
-
"no-self-assign": ["error", { props: true }],
|
|
122
|
-
"no-self-compare": "error",
|
|
123
|
-
"no-sequences": "error",
|
|
124
|
-
"no-shadow-restricted-names": "error",
|
|
125
|
-
"no-sparse-arrays": "error",
|
|
126
|
-
"no-template-curly-in-string": "error",
|
|
127
|
-
"no-this-before-super": "error",
|
|
128
|
-
"no-throw-literal": "error",
|
|
129
|
-
"no-undef": "error",
|
|
130
|
-
"no-undef-init": "error",
|
|
131
|
-
"no-unexpected-multiline": "error",
|
|
132
|
-
"no-unmodified-loop-condition": "error",
|
|
133
|
-
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
134
|
-
"no-unreachable": "error",
|
|
135
|
-
"no-unreachable-loop": "error",
|
|
136
|
-
"no-unsafe-finally": "error",
|
|
137
|
-
"no-unsafe-negation": "error",
|
|
138
|
-
"no-unused-expressions": [
|
|
139
|
-
"error",
|
|
140
|
-
{
|
|
141
|
-
allowShortCircuit: true,
|
|
142
|
-
allowTernary: true,
|
|
143
|
-
allowTaggedTemplates: true
|
|
144
|
-
}
|
|
145
|
-
],
|
|
146
|
-
"no-unused-vars": [
|
|
147
|
-
"error",
|
|
148
|
-
{
|
|
149
|
-
args: "none",
|
|
150
|
-
caughtErrors: "none",
|
|
151
|
-
ignoreRestSiblings: true,
|
|
152
|
-
vars: "all"
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
"no-use-before-define": ["error", { functions: false, classes: false, variables: false }],
|
|
156
|
-
"no-useless-call": "error",
|
|
157
|
-
"no-useless-computed-key": "error",
|
|
158
|
-
"no-useless-constructor": "error",
|
|
159
|
-
"no-useless-escape": "error",
|
|
160
|
-
"no-useless-rename": "error",
|
|
161
|
-
"no-useless-return": "error",
|
|
162
|
-
"no-void": "error",
|
|
163
|
-
"no-with": "error",
|
|
164
|
-
"one-var": ["error", { initialized: "never" }],
|
|
165
|
-
"prefer-const": ["error", { destructuring: "all" }],
|
|
166
|
-
"prefer-promise-reject-errors": "error",
|
|
167
|
-
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
168
|
-
"symbol-description": "error",
|
|
169
|
-
"unicode-bom": ["error", "never"],
|
|
170
|
-
"use-isnan": [
|
|
171
|
-
"error",
|
|
172
|
-
{
|
|
173
|
-
enforceForSwitchCase: true,
|
|
174
|
-
enforceForIndexOf: true
|
|
175
|
-
}
|
|
176
|
-
],
|
|
177
|
-
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
178
|
-
yoda: ["error", "never"],
|
|
179
|
-
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
180
|
-
"n/no-callback-literal": "error",
|
|
181
|
-
"n/no-deprecated-api": "error",
|
|
182
|
-
"n/no-exports-assign": "error",
|
|
183
|
-
"n/no-new-require": "error",
|
|
184
|
-
"n/no-path-concat": "error",
|
|
185
|
-
"n/process-exit-as-throw": "error",
|
|
186
|
-
"promise/param-names": "error"
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const modernization = {
|
|
190
|
-
name: "neostandard/modernization-since-standard-17",
|
|
191
|
-
rules: {
|
|
192
|
-
"dot-notation": "off",
|
|
193
|
-
"n/no-deprecated-api": "warn"
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
const promiseConfigs = [pluginPromise.configs["flat/recommended"]];
|
|
197
|
-
const modernizationStyles = {
|
|
198
|
-
name: "neostandard/style/modernization-since-standard-17",
|
|
199
|
-
rules: {
|
|
200
|
-
"@stylistic/comma-dangle": [
|
|
201
|
-
"warn",
|
|
202
|
-
{
|
|
203
|
-
arrays: "ignore",
|
|
204
|
-
enums: "ignore",
|
|
205
|
-
exports: "ignore",
|
|
206
|
-
imports: "ignore",
|
|
207
|
-
objects: "ignore"
|
|
208
|
-
}
|
|
209
|
-
],
|
|
210
|
-
"@stylistic/no-multi-spaces": ["error", { ignoreEOLComments: true }]
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
const style = {
|
|
214
|
-
name: "neostandard/style",
|
|
215
|
-
plugins: {
|
|
216
|
-
"@stylistic": plugins["@stylistic"]
|
|
217
|
-
},
|
|
218
|
-
rules: {
|
|
219
|
-
"@stylistic/array-bracket-spacing": ["error", "never"],
|
|
220
|
-
"@stylistic/arrow-spacing": ["error", { before: true, after: true }],
|
|
221
|
-
"@stylistic/block-spacing": ["error", "always"],
|
|
222
|
-
"@stylistic/brace-style": ["error", "1tbs", { allowSingleLine: true }],
|
|
223
|
-
"@stylistic/comma-dangle": [
|
|
224
|
-
"error",
|
|
225
|
-
{
|
|
226
|
-
arrays: "never",
|
|
227
|
-
objects: "never",
|
|
228
|
-
imports: "never",
|
|
229
|
-
exports: "never",
|
|
230
|
-
functions: "never"
|
|
231
|
-
}
|
|
232
|
-
],
|
|
233
|
-
"@stylistic/comma-spacing": ["error", { before: false, after: true }],
|
|
234
|
-
"@stylistic/comma-style": ["error", "last"],
|
|
235
|
-
"@stylistic/computed-property-spacing": ["error", "never", { enforceForClassMembers: true }],
|
|
236
|
-
"@stylistic/dot-location": ["error", "property"],
|
|
237
|
-
"@stylistic/eol-last": "error",
|
|
238
|
-
"@stylistic/function-call-spacing": ["error", "never"],
|
|
239
|
-
"@stylistic/generator-star-spacing": ["error", { before: true, after: true }],
|
|
240
|
-
"@stylistic/indent": [
|
|
241
|
-
"error",
|
|
242
|
-
2,
|
|
243
|
-
{
|
|
244
|
-
SwitchCase: 1,
|
|
245
|
-
VariableDeclarator: 1,
|
|
246
|
-
outerIIFEBody: 1,
|
|
247
|
-
MemberExpression: 1,
|
|
248
|
-
FunctionDeclaration: { parameters: 1, body: 1 },
|
|
249
|
-
FunctionExpression: { parameters: 1, body: 1 },
|
|
250
|
-
CallExpression: { arguments: 1 },
|
|
251
|
-
ArrayExpression: 1,
|
|
252
|
-
ObjectExpression: 1,
|
|
253
|
-
ImportDeclaration: 1,
|
|
254
|
-
flatTernaryExpressions: false,
|
|
255
|
-
ignoreComments: false,
|
|
256
|
-
ignoredNodes: ["TemplateLiteral *"],
|
|
257
|
-
offsetTernaryExpressions: { CallExpression: false, AwaitExpression: false, NewExpression: false }
|
|
258
|
-
}
|
|
259
|
-
],
|
|
260
|
-
"@stylistic/key-spacing": ["error", { beforeColon: false, afterColon: true }],
|
|
261
|
-
"@stylistic/keyword-spacing": ["error", { before: true, after: true }],
|
|
262
|
-
"@stylistic/lines-between-class-members": ["error", "always", { exceptAfterSingleLine: true }],
|
|
263
|
-
"@stylistic/multiline-ternary": ["error", "always-multiline"],
|
|
264
|
-
"@stylistic/new-parens": "error",
|
|
265
|
-
"@stylistic/no-extra-parens": ["error", "functions"],
|
|
266
|
-
"@stylistic/no-floating-decimal": "error",
|
|
267
|
-
"@stylistic/no-mixed-operators": [
|
|
268
|
-
"error",
|
|
269
|
-
{
|
|
270
|
-
groups: [
|
|
271
|
-
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
|
|
272
|
-
["&&", "||"],
|
|
273
|
-
["in", "instanceof"]
|
|
274
|
-
],
|
|
275
|
-
allowSamePrecedence: true
|
|
276
|
-
}
|
|
277
|
-
],
|
|
278
|
-
"@stylistic/no-mixed-spaces-and-tabs": "error",
|
|
279
|
-
"@stylistic/no-multi-spaces": "error",
|
|
280
|
-
"@stylistic/no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 0 }],
|
|
281
|
-
"@stylistic/no-tabs": "error",
|
|
282
|
-
"@stylistic/no-trailing-spaces": "error",
|
|
283
|
-
"@stylistic/no-whitespace-before-property": "error",
|
|
284
|
-
"@stylistic/object-curly-newline": ["error", { multiline: true, consistent: true }],
|
|
285
|
-
"@stylistic/object-curly-spacing": ["error", "always"],
|
|
286
|
-
"@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
|
|
287
|
-
"@stylistic/operator-linebreak": ["error", "after", { overrides: { "?": "before", ":": "before", "|>": "before" } }],
|
|
288
|
-
"@stylistic/padded-blocks": ["error", { blocks: "never", switches: "never", classes: "never" }],
|
|
289
|
-
"@stylistic/quote-props": ["error", "as-needed"],
|
|
290
|
-
"@stylistic/quotes": ["error", "single", { avoidEscape: true, allowTemplateLiterals: "never" }],
|
|
291
|
-
"@stylistic/rest-spread-spacing": ["error", "never"],
|
|
292
|
-
"@stylistic/semi": ["error", "never"],
|
|
293
|
-
"@stylistic/semi-spacing": ["error", { before: false, after: true }],
|
|
294
|
-
"@stylistic/space-before-blocks": ["error", "always"],
|
|
295
|
-
"@stylistic/space-before-function-paren": ["error", "always"],
|
|
296
|
-
"@stylistic/space-in-parens": ["error", "never"],
|
|
297
|
-
"@stylistic/space-infix-ops": "error",
|
|
298
|
-
"@stylistic/space-unary-ops": ["error", { words: true, nonwords: false }],
|
|
299
|
-
"@stylistic/spaced-comment": [
|
|
300
|
-
"error",
|
|
301
|
-
"always",
|
|
302
|
-
{
|
|
303
|
-
line: { markers: ["*package", "!", "/", ",", "="] },
|
|
304
|
-
block: { balanced: true, markers: ["*package", "!", ",", ":", "::", "flow-include"], exceptions: ["*"] }
|
|
305
|
-
}
|
|
306
|
-
],
|
|
307
|
-
"@stylistic/template-curly-spacing": ["error", "never"],
|
|
308
|
-
"@stylistic/template-tag-spacing": ["error", "never"],
|
|
309
|
-
"@stylistic/wrap-iife": ["error", "any", { functionPrototypeMethods: true }],
|
|
310
|
-
"@stylistic/yield-star-spacing": ["error", "both"]
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
const jsxIgnores = ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.ts"];
|
|
314
|
-
const jsx = {
|
|
315
|
-
name: "neostandard/jsx",
|
|
316
|
-
ignores: [...jsxIgnores],
|
|
317
|
-
languageOptions: {
|
|
318
|
-
parserOptions: {
|
|
319
|
-
ecmaFeatures: {
|
|
320
|
-
jsx: true
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
/*
|
|
325
|
-
* React support is temporarily disabled.
|
|
326
|
-
* plugins: {
|
|
327
|
-
* react: plugins.react,
|
|
328
|
-
* },
|
|
329
|
-
* settings: {
|
|
330
|
-
* react: {
|
|
331
|
-
* version: '17',
|
|
332
|
-
* },
|
|
333
|
-
* linkComponents: ['Link'],
|
|
334
|
-
* },
|
|
335
|
-
* rules: {
|
|
336
|
-
* 'react/jsx-boolean-value': 'error',
|
|
337
|
-
* 'react/jsx-fragments': ['error', 'syntax'],
|
|
338
|
-
* 'react/jsx-handler-names': 'error',
|
|
339
|
-
* 'react/jsx-key': [
|
|
340
|
-
* 'error',
|
|
341
|
-
* {
|
|
342
|
-
* checkFragmentShorthand: true,
|
|
343
|
-
* },
|
|
344
|
-
* ],
|
|
345
|
-
* 'react/jsx-no-comment-textnodes': 'error',
|
|
346
|
-
* 'react/jsx-no-duplicate-props': 'error',
|
|
347
|
-
* 'react/jsx-no-target-blank': ['error', { enforceDynamicLinks: 'always' }],
|
|
348
|
-
* 'react/jsx-no-undef': ['error', { allowGlobals: true }],
|
|
349
|
-
* 'react/jsx-uses-react': 'error',
|
|
350
|
-
* 'react/jsx-uses-vars': 'error',
|
|
351
|
-
* 'react/no-children-prop': 'error',
|
|
352
|
-
* 'react/no-danger-with-children': 'error',
|
|
353
|
-
* 'react/no-deprecated': 'error',
|
|
354
|
-
* 'react/no-direct-mutation-state': 'error',
|
|
355
|
-
* 'react/no-find-dom-node': 'error',
|
|
356
|
-
* 'react/no-is-mounted': 'error',
|
|
357
|
-
* 'react/no-string-refs': [
|
|
358
|
-
* 'error',
|
|
359
|
-
* {
|
|
360
|
-
* noTemplateLiterals: true,
|
|
361
|
-
* },
|
|
362
|
-
* ],
|
|
363
|
-
* 'react/no-unescaped-entities': [
|
|
364
|
-
* 'error',
|
|
365
|
-
* {
|
|
366
|
-
* forbid: ['>', '}'],
|
|
367
|
-
* },
|
|
368
|
-
* ],
|
|
369
|
-
* 'react/no-render-return-value': 'error',
|
|
370
|
-
* 'react/require-render-return': 'error',
|
|
371
|
-
* 'react/self-closing-comp': 'error',
|
|
372
|
-
* },
|
|
373
|
-
*/
|
|
374
|
-
};
|
|
375
|
-
const jsxStyles = {
|
|
376
|
-
name: "neostandard/style/jsx",
|
|
377
|
-
ignores: [...jsxIgnores],
|
|
378
|
-
rules: {
|
|
379
|
-
"@stylistic/jsx-quotes": ["error", "prefer-single"],
|
|
380
|
-
"@stylistic/jsx-closing-bracket-location": ["error", "tag-aligned"],
|
|
381
|
-
"@stylistic/jsx-closing-tag-location": "error",
|
|
382
|
-
"@stylistic/jsx-curly-brace-presence": [
|
|
383
|
-
"error",
|
|
384
|
-
{
|
|
385
|
-
props: "never",
|
|
386
|
-
children: "never"
|
|
387
|
-
}
|
|
388
|
-
],
|
|
389
|
-
"@stylistic/jsx-curly-newline": [
|
|
390
|
-
"error",
|
|
391
|
-
{
|
|
392
|
-
multiline: "consistent",
|
|
393
|
-
singleline: "consistent"
|
|
394
|
-
}
|
|
395
|
-
],
|
|
396
|
-
"@stylistic/jsx-curly-spacing": [
|
|
397
|
-
"error",
|
|
398
|
-
{
|
|
399
|
-
attributes: { when: "never", allowMultiline: true },
|
|
400
|
-
children: { when: "never", allowMultiline: true }
|
|
401
|
-
}
|
|
402
|
-
],
|
|
403
|
-
"@stylistic/jsx-equals-spacing": ["error", "never"],
|
|
404
|
-
"@stylistic/jsx-first-prop-new-line": ["error", "multiline-multiprop"],
|
|
405
|
-
"@stylistic/jsx-pascal-case": ["error", { allowAllCaps: false }],
|
|
406
|
-
"@stylistic/jsx-props-no-multi-spaces": "error",
|
|
407
|
-
"@stylistic/jsx-tag-spacing": [
|
|
408
|
-
"error",
|
|
409
|
-
{
|
|
410
|
-
closingSlash: "never",
|
|
411
|
-
beforeSelfClosing: "always",
|
|
412
|
-
afterOpening: "never",
|
|
413
|
-
beforeClosing: "never"
|
|
414
|
-
}
|
|
415
|
-
],
|
|
416
|
-
"@stylistic/jsx-wrap-multilines": [
|
|
417
|
-
"error",
|
|
418
|
-
{
|
|
419
|
-
declaration: "parens-new-line",
|
|
420
|
-
assignment: "parens-new-line",
|
|
421
|
-
return: "parens-new-line",
|
|
422
|
-
arrow: "ignore",
|
|
423
|
-
condition: "ignore",
|
|
424
|
-
logical: "ignore",
|
|
425
|
-
prop: "ignore"
|
|
426
|
-
}
|
|
427
|
-
]
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
const semiConfig = {
|
|
431
|
-
name: "neostandard/semi",
|
|
432
|
-
rules: {
|
|
433
|
-
"@stylistic/semi": ["error", "always"],
|
|
434
|
-
"@stylistic/no-extra-semi": "error"
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
const jsImportRules = {
|
|
438
|
-
name: "neostandard/import-x",
|
|
439
|
-
files: ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.jsx"],
|
|
440
|
-
plugins: {
|
|
441
|
-
"import-x": plugins["import-x"]
|
|
442
|
-
},
|
|
443
|
-
rules: {
|
|
444
|
-
"import-x/export": "error",
|
|
445
|
-
"import-x/first": "error",
|
|
446
|
-
"import-x/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
|
|
447
|
-
"import-x/no-duplicates": "error",
|
|
448
|
-
"import-x/no-named-default": "error",
|
|
449
|
-
"import-x/no-webpack-loader-syntax": "error",
|
|
450
|
-
// Custom rules
|
|
451
|
-
"import-x/no-mutable-exports": "error",
|
|
452
|
-
"import-x/newline-after-import": ["error", { count: 1 }],
|
|
453
|
-
"import-x/no-self-import": "error"
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
const isNonEmpty = (value) => Object.keys(value).length > 0;
|
|
457
|
-
const resolveIgnoresFromGitignore = () => {
|
|
458
|
-
const configFile = findFlatConfigFileSync();
|
|
459
|
-
if (!configFile) {
|
|
460
|
-
return [];
|
|
461
|
-
}
|
|
462
|
-
const result = [];
|
|
463
|
-
try {
|
|
464
|
-
const content = node_fs.readFileSync(node_path.join(node_path.dirname(configFile), ".gitignore"), "utf8");
|
|
465
|
-
for (let line of content.split("\n")) {
|
|
466
|
-
line = line.trim();
|
|
467
|
-
if (line && !line.startsWith("#")) {
|
|
468
|
-
result.push(gitignoreToMinimatch.gitignoreToMinimatch(line));
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
} catch {
|
|
472
|
-
}
|
|
473
|
-
return result;
|
|
474
|
-
};
|
|
475
|
-
function findFlatConfigFileSync() {
|
|
476
|
-
return findUp.findUpSync([
|
|
477
|
-
"eslint.config.js",
|
|
478
|
-
"eslint.config.mjs",
|
|
479
|
-
"eslint.config.cjs",
|
|
480
|
-
"eslint.config.ts",
|
|
481
|
-
"eslint.config.mts",
|
|
482
|
-
"eslint.config.cts"
|
|
483
|
-
]);
|
|
484
|
-
}
|
|
485
|
-
function typescriptify(configs, options) {
|
|
486
|
-
const { files, ignores, name, project, tsconfigRootDir, typeChecking = false } = options;
|
|
487
|
-
const deactivatedRules = {};
|
|
488
|
-
const replacementRules = {};
|
|
489
|
-
const tsPlugin = tseslint.plugin;
|
|
490
|
-
for (const config of configs) {
|
|
491
|
-
for (const ruleId of Object.keys(tsRedundant)) {
|
|
492
|
-
if (config.rules?.[ruleId]) {
|
|
493
|
-
deactivatedRules[ruleId] = "off";
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
for (const [ruleId, ruleDefinition] of Object.entries(tsPlugin.rules)) {
|
|
497
|
-
const currentRule = config.rules?.[ruleId];
|
|
498
|
-
if (currentRule === void 0) {
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
if (!ruleDefinition.meta?.docs || typeof ruleDefinition.meta.docs !== "object") {
|
|
502
|
-
continue;
|
|
503
|
-
}
|
|
504
|
-
const docs = ruleDefinition.meta.docs;
|
|
505
|
-
if (!docs.extendsBaseRule) {
|
|
506
|
-
continue;
|
|
507
|
-
}
|
|
508
|
-
if (docs.requiresTypeChecking && !typeChecking) {
|
|
509
|
-
continue;
|
|
510
|
-
}
|
|
511
|
-
deactivatedRules[ruleId] = "off";
|
|
512
|
-
if (ruleId !== "dot-notation") {
|
|
513
|
-
replacementRules[`@typescript-eslint/${ruleId}`] = currentRule;
|
|
514
|
-
}
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
return {
|
|
518
|
-
...name ? { name } : {},
|
|
519
|
-
...files ? { files } : {},
|
|
520
|
-
...ignores ? { ignores } : {},
|
|
521
|
-
languageOptions: {
|
|
522
|
-
parser: tseslint.parser,
|
|
523
|
-
parserOptions: {
|
|
524
|
-
project: project === void 0 ? typeChecking : project,
|
|
525
|
-
...tsconfigRootDir ? { tsconfigRootDir } : {}
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
plugins: {
|
|
529
|
-
"@typescript-eslint": tseslint.plugin
|
|
530
|
-
},
|
|
531
|
-
rules: {
|
|
532
|
-
...deactivatedRules,
|
|
533
|
-
...replacementRules
|
|
534
|
-
}
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
const tsRedundant = {
|
|
538
|
-
"getter-return": "off",
|
|
539
|
-
"constructor-super": "off",
|
|
540
|
-
"no-const-assign": "off",
|
|
541
|
-
"no-dupe-args": "off",
|
|
542
|
-
"no-dupe-class-members": "off",
|
|
543
|
-
"no-dupe-keys": "off",
|
|
544
|
-
"no-func-assign": "off",
|
|
545
|
-
"no-import-assign": "off",
|
|
546
|
-
"no-new-native-nonconstructor": "off",
|
|
547
|
-
"no-obj-calls": "off",
|
|
548
|
-
"no-redeclare": "off",
|
|
549
|
-
"no-setter-return": "off",
|
|
550
|
-
"no-this-before-super": "off",
|
|
551
|
-
"no-undef": "off",
|
|
552
|
-
"no-unreachable": "off",
|
|
553
|
-
"no-unsafe-negation": "off"
|
|
554
|
-
};
|
|
555
|
-
const getJsConfigs = (opts) => {
|
|
556
|
-
const jsxConfigs = opts.noJsx ? [] : [jsx, ...opts.noStyle ? [] : [jsxStyles]];
|
|
557
|
-
const styleConfigs = opts.noStyle ? [] : [style, modernizationStyles, ...opts.semi ? [semiConfig] : []];
|
|
558
|
-
return [...promiseConfigs, base, modernization, ...jsxConfigs, ...styleConfigs, jsImportRules];
|
|
559
|
-
};
|
|
560
|
-
const neostandard = (options) => {
|
|
561
|
-
const {
|
|
562
|
-
env,
|
|
563
|
-
files: rawFiles,
|
|
564
|
-
filesTs,
|
|
565
|
-
globals: rawGlobals,
|
|
566
|
-
ignores,
|
|
567
|
-
noJsx = false,
|
|
568
|
-
noStyle = false,
|
|
569
|
-
ts = false,
|
|
570
|
-
semi = false
|
|
571
|
-
} = options || {};
|
|
572
|
-
if (filesTs && !ts) {
|
|
573
|
-
throw new Error('"filesTs" is only usable with the "ts" option');
|
|
574
|
-
}
|
|
575
|
-
const resolvedGlobals = Array.isArray(rawGlobals) ? Object.fromEntries(rawGlobals.map((global) => [global, true])) : { ...rawGlobals };
|
|
576
|
-
for (const key of env || []) {
|
|
577
|
-
if (!globals[key]) {
|
|
578
|
-
throw new Error(`Invalid env definition: ${env}`);
|
|
579
|
-
}
|
|
580
|
-
const envGlobals = globals[key];
|
|
581
|
-
for (const [name, value] of Object.entries(envGlobals)) {
|
|
582
|
-
resolvedGlobals[name] = resolvedGlobals[name] || value;
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
const files = [...rawFiles || [], ...noJsx ? [] : ["**/*.jsx"]];
|
|
586
|
-
const jsConfigs = getJsConfigs({ noJsx, noStyle, semi });
|
|
587
|
-
return [
|
|
588
|
-
...ignores ? [{ ignores }] : [],
|
|
589
|
-
...files.length ? [
|
|
590
|
-
{
|
|
591
|
-
name: "neostandard/additional-files",
|
|
592
|
-
files
|
|
593
|
-
}
|
|
594
|
-
] : [],
|
|
595
|
-
...isNonEmpty(resolvedGlobals) ? [
|
|
596
|
-
{
|
|
597
|
-
name: "neostandard/globals",
|
|
598
|
-
languageOptions: { globals: resolvedGlobals }
|
|
599
|
-
}
|
|
600
|
-
] : [],
|
|
601
|
-
...jsConfigs,
|
|
602
|
-
...ts ? [
|
|
603
|
-
typescriptify(jsConfigs, {
|
|
604
|
-
files: ["**/*.ts", ...noJsx ? [] : ["**/*.tsx"], ...filesTs || []],
|
|
605
|
-
ignores: [...ignores || [], "**/*.md/**"],
|
|
606
|
-
name: "neostandard/ts"
|
|
607
|
-
})
|
|
608
|
-
] : []
|
|
609
|
-
];
|
|
610
|
-
};
|
|
611
|
-
|
|
612
12
|
const rule = {
|
|
613
13
|
meta: {
|
|
614
14
|
type: "suggestion",
|
|
@@ -658,7 +58,7 @@ var customRules = {
|
|
|
658
58
|
};
|
|
659
59
|
|
|
660
60
|
const typescript = [
|
|
661
|
-
...plugins["typescript-eslint"].configs.recommended,
|
|
61
|
+
...neostandard.plugins["typescript-eslint"].configs.recommended,
|
|
662
62
|
{
|
|
663
63
|
name: "kouts/typescript",
|
|
664
64
|
rules: {
|
|
@@ -733,7 +133,7 @@ const vue = (options) => {
|
|
|
733
133
|
const languageOptions = opts.ts ? {
|
|
734
134
|
languageOptions: {
|
|
735
135
|
parserOptions: {
|
|
736
|
-
parser: plugins["typescript-eslint"].parser
|
|
136
|
+
parser: neostandard.plugins["typescript-eslint"].parser
|
|
737
137
|
}
|
|
738
138
|
}
|
|
739
139
|
} : {};
|
|
@@ -789,6 +189,8 @@ const vue = (options) => {
|
|
|
789
189
|
};
|
|
790
190
|
|
|
791
191
|
const customRulesPlugin = { name: "kouts", rules: customRules };
|
|
192
|
+
const defaultEnvironments = ["node", "browser"];
|
|
193
|
+
const defaultFiles = ["**/*.vue"];
|
|
792
194
|
const config = (options) => {
|
|
793
195
|
const opts = {
|
|
794
196
|
noJsx: true,
|
|
@@ -798,7 +200,9 @@ const config = (options) => {
|
|
|
798
200
|
vue: true,
|
|
799
201
|
vueVersion: 3,
|
|
800
202
|
vitest: true,
|
|
801
|
-
...options
|
|
203
|
+
...options,
|
|
204
|
+
env: [.../* @__PURE__ */ new Set([...defaultEnvironments, ...options?.env || []])],
|
|
205
|
+
files: [.../* @__PURE__ */ new Set([...defaultFiles, ...options?.files || []])]
|
|
802
206
|
};
|
|
803
207
|
const linterConfig = [
|
|
804
208
|
// Custom rules plugin
|
|
@@ -817,7 +221,7 @@ const config = (options) => {
|
|
|
817
221
|
"vendor/**",
|
|
818
222
|
"dist/**",
|
|
819
223
|
"public/**",
|
|
820
|
-
...resolveIgnoresFromGitignore()
|
|
224
|
+
...neostandard.resolveIgnoresFromGitignore()
|
|
821
225
|
]
|
|
822
226
|
},
|
|
823
227
|
// JavaScript
|
|
@@ -829,6 +233,24 @@ const config = (options) => {
|
|
|
829
233
|
...opts.ts ? typescript : [],
|
|
830
234
|
// Neostandard
|
|
831
235
|
...neostandard(opts),
|
|
236
|
+
{
|
|
237
|
+
name: "kouts/import-x",
|
|
238
|
+
files: ["**/*.js", "**/*.mjs", "**/*.cjs", "**/*.jsx"],
|
|
239
|
+
plugins: {
|
|
240
|
+
"import-x": importX
|
|
241
|
+
},
|
|
242
|
+
rules: {
|
|
243
|
+
"import-x/export": "error",
|
|
244
|
+
"import-x/first": "error",
|
|
245
|
+
"import-x/no-absolute-path": ["error", { esmodule: true, commonjs: true, amd: false }],
|
|
246
|
+
"import-x/no-duplicates": "error",
|
|
247
|
+
"import-x/no-named-default": "error",
|
|
248
|
+
"import-x/no-webpack-loader-syntax": "error",
|
|
249
|
+
"import-x/no-mutable-exports": "error",
|
|
250
|
+
"import-x/newline-after-import": ["error", { count: 1 }],
|
|
251
|
+
"import-x/no-self-import": "error"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
832
254
|
{
|
|
833
255
|
name: "kouts/neostandard-overrides",
|
|
834
256
|
rules: {
|
|
@@ -886,5 +308,8 @@ const config = (options) => {
|
|
|
886
308
|
return linterConfig;
|
|
887
309
|
};
|
|
888
310
|
|
|
311
|
+
Object.defineProperty(exports, "plugins", {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
get: function () { return neostandard.plugins; }
|
|
314
|
+
});
|
|
889
315
|
exports.config = config;
|
|
890
|
-
exports.plugins = plugins;
|