@cany748/eslint-config 3.0.3 → 3.0.5
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.d.ts +661 -507
- package/dist/index.js +106 -77
- package/package.json +36 -38
- package/dist/index.cjs +0 -1323
- package/dist/index.d.cts +0 -10765
package/dist/index.cjs
DELETED
|
@@ -1,1323 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/index.ts
|
|
31
|
-
var src_exports = {};
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
GLOB_ALL_SRC: () => GLOB_ALL_SRC,
|
|
34
|
-
GLOB_ASTRO: () => GLOB_ASTRO,
|
|
35
|
-
GLOB_ASTRO_TS: () => GLOB_ASTRO_TS,
|
|
36
|
-
GLOB_CSS: () => GLOB_CSS,
|
|
37
|
-
GLOB_EXCLUDE: () => GLOB_EXCLUDE,
|
|
38
|
-
GLOB_GRAPHQL: () => GLOB_GRAPHQL,
|
|
39
|
-
GLOB_HTML: () => GLOB_HTML,
|
|
40
|
-
GLOB_JS: () => GLOB_JS,
|
|
41
|
-
GLOB_JSON: () => GLOB_JSON,
|
|
42
|
-
GLOB_JSON5: () => GLOB_JSON5,
|
|
43
|
-
GLOB_JSONC: () => GLOB_JSONC,
|
|
44
|
-
GLOB_JSX: () => GLOB_JSX,
|
|
45
|
-
GLOB_LESS: () => GLOB_LESS,
|
|
46
|
-
GLOB_MARKDOWN: () => GLOB_MARKDOWN,
|
|
47
|
-
GLOB_MARKDOWN_CODE: () => GLOB_MARKDOWN_CODE,
|
|
48
|
-
GLOB_MARKDOWN_IN_MARKDOWN: () => GLOB_MARKDOWN_IN_MARKDOWN,
|
|
49
|
-
GLOB_POSTCSS: () => GLOB_POSTCSS,
|
|
50
|
-
GLOB_SCSS: () => GLOB_SCSS,
|
|
51
|
-
GLOB_SRC: () => GLOB_SRC,
|
|
52
|
-
GLOB_SRC_EXT: () => GLOB_SRC_EXT,
|
|
53
|
-
GLOB_STYLE: () => GLOB_STYLE,
|
|
54
|
-
GLOB_SVELTE: () => GLOB_SVELTE,
|
|
55
|
-
GLOB_TESTS: () => GLOB_TESTS,
|
|
56
|
-
GLOB_TOML: () => GLOB_TOML,
|
|
57
|
-
GLOB_TS: () => GLOB_TS,
|
|
58
|
-
GLOB_TSX: () => GLOB_TSX,
|
|
59
|
-
GLOB_VUE: () => GLOB_VUE,
|
|
60
|
-
GLOB_XML: () => GLOB_XML,
|
|
61
|
-
GLOB_YAML: () => GLOB_YAML,
|
|
62
|
-
combine: () => combine,
|
|
63
|
-
comments: () => comments,
|
|
64
|
-
factoryConfig: () => factoryConfig,
|
|
65
|
-
formatters: () => formatters,
|
|
66
|
-
ignores: () => ignores,
|
|
67
|
-
imports: () => imports,
|
|
68
|
-
interopDefault: () => interopDefault,
|
|
69
|
-
isInEditorEnv: () => isInEditorEnv,
|
|
70
|
-
javascript: () => javascript,
|
|
71
|
-
jsonc: () => jsonc,
|
|
72
|
-
node: () => node,
|
|
73
|
-
parserPlain: () => parserPlain,
|
|
74
|
-
regexp: () => regexp,
|
|
75
|
-
sortPackageJson: () => sortPackageJson,
|
|
76
|
-
sortTsconfig: () => sortTsconfig,
|
|
77
|
-
test: () => test,
|
|
78
|
-
toArray: () => toArray,
|
|
79
|
-
typescript: () => typescript,
|
|
80
|
-
unicorn: () => unicorn,
|
|
81
|
-
unocss: () => unocss,
|
|
82
|
-
vue: () => vue
|
|
83
|
-
});
|
|
84
|
-
module.exports = __toCommonJS(src_exports);
|
|
85
|
-
|
|
86
|
-
// src/configs/comments.ts
|
|
87
|
-
var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
|
|
88
|
-
function comments() {
|
|
89
|
-
return [
|
|
90
|
-
{
|
|
91
|
-
name: "@eslint-community/eslint-comments",
|
|
92
|
-
plugins: {
|
|
93
|
-
"@eslint-community/eslint-comments": import_eslint_plugin_eslint_comments.default
|
|
94
|
-
},
|
|
95
|
-
rules: {
|
|
96
|
-
...import_eslint_plugin_eslint_comments.default.configs.recommended.rules,
|
|
97
|
-
"@eslint-community/eslint-comments/disable-enable-pair": "off"
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
];
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/configs/formatters.ts
|
|
104
|
-
var import_eslint_plugin_prettier = __toESM(require("eslint-plugin-prettier"), 1);
|
|
105
|
-
var import_recommended = __toESM(require("eslint-plugin-prettier/recommended"), 1);
|
|
106
|
-
|
|
107
|
-
// src/globs.ts
|
|
108
|
-
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
109
|
-
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
110
|
-
var GLOB_JS = "**/*.?([cm])js";
|
|
111
|
-
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
112
|
-
var GLOB_TS = "**/*.?([cm])ts";
|
|
113
|
-
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
114
|
-
var GLOB_STYLE = "**/*.{c,le,sc}ss";
|
|
115
|
-
var GLOB_CSS = "**/*.css";
|
|
116
|
-
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
117
|
-
var GLOB_LESS = "**/*.less";
|
|
118
|
-
var GLOB_SCSS = "**/*.scss";
|
|
119
|
-
var GLOB_JSON = "**/*.json";
|
|
120
|
-
var GLOB_JSON5 = "**/*.json5";
|
|
121
|
-
var GLOB_JSONC = "**/*.jsonc";
|
|
122
|
-
var GLOB_MARKDOWN = "**/*.md";
|
|
123
|
-
var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
|
|
124
|
-
var GLOB_SVELTE = "**/*.svelte";
|
|
125
|
-
var GLOB_VUE = "**/*.vue";
|
|
126
|
-
var GLOB_YAML = "**/*.y?(a)ml";
|
|
127
|
-
var GLOB_TOML = "**/*.toml";
|
|
128
|
-
var GLOB_XML = "**/*.xml";
|
|
129
|
-
var GLOB_HTML = "**/*.htm?(l)";
|
|
130
|
-
var GLOB_ASTRO = "**/*.astro";
|
|
131
|
-
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
132
|
-
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
133
|
-
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
134
|
-
var GLOB_TESTS = [
|
|
135
|
-
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
136
|
-
`**/*.spec.${GLOB_SRC_EXT}`,
|
|
137
|
-
`**/*.test.${GLOB_SRC_EXT}`,
|
|
138
|
-
`**/*.bench.${GLOB_SRC_EXT}`,
|
|
139
|
-
`**/*.benchmark.${GLOB_SRC_EXT}`
|
|
140
|
-
];
|
|
141
|
-
var GLOB_ALL_SRC = [
|
|
142
|
-
GLOB_SRC,
|
|
143
|
-
GLOB_STYLE,
|
|
144
|
-
GLOB_JSON,
|
|
145
|
-
GLOB_JSON5,
|
|
146
|
-
GLOB_MARKDOWN,
|
|
147
|
-
GLOB_SVELTE,
|
|
148
|
-
GLOB_VUE,
|
|
149
|
-
GLOB_YAML,
|
|
150
|
-
GLOB_XML,
|
|
151
|
-
GLOB_HTML
|
|
152
|
-
];
|
|
153
|
-
var GLOB_EXCLUDE = [
|
|
154
|
-
"**/node_modules",
|
|
155
|
-
"**/dist",
|
|
156
|
-
"**/build",
|
|
157
|
-
"**/vendor",
|
|
158
|
-
"**/public",
|
|
159
|
-
"**/out",
|
|
160
|
-
"**/package-lock.json",
|
|
161
|
-
"**/yarn.lock",
|
|
162
|
-
"**/pnpm-lock.yaml",
|
|
163
|
-
"**/bun.lockb",
|
|
164
|
-
"**/output",
|
|
165
|
-
"**/coverage",
|
|
166
|
-
"**/temp",
|
|
167
|
-
"**/.temp",
|
|
168
|
-
"**/tmp",
|
|
169
|
-
"**/.tmp",
|
|
170
|
-
"**/.history",
|
|
171
|
-
"**/.vitepress/cache",
|
|
172
|
-
"**/.nuxt",
|
|
173
|
-
"**/.next",
|
|
174
|
-
"**/.svelte-kit",
|
|
175
|
-
"**/.vercel",
|
|
176
|
-
"**/.netlify",
|
|
177
|
-
"**/.changeset",
|
|
178
|
-
"**/.idea",
|
|
179
|
-
"**/.cache",
|
|
180
|
-
"**/.output",
|
|
181
|
-
"**/.vite-inspect",
|
|
182
|
-
"**/.yarn",
|
|
183
|
-
"**/vite.config.*.timestamp-*",
|
|
184
|
-
"**/CHANGELOG*.md",
|
|
185
|
-
"**/*.min.*",
|
|
186
|
-
"**/LICENSE*",
|
|
187
|
-
"**/__snapshots__",
|
|
188
|
-
"**/auto-import?(s).d.ts",
|
|
189
|
-
"**/components.d.ts"
|
|
190
|
-
];
|
|
191
|
-
|
|
192
|
-
// src/utils.ts
|
|
193
|
-
var parserPlain = {
|
|
194
|
-
meta: {
|
|
195
|
-
name: "parser-plain"
|
|
196
|
-
},
|
|
197
|
-
parseForESLint: (code) => ({
|
|
198
|
-
ast: {
|
|
199
|
-
body: [],
|
|
200
|
-
comments: [],
|
|
201
|
-
loc: { end: code.length, start: 0 },
|
|
202
|
-
range: [0, code.length],
|
|
203
|
-
tokens: [],
|
|
204
|
-
type: "Program"
|
|
205
|
-
},
|
|
206
|
-
scopeManager: null,
|
|
207
|
-
services: { isPlain: true },
|
|
208
|
-
visitorKeys: {
|
|
209
|
-
Program: []
|
|
210
|
-
}
|
|
211
|
-
})
|
|
212
|
-
};
|
|
213
|
-
async function combine(...configs2) {
|
|
214
|
-
const resolved = await Promise.all(configs2);
|
|
215
|
-
return resolved.flat();
|
|
216
|
-
}
|
|
217
|
-
function toArray(value) {
|
|
218
|
-
return Array.isArray(value) ? value : [value];
|
|
219
|
-
}
|
|
220
|
-
async function interopDefault(m) {
|
|
221
|
-
const resolved = await m;
|
|
222
|
-
return resolved.default || resolved;
|
|
223
|
-
}
|
|
224
|
-
function isInEditorEnv() {
|
|
225
|
-
return !!((process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM) && !process.env.CI);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/configs/formatters.ts
|
|
229
|
-
function formatters(options = true) {
|
|
230
|
-
if (options === true) {
|
|
231
|
-
options = {
|
|
232
|
-
css: true,
|
|
233
|
-
graphql: true,
|
|
234
|
-
html: true,
|
|
235
|
-
markdown: true
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
const configs2 = [
|
|
239
|
-
{
|
|
240
|
-
name: "formatter/setup",
|
|
241
|
-
plugins: {
|
|
242
|
-
prettier: import_eslint_plugin_prettier.default
|
|
243
|
-
},
|
|
244
|
-
rules: import_recommended.default.rules
|
|
245
|
-
}
|
|
246
|
-
];
|
|
247
|
-
if (options.css) {
|
|
248
|
-
configs2.push(
|
|
249
|
-
{
|
|
250
|
-
files: [GLOB_CSS, GLOB_POSTCSS],
|
|
251
|
-
languageOptions: {
|
|
252
|
-
parser: parserPlain
|
|
253
|
-
},
|
|
254
|
-
name: "formatter/css",
|
|
255
|
-
rules: {
|
|
256
|
-
"prettier/prettier": ["error", { parser: "css" }]
|
|
257
|
-
}
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
files: [GLOB_SCSS],
|
|
261
|
-
languageOptions: {
|
|
262
|
-
parser: parserPlain
|
|
263
|
-
},
|
|
264
|
-
name: "formatter/scss",
|
|
265
|
-
rules: {
|
|
266
|
-
"prettier/prettier": ["error", { parser: "scss" }]
|
|
267
|
-
}
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
files: [GLOB_LESS],
|
|
271
|
-
languageOptions: {
|
|
272
|
-
parser: parserPlain
|
|
273
|
-
},
|
|
274
|
-
name: "formatter/less",
|
|
275
|
-
rules: {
|
|
276
|
-
"prettier/prettier": ["error", { parser: "less" }]
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
);
|
|
280
|
-
}
|
|
281
|
-
if (options.graphql) {
|
|
282
|
-
configs2.push({
|
|
283
|
-
files: [GLOB_GRAPHQL],
|
|
284
|
-
languageOptions: {
|
|
285
|
-
parser: parserPlain
|
|
286
|
-
},
|
|
287
|
-
name: "formatter/graphql",
|
|
288
|
-
rules: {
|
|
289
|
-
"prettier/prettier": ["error", { parser: "graphql" }]
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
}
|
|
293
|
-
if (options.html) {
|
|
294
|
-
configs2.push({
|
|
295
|
-
files: [GLOB_HTML],
|
|
296
|
-
languageOptions: {
|
|
297
|
-
parser: parserPlain
|
|
298
|
-
},
|
|
299
|
-
name: "formatter/html",
|
|
300
|
-
rules: {
|
|
301
|
-
"prettier/prettier": ["error", { parser: "html" }]
|
|
302
|
-
}
|
|
303
|
-
});
|
|
304
|
-
}
|
|
305
|
-
if (options.markdown) {
|
|
306
|
-
configs2.push({
|
|
307
|
-
files: [GLOB_MARKDOWN],
|
|
308
|
-
languageOptions: {
|
|
309
|
-
parser: parserPlain
|
|
310
|
-
},
|
|
311
|
-
name: "formatter/markdown",
|
|
312
|
-
rules: {
|
|
313
|
-
"prettier/prettier": ["error", { parser: "markdown" }]
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
return configs2;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
// src/configs/ignores.ts
|
|
321
|
-
function ignores() {
|
|
322
|
-
return [
|
|
323
|
-
{
|
|
324
|
-
ignores: GLOB_EXCLUDE
|
|
325
|
-
}
|
|
326
|
-
];
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// src/configs/imports.ts
|
|
330
|
-
var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
|
|
331
|
-
function imports() {
|
|
332
|
-
return [
|
|
333
|
-
{
|
|
334
|
-
name: "imports",
|
|
335
|
-
plugins: {
|
|
336
|
-
import: pluginImport
|
|
337
|
-
},
|
|
338
|
-
rules: {
|
|
339
|
-
"import/export": "error",
|
|
340
|
-
"import/first": "error",
|
|
341
|
-
"import/newline-after-import": ["error", { considerComments: true, count: 1 }],
|
|
342
|
-
"import/no-duplicates": "error",
|
|
343
|
-
"import/no-mutable-exports": "error",
|
|
344
|
-
"import/no-named-default": "error",
|
|
345
|
-
"import/no-self-import": "error",
|
|
346
|
-
"import/no-webpack-loader-syntax": "error",
|
|
347
|
-
"import/order": "error"
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
];
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
// src/configs/javascript.ts
|
|
354
|
-
var import_globals = __toESM(require("globals"), 1);
|
|
355
|
-
var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
|
|
356
|
-
function javascript(options = {}) {
|
|
357
|
-
const { isInEditor = false, overrides = {} } = options;
|
|
358
|
-
return [
|
|
359
|
-
{
|
|
360
|
-
languageOptions: {
|
|
361
|
-
ecmaVersion: 2022,
|
|
362
|
-
globals: {
|
|
363
|
-
...import_globals.default.browser,
|
|
364
|
-
...import_globals.default.es2021,
|
|
365
|
-
...import_globals.default.node,
|
|
366
|
-
document: "readonly",
|
|
367
|
-
navigator: "readonly",
|
|
368
|
-
window: "readonly"
|
|
369
|
-
},
|
|
370
|
-
parserOptions: {
|
|
371
|
-
ecmaFeatures: {
|
|
372
|
-
jsx: true
|
|
373
|
-
},
|
|
374
|
-
ecmaVersion: 2022,
|
|
375
|
-
sourceType: "module"
|
|
376
|
-
},
|
|
377
|
-
sourceType: "module"
|
|
378
|
-
},
|
|
379
|
-
linterOptions: {
|
|
380
|
-
reportUnusedDisableDirectives: true
|
|
381
|
-
},
|
|
382
|
-
name: "javascript/rules",
|
|
383
|
-
plugins: {
|
|
384
|
-
"unused-imports": import_eslint_plugin_unused_imports.default
|
|
385
|
-
},
|
|
386
|
-
rules: {
|
|
387
|
-
"accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
|
|
388
|
-
"array-callback-return": "error",
|
|
389
|
-
"block-scoped-var": "error",
|
|
390
|
-
camelcase: [
|
|
391
|
-
"error",
|
|
392
|
-
{ properties: "never", ignoreDestructuring: true, ignoreGlobals: true, ignoreImports: true, allow: ["^UNSAFE_"] }
|
|
393
|
-
],
|
|
394
|
-
"constructor-super": "error",
|
|
395
|
-
"default-case-last": "error",
|
|
396
|
-
"dot-notation": ["error", { allowKeywords: true }],
|
|
397
|
-
eqeqeq: ["error", "smart"],
|
|
398
|
-
"for-direction": "error",
|
|
399
|
-
"getter-return": "error",
|
|
400
|
-
"new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
|
|
401
|
-
"no-alert": "error",
|
|
402
|
-
"no-array-constructor": "error",
|
|
403
|
-
"no-async-promise-executor": "error",
|
|
404
|
-
"no-caller": "error",
|
|
405
|
-
"no-case-declarations": "error",
|
|
406
|
-
"no-class-assign": "error",
|
|
407
|
-
"no-compare-neg-zero": "error",
|
|
408
|
-
"no-cond-assign": ["error", "always"],
|
|
409
|
-
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
410
|
-
"no-const-assign": "error",
|
|
411
|
-
"no-constant-binary-expression": "error",
|
|
412
|
-
"no-constant-condition": "error",
|
|
413
|
-
"no-control-regex": "error",
|
|
414
|
-
"no-debugger": "error",
|
|
415
|
-
"no-delete-var": "error",
|
|
416
|
-
"no-dupe-args": "error",
|
|
417
|
-
"no-dupe-class-members": "error",
|
|
418
|
-
"no-dupe-else-if": "error",
|
|
419
|
-
"no-dupe-keys": "error",
|
|
420
|
-
"no-duplicate-case": "error",
|
|
421
|
-
"no-empty-character-class": "error",
|
|
422
|
-
"no-empty-pattern": "error",
|
|
423
|
-
"no-empty-static-block": "error",
|
|
424
|
-
"no-empty": ["error", { allowEmptyCatch: true }],
|
|
425
|
-
"no-eval": "error",
|
|
426
|
-
"no-ex-assign": "error",
|
|
427
|
-
"no-extend-native": "error",
|
|
428
|
-
"no-extra-bind": "error",
|
|
429
|
-
"no-extra-boolean-cast": "error",
|
|
430
|
-
"no-fallthrough": "error",
|
|
431
|
-
"no-func-assign": "error",
|
|
432
|
-
"no-global-assign": "error",
|
|
433
|
-
"no-implied-eval": "error",
|
|
434
|
-
"no-import-assign": "error",
|
|
435
|
-
"no-invalid-regexp": "error",
|
|
436
|
-
"no-irregular-whitespace": "error",
|
|
437
|
-
"no-iterator": "error",
|
|
438
|
-
"no-labels": ["error", { allowLoop: false, allowSwitch: false }],
|
|
439
|
-
"no-lone-blocks": "error",
|
|
440
|
-
"no-lonely-if": "error",
|
|
441
|
-
"no-loss-of-precision": "error",
|
|
442
|
-
"no-misleading-character-class": "error",
|
|
443
|
-
"no-multi-str": "error",
|
|
444
|
-
"no-new-func": "error",
|
|
445
|
-
"no-new-native-nonconstructor": "error",
|
|
446
|
-
"no-new-wrappers": "error",
|
|
447
|
-
"no-new": "error",
|
|
448
|
-
"no-nonoctal-decimal-escape": "error",
|
|
449
|
-
"no-obj-calls": "error",
|
|
450
|
-
"no-octal-escape": "error",
|
|
451
|
-
"no-octal": "error",
|
|
452
|
-
"no-proto": "error",
|
|
453
|
-
"no-prototype-builtins": "error",
|
|
454
|
-
"no-redeclare": ["error", { builtinGlobals: false }],
|
|
455
|
-
"no-regex-spaces": "error",
|
|
456
|
-
"no-restricted-globals": [
|
|
457
|
-
"error",
|
|
458
|
-
{ message: "Use `globalThis` instead.", name: "global" },
|
|
459
|
-
{ message: "Use `globalThis` instead.", name: "self" }
|
|
460
|
-
],
|
|
461
|
-
"no-restricted-properties": [
|
|
462
|
-
"error",
|
|
463
|
-
{ message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
|
|
464
|
-
{ message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
|
|
465
|
-
{ message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
|
|
466
|
-
{ message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
|
|
467
|
-
{ message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
|
|
468
|
-
],
|
|
469
|
-
"no-restricted-syntax": ["error", "TSEnumDeclaration[const=true]", "TSExportAssignment"],
|
|
470
|
-
"no-return-assign": ["error", "except-parens"],
|
|
471
|
-
"no-self-assign": ["error", { props: true }],
|
|
472
|
-
"no-self-compare": "error",
|
|
473
|
-
"no-sequences": "error",
|
|
474
|
-
"no-setter-return": "error",
|
|
475
|
-
"no-shadow-restricted-names": "error",
|
|
476
|
-
"no-sparse-arrays": "error",
|
|
477
|
-
"no-template-curly-in-string": "error",
|
|
478
|
-
"no-this-before-super": "error",
|
|
479
|
-
"no-throw-literal": "error",
|
|
480
|
-
"no-undef-init": "error",
|
|
481
|
-
"no-undef": "error",
|
|
482
|
-
"no-unexpected-multiline": "error",
|
|
483
|
-
"no-unmodified-loop-condition": "error",
|
|
484
|
-
"no-unneeded-ternary": ["error", { defaultAssignment: false }],
|
|
485
|
-
"no-unreachable": "error",
|
|
486
|
-
"no-unreachable-loop": "error",
|
|
487
|
-
"no-unsafe-finally": "error",
|
|
488
|
-
"no-unsafe-negation": "error",
|
|
489
|
-
"no-unsafe-optional-chaining": "error",
|
|
490
|
-
"no-unused-expressions": [
|
|
491
|
-
"error",
|
|
492
|
-
{
|
|
493
|
-
allowShortCircuit: true,
|
|
494
|
-
allowTaggedTemplates: true,
|
|
495
|
-
allowTernary: true
|
|
496
|
-
}
|
|
497
|
-
],
|
|
498
|
-
"no-unused-private-class-members": "error",
|
|
499
|
-
"no-unused-vars": "off",
|
|
500
|
-
"no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
|
|
501
|
-
"no-useless-backreference": "error",
|
|
502
|
-
"no-useless-call": "error",
|
|
503
|
-
"no-useless-catch": "error",
|
|
504
|
-
"no-useless-computed-key": "error",
|
|
505
|
-
"no-useless-constructor": "error",
|
|
506
|
-
"no-useless-escape": "error",
|
|
507
|
-
"no-useless-rename": "error",
|
|
508
|
-
"no-useless-return": "error",
|
|
509
|
-
"no-var": "error",
|
|
510
|
-
"no-void": ["error", { allowAsStatement: true }],
|
|
511
|
-
"no-with": "error",
|
|
512
|
-
"object-shorthand": [
|
|
513
|
-
"error",
|
|
514
|
-
"always",
|
|
515
|
-
{
|
|
516
|
-
avoidQuotes: true,
|
|
517
|
-
ignoreConstructors: false
|
|
518
|
-
}
|
|
519
|
-
],
|
|
520
|
-
"one-var": ["error", { initialized: "never" }],
|
|
521
|
-
"prefer-arrow-callback": [
|
|
522
|
-
"error",
|
|
523
|
-
{
|
|
524
|
-
allowNamedFunctions: false,
|
|
525
|
-
allowUnboundThis: true
|
|
526
|
-
}
|
|
527
|
-
],
|
|
528
|
-
"prefer-const": [
|
|
529
|
-
"error",
|
|
530
|
-
{
|
|
531
|
-
destructuring: "all",
|
|
532
|
-
ignoreReadBeforeAssign: true
|
|
533
|
-
}
|
|
534
|
-
],
|
|
535
|
-
"prefer-exponentiation-operator": "error",
|
|
536
|
-
"prefer-promise-reject-errors": "error",
|
|
537
|
-
"prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
|
|
538
|
-
"prefer-rest-params": "error",
|
|
539
|
-
"prefer-spread": "error",
|
|
540
|
-
"prefer-template": "error",
|
|
541
|
-
"require-await": "error",
|
|
542
|
-
"require-yield": "error",
|
|
543
|
-
"sort-imports": [
|
|
544
|
-
"error",
|
|
545
|
-
{
|
|
546
|
-
allowSeparatedGroups: false,
|
|
547
|
-
ignoreCase: false,
|
|
548
|
-
ignoreDeclarationSort: true,
|
|
549
|
-
ignoreMemberSort: false,
|
|
550
|
-
memberSyntaxSortOrder: ["none", "all", "multiple", "single"]
|
|
551
|
-
}
|
|
552
|
-
],
|
|
553
|
-
"symbol-description": "error",
|
|
554
|
-
"unicode-bom": ["error", "never"],
|
|
555
|
-
"unused-imports/no-unused-imports": isInEditor ? "off" : "error",
|
|
556
|
-
"unused-imports/no-unused-vars": [
|
|
557
|
-
"error",
|
|
558
|
-
{
|
|
559
|
-
args: "after-used",
|
|
560
|
-
argsIgnorePattern: "^_",
|
|
561
|
-
ignoreRestSiblings: true,
|
|
562
|
-
vars: "all",
|
|
563
|
-
varsIgnorePattern: "^_"
|
|
564
|
-
}
|
|
565
|
-
],
|
|
566
|
-
"use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
|
|
567
|
-
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
568
|
-
"vars-on-top": "error",
|
|
569
|
-
yoda: ["error", "never"],
|
|
570
|
-
...overrides
|
|
571
|
-
}
|
|
572
|
-
},
|
|
573
|
-
{
|
|
574
|
-
files: [`scripts/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
|
|
575
|
-
name: "javascript/disables/cli",
|
|
576
|
-
rules: {
|
|
577
|
-
"no-console": "off"
|
|
578
|
-
}
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
files: ["**/*.{test,spec}.js?(x)"],
|
|
582
|
-
name: "javascript/disables/test",
|
|
583
|
-
rules: {
|
|
584
|
-
"no-unused-expressions": "off"
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
];
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
// src/configs/jsonc.ts
|
|
591
|
-
async function jsonc(options = {}) {
|
|
592
|
-
const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC] } = options;
|
|
593
|
-
const [pluginJsonc, parserJsonc] = await Promise.all([
|
|
594
|
-
interopDefault(import("eslint-plugin-jsonc")),
|
|
595
|
-
interopDefault(import("jsonc-eslint-parser"))
|
|
596
|
-
]);
|
|
597
|
-
return [
|
|
598
|
-
{
|
|
599
|
-
name: "jsonc",
|
|
600
|
-
files,
|
|
601
|
-
languageOptions: {
|
|
602
|
-
parser: parserJsonc
|
|
603
|
-
},
|
|
604
|
-
plugins: {
|
|
605
|
-
jsonc: pluginJsonc
|
|
606
|
-
},
|
|
607
|
-
rules: {
|
|
608
|
-
...pluginJsonc.configs["recommended-with-jsonc"].rules,
|
|
609
|
-
...pluginJsonc.configs.prettier.rules
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
];
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// src/configs/node.ts
|
|
616
|
-
var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
|
|
617
|
-
function node() {
|
|
618
|
-
return [
|
|
619
|
-
{
|
|
620
|
-
name: "node",
|
|
621
|
-
plugins: {
|
|
622
|
-
n: import_eslint_plugin_n.default
|
|
623
|
-
},
|
|
624
|
-
rules: {
|
|
625
|
-
"n/handle-callback-err": ["error", "^(err|error)$"],
|
|
626
|
-
"n/no-deprecated-api": "error",
|
|
627
|
-
"n/no-exports-assign": "error",
|
|
628
|
-
"n/no-new-require": "error",
|
|
629
|
-
"n/no-path-concat": "error",
|
|
630
|
-
"n/prefer-global/buffer": ["error", "always"],
|
|
631
|
-
"n/prefer-global/console": ["error", "always"],
|
|
632
|
-
"n/prefer-global/process": ["error", "always"],
|
|
633
|
-
"n/prefer-global/text-decoder": ["error", "always"],
|
|
634
|
-
"n/prefer-global/text-encoder": ["error", "always"],
|
|
635
|
-
"n/prefer-global/url": ["error", "always"],
|
|
636
|
-
"n/prefer-global/url-search-params": ["error", "always"],
|
|
637
|
-
"n/process-exit-as-throw": "error"
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
];
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
// src/configs/sort.ts
|
|
644
|
-
function sortPackageJson() {
|
|
645
|
-
return [
|
|
646
|
-
{
|
|
647
|
-
files: ["**/package.json"],
|
|
648
|
-
name: "sort/package-json",
|
|
649
|
-
rules: {
|
|
650
|
-
"jsonc/sort-array-values": [
|
|
651
|
-
"error",
|
|
652
|
-
{
|
|
653
|
-
order: { type: "asc" },
|
|
654
|
-
pathPattern: "^files$"
|
|
655
|
-
}
|
|
656
|
-
],
|
|
657
|
-
"jsonc/sort-keys": [
|
|
658
|
-
"error",
|
|
659
|
-
{
|
|
660
|
-
order: [
|
|
661
|
-
"publisher",
|
|
662
|
-
"name",
|
|
663
|
-
"displayName",
|
|
664
|
-
"type",
|
|
665
|
-
"version",
|
|
666
|
-
"private",
|
|
667
|
-
"packageManager",
|
|
668
|
-
"description",
|
|
669
|
-
"author",
|
|
670
|
-
"contributors",
|
|
671
|
-
"license",
|
|
672
|
-
"funding",
|
|
673
|
-
"homepage",
|
|
674
|
-
"repository",
|
|
675
|
-
"bugs",
|
|
676
|
-
"keywords",
|
|
677
|
-
"categories",
|
|
678
|
-
"sideEffects",
|
|
679
|
-
"exports",
|
|
680
|
-
"main",
|
|
681
|
-
"module",
|
|
682
|
-
"unpkg",
|
|
683
|
-
"jsdelivr",
|
|
684
|
-
"types",
|
|
685
|
-
"typesVersions",
|
|
686
|
-
"bin",
|
|
687
|
-
"icon",
|
|
688
|
-
"files",
|
|
689
|
-
"engines",
|
|
690
|
-
"activationEvents",
|
|
691
|
-
"contributes",
|
|
692
|
-
"scripts",
|
|
693
|
-
"peerDependencies",
|
|
694
|
-
"peerDependenciesMeta",
|
|
695
|
-
"dependencies",
|
|
696
|
-
"optionalDependencies",
|
|
697
|
-
"devDependencies",
|
|
698
|
-
"pnpm",
|
|
699
|
-
"overrides",
|
|
700
|
-
"resolutions",
|
|
701
|
-
"husky",
|
|
702
|
-
"simple-git-hooks",
|
|
703
|
-
"lint-staged",
|
|
704
|
-
"eslintConfig",
|
|
705
|
-
"prettier",
|
|
706
|
-
"stylelint"
|
|
707
|
-
],
|
|
708
|
-
pathPattern: "^$"
|
|
709
|
-
},
|
|
710
|
-
{
|
|
711
|
-
order: { type: "asc" },
|
|
712
|
-
pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
|
|
713
|
-
},
|
|
714
|
-
{
|
|
715
|
-
order: { type: "asc" },
|
|
716
|
-
pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
|
|
717
|
-
},
|
|
718
|
-
{
|
|
719
|
-
order: ["types", "import", "require", "default"],
|
|
720
|
-
pathPattern: "^exports.*$"
|
|
721
|
-
},
|
|
722
|
-
{
|
|
723
|
-
order: [
|
|
724
|
-
// client hooks only
|
|
725
|
-
"pre-commit",
|
|
726
|
-
"prepare-commit-msg",
|
|
727
|
-
"commit-msg",
|
|
728
|
-
"post-commit",
|
|
729
|
-
"pre-rebase",
|
|
730
|
-
"post-rewrite",
|
|
731
|
-
"post-checkout",
|
|
732
|
-
"post-merge",
|
|
733
|
-
"pre-push",
|
|
734
|
-
"pre-auto-gc"
|
|
735
|
-
],
|
|
736
|
-
pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
|
|
737
|
-
}
|
|
738
|
-
]
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
];
|
|
742
|
-
}
|
|
743
|
-
function sortTsconfig() {
|
|
744
|
-
return [
|
|
745
|
-
{
|
|
746
|
-
files: ["**/tsconfig.json", "**/tsconfig.*.json"],
|
|
747
|
-
name: "sort/tsconfig-json",
|
|
748
|
-
rules: {
|
|
749
|
-
"jsonc/sort-keys": [
|
|
750
|
-
"error",
|
|
751
|
-
{
|
|
752
|
-
order: ["extends", "compilerOptions", "references", "files", "include", "exclude"],
|
|
753
|
-
pathPattern: "^$"
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
order: [
|
|
757
|
-
/* Projects */
|
|
758
|
-
"incremental",
|
|
759
|
-
"composite",
|
|
760
|
-
"tsBuildInfoFile",
|
|
761
|
-
"disableSourceOfProjectReferenceRedirect",
|
|
762
|
-
"disableSolutionSearching",
|
|
763
|
-
"disableReferencedProjectLoad",
|
|
764
|
-
/* Language and Environment */
|
|
765
|
-
"target",
|
|
766
|
-
"jsx",
|
|
767
|
-
"jsxFactory",
|
|
768
|
-
"jsxFragmentFactory",
|
|
769
|
-
"jsxImportSource",
|
|
770
|
-
"lib",
|
|
771
|
-
"moduleDetection",
|
|
772
|
-
"noLib",
|
|
773
|
-
"reactNamespace",
|
|
774
|
-
"useDefineForClassFields",
|
|
775
|
-
"emitDecoratorMetadata",
|
|
776
|
-
"experimentalDecorators",
|
|
777
|
-
/* Modules */
|
|
778
|
-
"baseUrl",
|
|
779
|
-
"rootDir",
|
|
780
|
-
"rootDirs",
|
|
781
|
-
"customConditions",
|
|
782
|
-
"module",
|
|
783
|
-
"moduleResolution",
|
|
784
|
-
"moduleSuffixes",
|
|
785
|
-
"noResolve",
|
|
786
|
-
"paths",
|
|
787
|
-
"resolveJsonModule",
|
|
788
|
-
"resolvePackageJsonExports",
|
|
789
|
-
"resolvePackageJsonImports",
|
|
790
|
-
"typeRoots",
|
|
791
|
-
"types",
|
|
792
|
-
"allowArbitraryExtensions",
|
|
793
|
-
"allowImportingTsExtensions",
|
|
794
|
-
"allowUmdGlobalAccess",
|
|
795
|
-
/* JavaScript Support */
|
|
796
|
-
"allowJs",
|
|
797
|
-
"checkJs",
|
|
798
|
-
"maxNodeModuleJsDepth",
|
|
799
|
-
/* Type Checking */
|
|
800
|
-
"strict",
|
|
801
|
-
"strictBindCallApply",
|
|
802
|
-
"strictFunctionTypes",
|
|
803
|
-
"strictNullChecks",
|
|
804
|
-
"strictPropertyInitialization",
|
|
805
|
-
"allowUnreachableCode",
|
|
806
|
-
"allowUnusedLabels",
|
|
807
|
-
"alwaysStrict",
|
|
808
|
-
"exactOptionalPropertyTypes",
|
|
809
|
-
"noFallthroughCasesInSwitch",
|
|
810
|
-
"noImplicitAny",
|
|
811
|
-
"noImplicitOverride",
|
|
812
|
-
"noImplicitReturns",
|
|
813
|
-
"noImplicitThis",
|
|
814
|
-
"noPropertyAccessFromIndexSignature",
|
|
815
|
-
"noUncheckedIndexedAccess",
|
|
816
|
-
"noUnusedLocals",
|
|
817
|
-
"noUnusedParameters",
|
|
818
|
-
"useUnknownInCatchVariables",
|
|
819
|
-
/* Emit */
|
|
820
|
-
"declaration",
|
|
821
|
-
"declarationDir",
|
|
822
|
-
"declarationMap",
|
|
823
|
-
"downlevelIteration",
|
|
824
|
-
"emitBOM",
|
|
825
|
-
"emitDeclarationOnly",
|
|
826
|
-
"importHelpers",
|
|
827
|
-
"importsNotUsedAsValues",
|
|
828
|
-
"inlineSourceMap",
|
|
829
|
-
"inlineSources",
|
|
830
|
-
"mapRoot",
|
|
831
|
-
"newLine",
|
|
832
|
-
"noEmit",
|
|
833
|
-
"noEmitHelpers",
|
|
834
|
-
"noEmitOnError",
|
|
835
|
-
"outDir",
|
|
836
|
-
"outFile",
|
|
837
|
-
"preserveConstEnums",
|
|
838
|
-
"preserveValueImports",
|
|
839
|
-
"removeComments",
|
|
840
|
-
"sourceMap",
|
|
841
|
-
"sourceRoot",
|
|
842
|
-
"stripInternal",
|
|
843
|
-
/* Interop Constraints */
|
|
844
|
-
"allowSyntheticDefaultImports",
|
|
845
|
-
"esModuleInterop",
|
|
846
|
-
"forceConsistentCasingInFileNames",
|
|
847
|
-
"isolatedDeclarations",
|
|
848
|
-
"isolatedModules",
|
|
849
|
-
"preserveSymlinks",
|
|
850
|
-
"verbatimModuleSyntax",
|
|
851
|
-
/* Completeness */
|
|
852
|
-
"skipDefaultLibCheck",
|
|
853
|
-
"skipLibCheck"
|
|
854
|
-
],
|
|
855
|
-
pathPattern: "^compilerOptions$"
|
|
856
|
-
}
|
|
857
|
-
]
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
];
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
// src/configs/test.ts
|
|
864
|
-
var _pluginTest;
|
|
865
|
-
async function test(options = {}) {
|
|
866
|
-
const { files = GLOB_TESTS, isInEditor = false, overrides = {} } = options;
|
|
867
|
-
const [pluginVitest, pluginNoOnlyTests] = await Promise.all([
|
|
868
|
-
interopDefault(import("@vitest/eslint-plugin")),
|
|
869
|
-
interopDefault(import("eslint-plugin-no-only-tests"))
|
|
870
|
-
]);
|
|
871
|
-
_pluginTest = _pluginTest || {
|
|
872
|
-
...pluginVitest,
|
|
873
|
-
rules: {
|
|
874
|
-
...pluginVitest.rules,
|
|
875
|
-
...pluginNoOnlyTests.rules
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
return [
|
|
879
|
-
{
|
|
880
|
-
files,
|
|
881
|
-
name: "test",
|
|
882
|
-
plugins: {
|
|
883
|
-
test: _pluginTest
|
|
884
|
-
},
|
|
885
|
-
rules: {
|
|
886
|
-
"test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
|
|
887
|
-
"test/no-identical-title": "error",
|
|
888
|
-
"test/no-import-node-test": "error",
|
|
889
|
-
"test/no-only-tests": isInEditor ? "off" : "error",
|
|
890
|
-
"test/prefer-hooks-in-order": "error",
|
|
891
|
-
"test/prefer-lowercase-title": "error",
|
|
892
|
-
"@typescript-eslint/explicit-function-return-type": "off",
|
|
893
|
-
...overrides
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
];
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
// src/configs/typescript.ts
|
|
900
|
-
async function typescript(options = {}) {
|
|
901
|
-
const { componentExts = [], overrides = {}, overridesTypeAware = {}, parserOptions = {}, type = "app" } = options;
|
|
902
|
-
const files = options.files ?? [GLOB_TS, GLOB_TSX, ...componentExts.map((ext) => `**/*.${ext}`)];
|
|
903
|
-
const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
|
|
904
|
-
const ignoresTypeAware = options.ignoresTypeAware ?? [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS];
|
|
905
|
-
const tsconfigPath = options?.tsconfigPath;
|
|
906
|
-
const isTypeAware = !!tsconfigPath;
|
|
907
|
-
const [pluginTs, parserTs] = await Promise.all([
|
|
908
|
-
interopDefault(import("@typescript-eslint/eslint-plugin")),
|
|
909
|
-
interopDefault(import("@typescript-eslint/parser"))
|
|
910
|
-
]);
|
|
911
|
-
function makeParser(typeAware, files2, ignores2) {
|
|
912
|
-
return {
|
|
913
|
-
files: files2,
|
|
914
|
-
...ignores2 ? { ignores: ignores2 } : {},
|
|
915
|
-
languageOptions: {
|
|
916
|
-
parser: parserTs,
|
|
917
|
-
parserOptions: {
|
|
918
|
-
extraFileExtensions: componentExts.map((ext) => `.${ext}`),
|
|
919
|
-
sourceType: "module",
|
|
920
|
-
...typeAware ? {
|
|
921
|
-
projectService: {
|
|
922
|
-
allowDefaultProject: ["./*.js"],
|
|
923
|
-
defaultProject: tsconfigPath
|
|
924
|
-
},
|
|
925
|
-
tsconfigRootDir: process.cwd()
|
|
926
|
-
} : {},
|
|
927
|
-
...parserOptions
|
|
928
|
-
}
|
|
929
|
-
},
|
|
930
|
-
name: `typescript/${typeAware ? "type-aware-parser" : "parser"}`
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
return [
|
|
934
|
-
{
|
|
935
|
-
// Install the plugins without globs, so they can be configured separately.
|
|
936
|
-
name: "typescript/setup",
|
|
937
|
-
plugins: {
|
|
938
|
-
"@typescript-eslint": pluginTs
|
|
939
|
-
}
|
|
940
|
-
},
|
|
941
|
-
// assign type-aware parser for type-aware files and type-unaware parser for the rest
|
|
942
|
-
...isTypeAware ? [makeParser(false, files), makeParser(true, filesTypeAware, ignoresTypeAware)] : [makeParser(false, files)],
|
|
943
|
-
{
|
|
944
|
-
files,
|
|
945
|
-
name: "typescript/rules",
|
|
946
|
-
rules: {
|
|
947
|
-
...pluginTs.configs["eslint-recommended"].overrides[0].rules,
|
|
948
|
-
...pluginTs.configs.strict.rules,
|
|
949
|
-
"@typescript-eslint/consistent-type-assertions": "error",
|
|
950
|
-
"@typescript-eslint/consistent-type-definitions": "off",
|
|
951
|
-
"@typescript-eslint/consistent-type-imports": [
|
|
952
|
-
"error",
|
|
953
|
-
{ disallowTypeAnnotations: false, prefer: "type-imports", fixStyle: "inline-type-imports" }
|
|
954
|
-
],
|
|
955
|
-
"@typescript-eslint/method-signature-style": "error",
|
|
956
|
-
"@typescript-eslint/no-dynamic-delete": "off",
|
|
957
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
958
|
-
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
959
|
-
"@typescript-eslint/no-invalid-void-type": "off",
|
|
960
|
-
"@typescript-eslint/no-non-null-assertion": "off",
|
|
961
|
-
"@typescript-eslint/no-require-imports": "error",
|
|
962
|
-
"@typescript-eslint/triple-slash-reference": "off",
|
|
963
|
-
"@typescript-eslint/unified-signatures": "off",
|
|
964
|
-
// handled by unused-imports/no-unused-imports
|
|
965
|
-
"@typescript-eslint/no-unused-vars": "off",
|
|
966
|
-
"no-dupe-class-members": "off",
|
|
967
|
-
"@typescript-eslint/no-dupe-class-members": "error",
|
|
968
|
-
"no-invalid-this": "off",
|
|
969
|
-
"@typescript-eslint/no-invalid-this": "error",
|
|
970
|
-
"no-redeclare": "off",
|
|
971
|
-
"@typescript-eslint/no-redeclare": "error",
|
|
972
|
-
"no-unused-expressions": "off",
|
|
973
|
-
"@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true, allowTaggedTemplates: true }],
|
|
974
|
-
"no-use-before-define": "off",
|
|
975
|
-
"@typescript-eslint/no-use-before-define": "error",
|
|
976
|
-
...type === "lib" ? {
|
|
977
|
-
"@typescript-eslint/explicit-function-return-type": [
|
|
978
|
-
"error",
|
|
979
|
-
{
|
|
980
|
-
allowExpressions: true,
|
|
981
|
-
allowHigherOrderFunctions: true,
|
|
982
|
-
allowIIFEs: true
|
|
983
|
-
}
|
|
984
|
-
]
|
|
985
|
-
} : {},
|
|
986
|
-
...overrides
|
|
987
|
-
}
|
|
988
|
-
},
|
|
989
|
-
...isTypeAware ? [
|
|
990
|
-
{
|
|
991
|
-
files: filesTypeAware,
|
|
992
|
-
ignores: ignoresTypeAware,
|
|
993
|
-
name: "typescript/rules-type-aware",
|
|
994
|
-
rules: {
|
|
995
|
-
...tsconfigPath ? {
|
|
996
|
-
...pluginTs.configs["recommended-type-checked-only"].rules,
|
|
997
|
-
"@typescript-eslint/no-confusing-void-expression": "error",
|
|
998
|
-
"@typescript-eslint/promise-function-async": "error",
|
|
999
|
-
"@typescript-eslint/restrict-template-expressions": "off",
|
|
1000
|
-
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
1001
|
-
"dot-notation": "off",
|
|
1002
|
-
"@typescript-eslint/dot-notation": ["error", { allowKeywords: true }],
|
|
1003
|
-
"no-throw-literal": "off",
|
|
1004
|
-
"@typescript-eslint/only-throw-error": "error"
|
|
1005
|
-
} : {},
|
|
1006
|
-
...overridesTypeAware
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
] : [],
|
|
1010
|
-
{
|
|
1011
|
-
files: ["**/*.d.?([cm])ts"],
|
|
1012
|
-
name: "typescript/disables/dts",
|
|
1013
|
-
rules: {
|
|
1014
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
1015
|
-
"import/no-duplicates": "off",
|
|
1016
|
-
"no-restricted-syntax": "off",
|
|
1017
|
-
"unused-imports/no-unused-vars": "off"
|
|
1018
|
-
}
|
|
1019
|
-
},
|
|
1020
|
-
{
|
|
1021
|
-
files: ["**/*.{test,spec}.ts?(x)"],
|
|
1022
|
-
name: "typescript/disables/test",
|
|
1023
|
-
rules: {
|
|
1024
|
-
"no-unused-expressions": "off"
|
|
1025
|
-
}
|
|
1026
|
-
},
|
|
1027
|
-
{
|
|
1028
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
1029
|
-
name: "typescript/disables/cjs",
|
|
1030
|
-
rules: {
|
|
1031
|
-
"@typescript-eslint/no-require-imports": "off",
|
|
1032
|
-
"@typescript-eslint/no-var-requires": "off"
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
];
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
// src/configs/unicorn.ts
|
|
1039
|
-
var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
|
|
1040
|
-
function unicorn() {
|
|
1041
|
-
return [
|
|
1042
|
-
{
|
|
1043
|
-
name: "unicorn",
|
|
1044
|
-
plugins: {
|
|
1045
|
-
unicorn: import_eslint_plugin_unicorn.default
|
|
1046
|
-
},
|
|
1047
|
-
rules: {
|
|
1048
|
-
...import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules,
|
|
1049
|
-
"unicorn/consistent-function-scoping": "off",
|
|
1050
|
-
"unicorn/filename-case": "off",
|
|
1051
|
-
"unicorn/import-style": "off",
|
|
1052
|
-
"unicorn/no-array-callback-reference": "off",
|
|
1053
|
-
"unicorn/no-null": "off",
|
|
1054
|
-
"unicorn/prefer-string-replace-all": "off",
|
|
1055
|
-
"unicorn/prefer-top-level-await": "off",
|
|
1056
|
-
"unicorn/prevent-abbreviations": "off"
|
|
1057
|
-
}
|
|
1058
|
-
}
|
|
1059
|
-
];
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
// src/configs/unocss.ts
|
|
1063
|
-
async function unocss() {
|
|
1064
|
-
const pluginUnoCSS = await interopDefault(import("@unocss/eslint-plugin"));
|
|
1065
|
-
return [
|
|
1066
|
-
{
|
|
1067
|
-
...pluginUnoCSS.configs.flat,
|
|
1068
|
-
name: "unocss"
|
|
1069
|
-
}
|
|
1070
|
-
];
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
// src/configs/vue.ts
|
|
1074
|
-
async function vue(options = {}) {
|
|
1075
|
-
const { files = [GLOB_VUE], overrides = {}, vueVersion = 3 } = options;
|
|
1076
|
-
const [pluginVue, parserVue] = await Promise.all([
|
|
1077
|
-
interopDefault(import("eslint-plugin-vue")),
|
|
1078
|
-
interopDefault(import("vue-eslint-parser"))
|
|
1079
|
-
]);
|
|
1080
|
-
return [
|
|
1081
|
-
{
|
|
1082
|
-
files,
|
|
1083
|
-
languageOptions: {
|
|
1084
|
-
parser: parserVue,
|
|
1085
|
-
globals: {
|
|
1086
|
-
computed: "readonly",
|
|
1087
|
-
defineEmits: "readonly",
|
|
1088
|
-
defineExpose: "readonly",
|
|
1089
|
-
defineProps: "readonly",
|
|
1090
|
-
onMounted: "readonly",
|
|
1091
|
-
onUnmounted: "readonly",
|
|
1092
|
-
reactive: "readonly",
|
|
1093
|
-
ref: "readonly",
|
|
1094
|
-
shallowReactive: "readonly",
|
|
1095
|
-
shallowRef: "readonly",
|
|
1096
|
-
toRef: "readonly",
|
|
1097
|
-
toRefs: "readonly",
|
|
1098
|
-
watch: "readonly",
|
|
1099
|
-
watchEffect: "readonly"
|
|
1100
|
-
},
|
|
1101
|
-
parserOptions: {
|
|
1102
|
-
ecmaFeatures: {
|
|
1103
|
-
jsx: true
|
|
1104
|
-
},
|
|
1105
|
-
extraFileExtensions: [".vue"],
|
|
1106
|
-
parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
|
|
1107
|
-
sourceType: "module"
|
|
1108
|
-
}
|
|
1109
|
-
},
|
|
1110
|
-
name: "vue",
|
|
1111
|
-
processor: pluginVue.processors[".vue"],
|
|
1112
|
-
plugins: {
|
|
1113
|
-
vue: pluginVue
|
|
1114
|
-
},
|
|
1115
|
-
rules: {
|
|
1116
|
-
...pluginVue.configs.base.rules,
|
|
1117
|
-
...vueVersion === 2 ? {
|
|
1118
|
-
...pluginVue.configs.essential.rules,
|
|
1119
|
-
...pluginVue.configs["strongly-recommended"].rules,
|
|
1120
|
-
...pluginVue.configs.recommended.rules
|
|
1121
|
-
} : {
|
|
1122
|
-
...pluginVue.configs["vue3-essential"].rules,
|
|
1123
|
-
...pluginVue.configs["vue3-strongly-recommended"].rules,
|
|
1124
|
-
...pluginVue.configs["vue3-recommended"].rules
|
|
1125
|
-
},
|
|
1126
|
-
"vue/component-name-in-template-casing": ["error", "PascalCase"],
|
|
1127
|
-
"vue/component-options-name-casing": ["error", "PascalCase"],
|
|
1128
|
-
"vue/custom-event-name-casing": ["error", "camelCase"],
|
|
1129
|
-
"vue/define-macros-order": [
|
|
1130
|
-
"error",
|
|
1131
|
-
{
|
|
1132
|
-
order: ["defineOptions", "defineModel", "defineProps", "defineEmits", "defineSlots"]
|
|
1133
|
-
}
|
|
1134
|
-
],
|
|
1135
|
-
"vue/dot-notation": "error",
|
|
1136
|
-
"vue/eqeqeq": ["error", "smart"],
|
|
1137
|
-
"vue/html-comment-content-spacing": ["error", "always", { exceptions: ["-"] }],
|
|
1138
|
-
"vue/no-constant-condition": "error",
|
|
1139
|
-
"vue/no-empty-pattern": "error",
|
|
1140
|
-
"vue/no-irregular-whitespace": "error",
|
|
1141
|
-
"vue/no-loss-of-precision": "error",
|
|
1142
|
-
"vue/no-restricted-syntax": ["error", "DebuggerStatement", "LabeledStatement", "WithStatement"],
|
|
1143
|
-
"vue/no-restricted-v-bind": ["error", "/^v-/"],
|
|
1144
|
-
"vue/no-sparse-arrays": "error",
|
|
1145
|
-
"vue/no-unused-refs": "error",
|
|
1146
|
-
"vue/no-useless-v-bind": "error",
|
|
1147
|
-
"vue/no-v-html": "off",
|
|
1148
|
-
"vue/object-shorthand": ["error", "always", { avoidQuotes: true, ignoreConstructors: false }],
|
|
1149
|
-
"vue/prefer-separate-static-class": "error",
|
|
1150
|
-
"vue/prefer-template": "error",
|
|
1151
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1152
|
-
"vue/component-tags-order": "off",
|
|
1153
|
-
...overrides
|
|
1154
|
-
}
|
|
1155
|
-
}
|
|
1156
|
-
];
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
// src/configs/regexp.ts
|
|
1160
|
-
var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
|
|
1161
|
-
function regexp(options = {}) {
|
|
1162
|
-
const config = import_eslint_plugin_regexp.configs["flat/recommended"];
|
|
1163
|
-
return [
|
|
1164
|
-
{
|
|
1165
|
-
...config,
|
|
1166
|
-
name: "regexp",
|
|
1167
|
-
rules: {
|
|
1168
|
-
...config.rules,
|
|
1169
|
-
...options.overrides
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
];
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
// src/factory.ts
|
|
1176
|
-
var import_local_pkg = require("local-pkg");
|
|
1177
|
-
var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
|
|
1178
|
-
var flatConfigProps = [
|
|
1179
|
-
"name",
|
|
1180
|
-
"files",
|
|
1181
|
-
"ignores",
|
|
1182
|
-
"languageOptions",
|
|
1183
|
-
"linterOptions",
|
|
1184
|
-
"processor",
|
|
1185
|
-
"plugins",
|
|
1186
|
-
"rules",
|
|
1187
|
-
"settings"
|
|
1188
|
-
];
|
|
1189
|
-
var VuePackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
|
|
1190
|
-
var factoryConfig = function(options = {}, ...userConfigs) {
|
|
1191
|
-
const {
|
|
1192
|
-
componentExts = [],
|
|
1193
|
-
formatters: enableFormatters = true,
|
|
1194
|
-
gitignore: enableGitignore = true,
|
|
1195
|
-
isInEditor = isInEditorEnv(),
|
|
1196
|
-
jsonc: enableJSONC = true,
|
|
1197
|
-
regexp: enableRegexp = true,
|
|
1198
|
-
test: enableTest = true,
|
|
1199
|
-
typescript: enableTypeScript = (0, import_local_pkg.isPackageExists)("typescript"),
|
|
1200
|
-
unocss: enableUnoCSS = (0, import_local_pkg.isPackageExists)("unocss"),
|
|
1201
|
-
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
|
|
1202
|
-
} = options;
|
|
1203
|
-
const configs2 = [];
|
|
1204
|
-
if (enableGitignore) {
|
|
1205
|
-
if (typeof enableGitignore === "boolean") {
|
|
1206
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({ strict: false })]));
|
|
1207
|
-
} else {
|
|
1208
|
-
configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
configs2.push(
|
|
1212
|
-
comments(),
|
|
1213
|
-
ignores(),
|
|
1214
|
-
imports(),
|
|
1215
|
-
javascript({
|
|
1216
|
-
isInEditor,
|
|
1217
|
-
overrides: options.javascript?.overrides
|
|
1218
|
-
}),
|
|
1219
|
-
node(),
|
|
1220
|
-
unicorn()
|
|
1221
|
-
);
|
|
1222
|
-
if (enableVue) {
|
|
1223
|
-
componentExts.push("vue");
|
|
1224
|
-
}
|
|
1225
|
-
if (enableTypeScript) {
|
|
1226
|
-
configs2.push(
|
|
1227
|
-
typescript({
|
|
1228
|
-
...typeof enableTypeScript === "boolean" ? {} : enableTypeScript || {},
|
|
1229
|
-
componentExts,
|
|
1230
|
-
type: options.type
|
|
1231
|
-
})
|
|
1232
|
-
);
|
|
1233
|
-
}
|
|
1234
|
-
if (enableRegexp) {
|
|
1235
|
-
configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
1236
|
-
}
|
|
1237
|
-
if (enableTest) {
|
|
1238
|
-
configs2.push(
|
|
1239
|
-
test({
|
|
1240
|
-
isInEditor,
|
|
1241
|
-
overrides: typeof enableTest === "boolean" ? {} : enableTest?.overrides
|
|
1242
|
-
})
|
|
1243
|
-
);
|
|
1244
|
-
}
|
|
1245
|
-
if (enableVue) {
|
|
1246
|
-
configs2.push(
|
|
1247
|
-
vue({
|
|
1248
|
-
...typeof enableVue === "boolean" ? {} : enableVue || {},
|
|
1249
|
-
typescript: !!enableTypeScript
|
|
1250
|
-
})
|
|
1251
|
-
);
|
|
1252
|
-
}
|
|
1253
|
-
if (enableUnoCSS) {
|
|
1254
|
-
configs2.push(unocss());
|
|
1255
|
-
}
|
|
1256
|
-
if (enableJSONC) {
|
|
1257
|
-
configs2.push(jsonc(typeof enableJSONC === "boolean" ? {} : enableJSONC), sortPackageJson(), sortTsconfig());
|
|
1258
|
-
}
|
|
1259
|
-
if (enableFormatters) {
|
|
1260
|
-
configs2.push(formatters(enableFormatters));
|
|
1261
|
-
}
|
|
1262
|
-
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
1263
|
-
if (key in options) acc[key] = options[key];
|
|
1264
|
-
return acc;
|
|
1265
|
-
}, {});
|
|
1266
|
-
if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
|
|
1267
|
-
let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
|
|
1268
|
-
composer = composer.append(...configs2, ...userConfigs);
|
|
1269
|
-
return composer;
|
|
1270
|
-
};
|
|
1271
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
1272
|
-
0 && (module.exports = {
|
|
1273
|
-
GLOB_ALL_SRC,
|
|
1274
|
-
GLOB_ASTRO,
|
|
1275
|
-
GLOB_ASTRO_TS,
|
|
1276
|
-
GLOB_CSS,
|
|
1277
|
-
GLOB_EXCLUDE,
|
|
1278
|
-
GLOB_GRAPHQL,
|
|
1279
|
-
GLOB_HTML,
|
|
1280
|
-
GLOB_JS,
|
|
1281
|
-
GLOB_JSON,
|
|
1282
|
-
GLOB_JSON5,
|
|
1283
|
-
GLOB_JSONC,
|
|
1284
|
-
GLOB_JSX,
|
|
1285
|
-
GLOB_LESS,
|
|
1286
|
-
GLOB_MARKDOWN,
|
|
1287
|
-
GLOB_MARKDOWN_CODE,
|
|
1288
|
-
GLOB_MARKDOWN_IN_MARKDOWN,
|
|
1289
|
-
GLOB_POSTCSS,
|
|
1290
|
-
GLOB_SCSS,
|
|
1291
|
-
GLOB_SRC,
|
|
1292
|
-
GLOB_SRC_EXT,
|
|
1293
|
-
GLOB_STYLE,
|
|
1294
|
-
GLOB_SVELTE,
|
|
1295
|
-
GLOB_TESTS,
|
|
1296
|
-
GLOB_TOML,
|
|
1297
|
-
GLOB_TS,
|
|
1298
|
-
GLOB_TSX,
|
|
1299
|
-
GLOB_VUE,
|
|
1300
|
-
GLOB_XML,
|
|
1301
|
-
GLOB_YAML,
|
|
1302
|
-
combine,
|
|
1303
|
-
comments,
|
|
1304
|
-
factoryConfig,
|
|
1305
|
-
formatters,
|
|
1306
|
-
ignores,
|
|
1307
|
-
imports,
|
|
1308
|
-
interopDefault,
|
|
1309
|
-
isInEditorEnv,
|
|
1310
|
-
javascript,
|
|
1311
|
-
jsonc,
|
|
1312
|
-
node,
|
|
1313
|
-
parserPlain,
|
|
1314
|
-
regexp,
|
|
1315
|
-
sortPackageJson,
|
|
1316
|
-
sortTsconfig,
|
|
1317
|
-
test,
|
|
1318
|
-
toArray,
|
|
1319
|
-
typescript,
|
|
1320
|
-
unicorn,
|
|
1321
|
-
unocss,
|
|
1322
|
-
vue
|
|
1323
|
-
});
|