@coderwyd/eslint-config 2.7.3 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -66
- package/dist/cli.cjs +8 -43
- package/dist/cli.js +8 -43
- package/dist/index.cjs +249 -573
- package/dist/index.d.cts +4681 -6480
- package/dist/index.d.ts +4681 -6480
- package/dist/index.js +248 -572
- package/package.json +10 -12
package/dist/index.cjs
CHANGED
|
@@ -48,7 +48,7 @@ __export(src_exports, {
|
|
|
48
48
|
});
|
|
49
49
|
module.exports = __toCommonJS(src_exports);
|
|
50
50
|
|
|
51
|
-
// node_modules/.pnpm/tsup@8.3.0_jiti@
|
|
51
|
+
// node_modules/.pnpm/tsup@8.3.0_jiti@2.0.0_postcss@8.4.39_tsx@4.19.1_typescript@5.6.2_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
|
|
52
52
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
53
53
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
54
54
|
|
|
@@ -93,25 +93,16 @@ function comments() {
|
|
|
93
93
|
// src/constants/glob.ts
|
|
94
94
|
var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
|
|
95
95
|
var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
|
|
96
|
-
var GLOB_JSX = "**/*.?([cm])jsx";
|
|
97
96
|
var GLOB_TS = "**/*.?([cm])ts";
|
|
98
97
|
var GLOB_DTS = "**/*.d.?([cm])ts";
|
|
99
98
|
var GLOB_TSX = "**/*.?([cm])tsx";
|
|
100
99
|
var GLOB_VUE = "**/*.vue";
|
|
101
100
|
var GLOB_ASTRO_TS = "**/*.astro/*.ts";
|
|
102
101
|
var GLOB_SVELTE = "**/*.svelte";
|
|
103
|
-
var GLOB_HTML = "**/*.htm?(l)";
|
|
104
|
-
var GLOB_CSS = "**/*.css";
|
|
105
|
-
var GLOB_POSTCSS = "**/*.{p,post}css";
|
|
106
|
-
var GLOB_LESS = "**/*.less";
|
|
107
|
-
var GLOB_SCSS = "**/*.scss";
|
|
108
102
|
var GLOB_JSON = "**/*.json";
|
|
109
103
|
var GLOB_JSON5 = "**/*.json5";
|
|
110
104
|
var GLOB_JSONC = "**/*.jsonc";
|
|
111
105
|
var GLOB_MARKDOWN = "**/*.md";
|
|
112
|
-
var GLOB_YAML = "**/*.y?(a)ml";
|
|
113
|
-
var GLOB_TOML = "**/*.toml";
|
|
114
|
-
var GLOB_GRAPHQL = "**/*.{g,graph}ql";
|
|
115
106
|
var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
|
|
116
107
|
var GLOB_TESTS = [
|
|
117
108
|
`**/__tests__/**/*.${GLOB_SRC_EXT}`,
|
|
@@ -154,339 +145,18 @@ var GLOB_EXCLUDE = [
|
|
|
154
145
|
"**/components.d.ts"
|
|
155
146
|
];
|
|
156
147
|
|
|
157
|
-
// src/configs/disables.ts
|
|
158
|
-
function disables() {
|
|
159
|
-
return [
|
|
160
|
-
{
|
|
161
|
-
files: [`**/scripts/${GLOB_SRC}`],
|
|
162
|
-
name: "coderwyd/disables/scripts",
|
|
163
|
-
rules: {
|
|
164
|
-
"antfu/no-top-level-await": "off",
|
|
165
|
-
"no-console": "off",
|
|
166
|
-
"ts/explicit-function-return-type": "off"
|
|
167
|
-
}
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
171
|
-
name: "coderwyd/disables/cli",
|
|
172
|
-
rules: {
|
|
173
|
-
"antfu/no-top-level-await": "off",
|
|
174
|
-
"no-console": "off"
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
179
|
-
name: "coderwyd/disables/bin",
|
|
180
|
-
rules: {
|
|
181
|
-
"antfu/no-import-dist": "off",
|
|
182
|
-
"antfu/no-import-node-modules-by-path": "off"
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
files: [GLOB_DTS],
|
|
187
|
-
name: "coderwyd/disables/dts",
|
|
188
|
-
rules: {
|
|
189
|
-
"eslint-comments/no-unlimited-disable": "off",
|
|
190
|
-
"import/no-duplicates": "off",
|
|
191
|
-
"no-restricted-syntax": "off",
|
|
192
|
-
"unused-imports/no-unused-vars": "off"
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
197
|
-
name: "coderwyd/disables/test",
|
|
198
|
-
rules: {
|
|
199
|
-
"antfu/no-top-level-await": "off",
|
|
200
|
-
"no-unused-expressions": "off"
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
files: ["**/*.js", "**/*.cjs"],
|
|
205
|
-
name: "coderwyd/disables/cjs",
|
|
206
|
-
rules: {
|
|
207
|
-
"ts/no-require-imports": "off"
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
];
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// src/shared/index.ts
|
|
214
|
-
var import_node_process = __toESM(require("process"), 1);
|
|
215
|
-
var import_node_url = require("url");
|
|
216
|
-
var import_local_pkg = require("local-pkg");
|
|
217
|
-
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
218
|
-
var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
|
|
219
|
-
var parserPlain = {
|
|
220
|
-
meta: {
|
|
221
|
-
name: "parser-plain"
|
|
222
|
-
},
|
|
223
|
-
parseForESLint: (code) => ({
|
|
224
|
-
ast: {
|
|
225
|
-
body: [],
|
|
226
|
-
comments: [],
|
|
227
|
-
loc: { end: code.length, start: 0 },
|
|
228
|
-
range: [0, code.length],
|
|
229
|
-
tokens: [],
|
|
230
|
-
type: "Program"
|
|
231
|
-
},
|
|
232
|
-
scopeManager: null,
|
|
233
|
-
services: { isPlain: true },
|
|
234
|
-
visitorKeys: {
|
|
235
|
-
Program: []
|
|
236
|
-
}
|
|
237
|
-
})
|
|
238
|
-
};
|
|
239
|
-
async function combine(...configs2) {
|
|
240
|
-
const resolved = await Promise.all(configs2);
|
|
241
|
-
return resolved.flat();
|
|
242
|
-
}
|
|
243
|
-
function renameRules(rules, map) {
|
|
244
|
-
return Object.fromEntries(
|
|
245
|
-
Object.entries(rules).map(([key, value]) => {
|
|
246
|
-
for (const [from, to] of Object.entries(map)) {
|
|
247
|
-
if (key.startsWith(`${from}/`))
|
|
248
|
-
return [to + key.slice(from.length), value];
|
|
249
|
-
}
|
|
250
|
-
return [key, value];
|
|
251
|
-
})
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
function renamePluginInConfigs(configs2, map) {
|
|
255
|
-
return configs2.map((i) => {
|
|
256
|
-
const clone = { ...i };
|
|
257
|
-
if (clone.rules)
|
|
258
|
-
clone.rules = renameRules(clone.rules, map);
|
|
259
|
-
if (clone.plugins) {
|
|
260
|
-
clone.plugins = Object.fromEntries(
|
|
261
|
-
Object.entries(clone.plugins).map(([key, value]) => {
|
|
262
|
-
if (key in map)
|
|
263
|
-
return [map[key], value];
|
|
264
|
-
return [key, value];
|
|
265
|
-
})
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
return clone;
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
function getVueVersion() {
|
|
272
|
-
const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
|
|
273
|
-
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
|
|
274
|
-
return +pkg.version[0];
|
|
275
|
-
return 3;
|
|
276
|
-
}
|
|
277
|
-
function toArray(value) {
|
|
278
|
-
return Array.isArray(value) ? value : [value];
|
|
279
|
-
}
|
|
280
|
-
async function interopDefault(m) {
|
|
281
|
-
const resolved = await m;
|
|
282
|
-
return resolved.default || resolved;
|
|
283
|
-
}
|
|
284
|
-
function isPackageInScope(name) {
|
|
285
|
-
return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
286
|
-
}
|
|
287
|
-
async function ensurePackages(packages) {
|
|
288
|
-
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
|
|
289
|
-
return;
|
|
290
|
-
const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
|
|
291
|
-
if (nonExistingPackages.length === 0)
|
|
292
|
-
return;
|
|
293
|
-
const { default: prompts } = await import("prompts");
|
|
294
|
-
const { result } = await prompts([
|
|
295
|
-
{
|
|
296
|
-
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
297
|
-
name: "result",
|
|
298
|
-
type: "confirm"
|
|
299
|
-
}
|
|
300
|
-
]);
|
|
301
|
-
if (result) {
|
|
302
|
-
await import("@antfu/install-pkg").then(
|
|
303
|
-
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
function resolveSubOptions(options, key) {
|
|
308
|
-
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
309
|
-
}
|
|
310
|
-
function getOverrides(options, key) {
|
|
311
|
-
const sub = resolveSubOptions(options, key);
|
|
312
|
-
return {
|
|
313
|
-
..."overrides" in sub ? sub.overrides || {} : {}
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
function isInEditorEnv() {
|
|
317
|
-
if (import_node_process.default.env.CI)
|
|
318
|
-
return false;
|
|
319
|
-
if (isInGitHooksOrLintStaged())
|
|
320
|
-
return false;
|
|
321
|
-
return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM || false);
|
|
322
|
-
}
|
|
323
|
-
function isInGitHooksOrLintStaged() {
|
|
324
|
-
return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged") || import_node_process.default.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// src/configs/stylistic.ts
|
|
328
|
-
var StylisticConfigDefaults = {
|
|
329
|
-
indent: 2,
|
|
330
|
-
jsx: true,
|
|
331
|
-
quotes: "single",
|
|
332
|
-
semi: false
|
|
333
|
-
};
|
|
334
|
-
async function stylistic(options = {}) {
|
|
335
|
-
const {
|
|
336
|
-
indent,
|
|
337
|
-
jsx: jsx2,
|
|
338
|
-
overrides = {},
|
|
339
|
-
quotes,
|
|
340
|
-
semi
|
|
341
|
-
} = {
|
|
342
|
-
...StylisticConfigDefaults,
|
|
343
|
-
...options
|
|
344
|
-
};
|
|
345
|
-
const pluginStylistic = await interopDefault(
|
|
346
|
-
import("@stylistic/eslint-plugin")
|
|
347
|
-
);
|
|
348
|
-
const config = pluginStylistic.configs.customize({
|
|
349
|
-
flat: true,
|
|
350
|
-
indent,
|
|
351
|
-
jsx: jsx2,
|
|
352
|
-
pluginName: "style",
|
|
353
|
-
quotes,
|
|
354
|
-
semi
|
|
355
|
-
});
|
|
356
|
-
return [
|
|
357
|
-
{
|
|
358
|
-
name: "coderwyd/stylistic/rules",
|
|
359
|
-
plugins: {
|
|
360
|
-
antfu: import_eslint_plugin_antfu.default,
|
|
361
|
-
style: pluginStylistic
|
|
362
|
-
},
|
|
363
|
-
rules: {
|
|
364
|
-
...config.rules,
|
|
365
|
-
"antfu/consistent-chaining": "error",
|
|
366
|
-
"antfu/consistent-list-newline": "error",
|
|
367
|
-
"antfu/curly": "error",
|
|
368
|
-
"antfu/if-newline": "warn",
|
|
369
|
-
"antfu/top-level-function": "warn",
|
|
370
|
-
...overrides
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
];
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
// src/configs/formatter.ts
|
|
377
|
-
async function formatter(options = {}, stylistic2 = {}) {
|
|
378
|
-
const { css, graphql, html, markdown, toml, yaml } = options === true ? {
|
|
379
|
-
css: true,
|
|
380
|
-
graphql: true,
|
|
381
|
-
html: true,
|
|
382
|
-
markdown: true,
|
|
383
|
-
toml: true,
|
|
384
|
-
yaml: true
|
|
385
|
-
} : options;
|
|
386
|
-
const { indent, quotes, semi } = {
|
|
387
|
-
...StylisticConfigDefaults,
|
|
388
|
-
...stylistic2
|
|
389
|
-
};
|
|
390
|
-
const prettierOptions = Object.assign(
|
|
391
|
-
{
|
|
392
|
-
endOfLine: "auto",
|
|
393
|
-
printWidth: 80,
|
|
394
|
-
semi,
|
|
395
|
-
singleQuote: quotes === "single",
|
|
396
|
-
tabWidth: typeof indent === "number" ? indent : 2,
|
|
397
|
-
trailingComma: "all",
|
|
398
|
-
useTabs: indent === "tab"
|
|
399
|
-
},
|
|
400
|
-
typeof options === "boolean" ? {} : options.prettierOptions || {}
|
|
401
|
-
);
|
|
402
|
-
await ensurePackages(["eslint-plugin-format"]);
|
|
403
|
-
const pluginFormat = await interopDefault(import("eslint-plugin-format"));
|
|
404
|
-
function createPrettierFormatter(files, parser, plugins) {
|
|
405
|
-
const rules = {
|
|
406
|
-
...prettierOptions,
|
|
407
|
-
parser
|
|
408
|
-
};
|
|
409
|
-
const markdownRules = {
|
|
410
|
-
printWidth: 120,
|
|
411
|
-
...rules,
|
|
412
|
-
embeddedLanguageFormatting: "off"
|
|
413
|
-
};
|
|
414
|
-
if (plugins?.length)
|
|
415
|
-
rules.plugins = [...rules.plugins || [], ...plugins];
|
|
416
|
-
const config = {
|
|
417
|
-
files,
|
|
418
|
-
languageOptions: {
|
|
419
|
-
parser: parserPlain
|
|
420
|
-
},
|
|
421
|
-
name: `coderwyd/formatter/${parser}`,
|
|
422
|
-
plugins: {
|
|
423
|
-
format: pluginFormat
|
|
424
|
-
},
|
|
425
|
-
rules: {
|
|
426
|
-
"format/prettier": [
|
|
427
|
-
"warn",
|
|
428
|
-
parser === "markdown" ? markdownRules : rules
|
|
429
|
-
]
|
|
430
|
-
}
|
|
431
|
-
};
|
|
432
|
-
return config;
|
|
433
|
-
}
|
|
434
|
-
const configs2 = [
|
|
435
|
-
{
|
|
436
|
-
name: "coderwyd/formatter/setup",
|
|
437
|
-
plugins: {
|
|
438
|
-
format: pluginFormat
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
];
|
|
442
|
-
if (html) {
|
|
443
|
-
const htmlConfig = createPrettierFormatter([GLOB_HTML], "html");
|
|
444
|
-
configs2.push(htmlConfig);
|
|
445
|
-
}
|
|
446
|
-
if (css) {
|
|
447
|
-
const cssConfig = createPrettierFormatter([GLOB_CSS, GLOB_POSTCSS], "css");
|
|
448
|
-
const scssConfig = createPrettierFormatter([GLOB_SCSS], "scss");
|
|
449
|
-
const lessConfig = createPrettierFormatter([GLOB_LESS], "less");
|
|
450
|
-
configs2.push(cssConfig, scssConfig, lessConfig);
|
|
451
|
-
}
|
|
452
|
-
if (markdown) {
|
|
453
|
-
const markdownConfig = createPrettierFormatter([GLOB_MARKDOWN], "markdown");
|
|
454
|
-
configs2.push(markdownConfig);
|
|
455
|
-
}
|
|
456
|
-
if (graphql) {
|
|
457
|
-
const graphqlConfig = createPrettierFormatter([GLOB_GRAPHQL], "graphql");
|
|
458
|
-
configs2.push(graphqlConfig);
|
|
459
|
-
}
|
|
460
|
-
if (yaml) {
|
|
461
|
-
const yamlConfig = createPrettierFormatter([GLOB_YAML], "yaml");
|
|
462
|
-
configs2.push(yamlConfig);
|
|
463
|
-
}
|
|
464
|
-
if (toml) {
|
|
465
|
-
await ensurePackages(["@toml-tools/parser", "prettier-plugin-toml"]);
|
|
466
|
-
const tomlConfig = createPrettierFormatter([GLOB_TOML], "toml", [
|
|
467
|
-
"prettier-plugin-toml"
|
|
468
|
-
]);
|
|
469
|
-
configs2.push(tomlConfig);
|
|
470
|
-
}
|
|
471
|
-
return configs2;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
148
|
// src/configs/ignores.ts
|
|
475
149
|
function ignores(userIgnores = []) {
|
|
476
150
|
return [
|
|
477
151
|
{
|
|
478
|
-
ignores: [
|
|
479
|
-
...GLOB_EXCLUDE,
|
|
480
|
-
...userIgnores
|
|
481
|
-
],
|
|
152
|
+
ignores: [...GLOB_EXCLUDE, ...userIgnores],
|
|
482
153
|
name: "coderwyd/ignores"
|
|
483
154
|
}
|
|
484
155
|
];
|
|
485
156
|
}
|
|
486
157
|
|
|
487
158
|
// src/configs/imports.ts
|
|
488
|
-
function imports(
|
|
489
|
-
const { stylistic: stylistic2 = true } = options;
|
|
159
|
+
function imports() {
|
|
490
160
|
return [
|
|
491
161
|
{
|
|
492
162
|
name: "coderwyd/imports/rules",
|
|
@@ -503,10 +173,7 @@ function imports(options = {}) {
|
|
|
503
173
|
"import/no-mutable-exports": "error",
|
|
504
174
|
"import/no-named-default": "error",
|
|
505
175
|
"import/no-self-import": "error",
|
|
506
|
-
"import/no-webpack-loader-syntax": "error"
|
|
507
|
-
...stylistic2 ? {
|
|
508
|
-
"import/newline-after-import": ["error", { count: 1 }]
|
|
509
|
-
} : {}
|
|
176
|
+
"import/no-webpack-loader-syntax": "error"
|
|
510
177
|
}
|
|
511
178
|
}
|
|
512
179
|
];
|
|
@@ -558,7 +225,7 @@ function javascript(options = {}) {
|
|
|
558
225
|
"constructor-super": "error",
|
|
559
226
|
"default-case-last": "error",
|
|
560
227
|
"dot-notation": ["error", { allowKeywords: true }],
|
|
561
|
-
|
|
228
|
+
eqeqeq: ["error", "smart"],
|
|
562
229
|
"for-direction": "error",
|
|
563
230
|
"getter-return": "error",
|
|
564
231
|
"new-cap": [
|
|
@@ -739,16 +406,126 @@ function javascript(options = {}) {
|
|
|
739
406
|
],
|
|
740
407
|
"valid-typeof": ["error", { requireStringLiterals: true }],
|
|
741
408
|
"vars-on-top": "error",
|
|
742
|
-
|
|
409
|
+
yoda: ["error", "never"],
|
|
743
410
|
...overrides
|
|
744
411
|
}
|
|
745
412
|
}
|
|
746
413
|
];
|
|
747
414
|
}
|
|
748
415
|
|
|
416
|
+
// src/shared/index.ts
|
|
417
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
418
|
+
var import_node_url = require("url");
|
|
419
|
+
var import_local_pkg = require("local-pkg");
|
|
420
|
+
var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
|
|
421
|
+
var isCwdInScope = (0, import_local_pkg.isPackageExists)("@coderwyd/eslint-config");
|
|
422
|
+
var parserPlain = {
|
|
423
|
+
meta: {
|
|
424
|
+
name: "parser-plain"
|
|
425
|
+
},
|
|
426
|
+
parseForESLint: (code) => ({
|
|
427
|
+
ast: {
|
|
428
|
+
body: [],
|
|
429
|
+
comments: [],
|
|
430
|
+
loc: { end: code.length, start: 0 },
|
|
431
|
+
range: [0, code.length],
|
|
432
|
+
tokens: [],
|
|
433
|
+
type: "Program"
|
|
434
|
+
},
|
|
435
|
+
scopeManager: null,
|
|
436
|
+
services: { isPlain: true },
|
|
437
|
+
visitorKeys: {
|
|
438
|
+
Program: []
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
};
|
|
442
|
+
async function combine(...configs2) {
|
|
443
|
+
const resolved = await Promise.all(configs2);
|
|
444
|
+
return resolved.flat();
|
|
445
|
+
}
|
|
446
|
+
function renameRules(rules, map) {
|
|
447
|
+
return Object.fromEntries(
|
|
448
|
+
Object.entries(rules).map(([key, value]) => {
|
|
449
|
+
for (const [from, to] of Object.entries(map)) {
|
|
450
|
+
if (key.startsWith(`${from}/`))
|
|
451
|
+
return [to + key.slice(from.length), value];
|
|
452
|
+
}
|
|
453
|
+
return [key, value];
|
|
454
|
+
})
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
function renamePluginInConfigs(configs2, map) {
|
|
458
|
+
return configs2.map((i) => {
|
|
459
|
+
const clone = { ...i };
|
|
460
|
+
if (clone.rules) clone.rules = renameRules(clone.rules, map);
|
|
461
|
+
if (clone.plugins) {
|
|
462
|
+
clone.plugins = Object.fromEntries(
|
|
463
|
+
Object.entries(clone.plugins).map(([key, value]) => {
|
|
464
|
+
if (key in map) return [map[key], value];
|
|
465
|
+
return [key, value];
|
|
466
|
+
})
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
return clone;
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function getVueVersion() {
|
|
473
|
+
const pkg = (0, import_local_pkg.getPackageInfoSync)("vue", { paths: [import_node_process.default.cwd()] });
|
|
474
|
+
if (pkg && typeof pkg.version === "string" && !Number.isNaN(+pkg.version[0]))
|
|
475
|
+
return +pkg.version[0];
|
|
476
|
+
return 3;
|
|
477
|
+
}
|
|
478
|
+
function toArray(value) {
|
|
479
|
+
return Array.isArray(value) ? value : [value];
|
|
480
|
+
}
|
|
481
|
+
async function interopDefault(m) {
|
|
482
|
+
const resolved = await m;
|
|
483
|
+
return resolved.default || resolved;
|
|
484
|
+
}
|
|
485
|
+
function isPackageInScope(name) {
|
|
486
|
+
return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
|
|
487
|
+
}
|
|
488
|
+
async function ensurePackages(packages) {
|
|
489
|
+
if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
|
|
490
|
+
return;
|
|
491
|
+
const nonExistingPackages = packages.filter((i) => !isPackageInScope(i));
|
|
492
|
+
if (nonExistingPackages.length === 0) return;
|
|
493
|
+
const { default: prompts } = await import("prompts");
|
|
494
|
+
const { result } = await prompts([
|
|
495
|
+
{
|
|
496
|
+
message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`,
|
|
497
|
+
name: "result",
|
|
498
|
+
type: "confirm"
|
|
499
|
+
}
|
|
500
|
+
]);
|
|
501
|
+
if (result) {
|
|
502
|
+
await import("@antfu/install-pkg").then(
|
|
503
|
+
(i) => i.installPackage(nonExistingPackages, { dev: true })
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
function resolveSubOptions(options, key) {
|
|
508
|
+
return typeof options[key] === "boolean" ? {} : options[key] || {};
|
|
509
|
+
}
|
|
510
|
+
function getOverrides(options, key) {
|
|
511
|
+
const sub = resolveSubOptions(options, key);
|
|
512
|
+
return {
|
|
513
|
+
..."overrides" in sub ? sub.overrides || {} : {}
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
function isInEditorEnv() {
|
|
517
|
+
if (import_node_process.default.env.CI) return false;
|
|
518
|
+
if (isInGitHooksOrLintStaged()) {
|
|
519
|
+
return false;
|
|
520
|
+
}
|
|
521
|
+
return !!(import_node_process.default.env.VSCODE_PID || import_node_process.default.env.VSCODE_CWD || import_node_process.default.env.JETBRAINS_IDE || import_node_process.default.env.VIM || import_node_process.default.env.NVIM || false);
|
|
522
|
+
}
|
|
523
|
+
function isInGitHooksOrLintStaged() {
|
|
524
|
+
return !!(import_node_process.default.env.GIT_PARAMS || import_node_process.default.env.VSCODE_GIT_COMMAND || import_node_process.default.env.npm_lifecycle_script?.startsWith("lint-staged") || import_node_process.default.env.npm_lifecycle_script?.startsWith("nano-staged") || false);
|
|
525
|
+
}
|
|
526
|
+
|
|
749
527
|
// src/configs/jsdoc.ts
|
|
750
|
-
async function jsdoc(
|
|
751
|
-
const { stylistic: stylistic2 = true } = options;
|
|
528
|
+
async function jsdoc() {
|
|
752
529
|
return [
|
|
753
530
|
{
|
|
754
531
|
name: "coderwyd/jsdoc/rules",
|
|
@@ -770,11 +547,7 @@ async function jsdoc(options = {}) {
|
|
|
770
547
|
"jsdoc/require-property-name": "warn",
|
|
771
548
|
"jsdoc/require-returns-check": "warn",
|
|
772
549
|
"jsdoc/require-returns-description": "warn",
|
|
773
|
-
"jsdoc/require-yields-check": "warn"
|
|
774
|
-
...stylistic2 ? {
|
|
775
|
-
"jsdoc/check-alignment": "warn",
|
|
776
|
-
"jsdoc/multiline-blocks": "warn"
|
|
777
|
-
} : {}
|
|
550
|
+
"jsdoc/require-yields-check": "warn"
|
|
778
551
|
}
|
|
779
552
|
}
|
|
780
553
|
];
|
|
@@ -782,14 +555,7 @@ async function jsdoc(options = {}) {
|
|
|
782
555
|
|
|
783
556
|
// src/configs/jsonc.ts
|
|
784
557
|
async function jsonc(options = {}) {
|
|
785
|
-
const {
|
|
786
|
-
files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
|
|
787
|
-
overrides = {},
|
|
788
|
-
stylistic: stylistic2 = true
|
|
789
|
-
} = options || {};
|
|
790
|
-
const {
|
|
791
|
-
indent = 2
|
|
792
|
-
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
558
|
+
const { files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC], overrides = {} } = options || {};
|
|
793
559
|
const [pluginJsonc, parserJsonc] = await Promise.all([
|
|
794
560
|
interopDefault(import("eslint-plugin-jsonc")),
|
|
795
561
|
interopDefault(import("jsonc-eslint-parser"))
|
|
@@ -834,50 +600,12 @@ async function jsonc(options = {}) {
|
|
|
834
600
|
"jsonc/space-unary-ops": "error",
|
|
835
601
|
"jsonc/valid-json-number": "error",
|
|
836
602
|
"jsonc/vue-custom-block/no-parsing-error": "error",
|
|
837
|
-
...stylistic2 ? {
|
|
838
|
-
"jsonc/array-bracket-spacing": ["error", "never"],
|
|
839
|
-
"jsonc/comma-dangle": ["error", "never"],
|
|
840
|
-
"jsonc/comma-style": ["error", "last"],
|
|
841
|
-
"jsonc/indent": ["error", indent],
|
|
842
|
-
"jsonc/key-spacing": [
|
|
843
|
-
"error",
|
|
844
|
-
{ afterColon: true, beforeColon: false }
|
|
845
|
-
],
|
|
846
|
-
"jsonc/object-curly-newline": [
|
|
847
|
-
"error",
|
|
848
|
-
{ consistent: true, multiline: true }
|
|
849
|
-
],
|
|
850
|
-
"jsonc/object-curly-spacing": ["error", "always"],
|
|
851
|
-
"jsonc/object-property-newline": [
|
|
852
|
-
"error",
|
|
853
|
-
{ allowMultiplePropertiesPerLine: true }
|
|
854
|
-
],
|
|
855
|
-
"jsonc/quote-props": "error",
|
|
856
|
-
"jsonc/quotes": "error"
|
|
857
|
-
} : {},
|
|
858
603
|
...overrides
|
|
859
604
|
}
|
|
860
605
|
}
|
|
861
606
|
];
|
|
862
607
|
}
|
|
863
608
|
|
|
864
|
-
// src/configs/jsx.ts
|
|
865
|
-
function jsx() {
|
|
866
|
-
return [
|
|
867
|
-
{
|
|
868
|
-
files: [GLOB_JSX, GLOB_TSX],
|
|
869
|
-
languageOptions: {
|
|
870
|
-
parserOptions: {
|
|
871
|
-
ecmaFeatures: {
|
|
872
|
-
jsx: true
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
},
|
|
876
|
-
name: "coderwyd/jsx/setup"
|
|
877
|
-
}
|
|
878
|
-
];
|
|
879
|
-
}
|
|
880
|
-
|
|
881
609
|
// src/configs/node.ts
|
|
882
610
|
function node() {
|
|
883
611
|
return [
|
|
@@ -910,7 +638,10 @@ function perfectionist() {
|
|
|
910
638
|
perfectionist: import_eslint_plugin_perfectionist.default
|
|
911
639
|
},
|
|
912
640
|
rules: {
|
|
913
|
-
"perfectionist/sort-exports": [
|
|
641
|
+
"perfectionist/sort-exports": [
|
|
642
|
+
"error",
|
|
643
|
+
{ order: "asc", type: "natural" }
|
|
644
|
+
],
|
|
914
645
|
"perfectionist/sort-imports": [
|
|
915
646
|
"warn",
|
|
916
647
|
{
|
|
@@ -946,6 +677,27 @@ function perfectionist() {
|
|
|
946
677
|
];
|
|
947
678
|
}
|
|
948
679
|
|
|
680
|
+
// src/configs/prettier.ts
|
|
681
|
+
var import_eslint_config_prettier = __toESM(require("eslint-config-prettier"), 1);
|
|
682
|
+
var { rules: eslintRules } = import_eslint_config_prettier.default;
|
|
683
|
+
async function prettier() {
|
|
684
|
+
const pluginPrettier = await interopDefault(import("eslint-plugin-prettier"));
|
|
685
|
+
return [
|
|
686
|
+
{
|
|
687
|
+
name: "coderwyd/prettier/rules",
|
|
688
|
+
plugins: {
|
|
689
|
+
prettier: pluginPrettier
|
|
690
|
+
},
|
|
691
|
+
rules: {
|
|
692
|
+
...eslintRules,
|
|
693
|
+
"arrow-body-style": "off",
|
|
694
|
+
"prefer-arrow-callback": "off",
|
|
695
|
+
"prettier/prettier": "warn"
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
];
|
|
699
|
+
}
|
|
700
|
+
|
|
949
701
|
// src/configs/react.ts
|
|
950
702
|
var import_local_pkg3 = require("local-pkg");
|
|
951
703
|
|
|
@@ -954,12 +706,7 @@ var import_node_process2 = __toESM(require("process"), 1);
|
|
|
954
706
|
var import_local_pkg2 = require("local-pkg");
|
|
955
707
|
var isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.VSCODE_CWD || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM || import_node_process2.default.env.NVIM) && !import_node_process2.default.env.CI);
|
|
956
708
|
var hasTypeScript = (0, import_local_pkg2.isPackageExists)("typescript");
|
|
957
|
-
var VueJsPackages = [
|
|
958
|
-
"vue",
|
|
959
|
-
"nuxt",
|
|
960
|
-
"vitepress",
|
|
961
|
-
"@slidev/cli"
|
|
962
|
-
];
|
|
709
|
+
var VueJsPackages = ["vue", "nuxt", "vitepress", "@slidev/cli"];
|
|
963
710
|
var hasVue = hasPackages(VueJsPackages);
|
|
964
711
|
var RemixPackages = [
|
|
965
712
|
"@remix-run/node",
|
|
@@ -999,7 +746,7 @@ async function react(options = {}) {
|
|
|
999
746
|
{
|
|
1000
747
|
name: "coderwyd/react/setup",
|
|
1001
748
|
plugins: {
|
|
1002
|
-
|
|
749
|
+
react: plugins["@eslint-react"],
|
|
1003
750
|
"react-dom": plugins["@eslint-react/dom"],
|
|
1004
751
|
"react-hooks": pluginReactHooks,
|
|
1005
752
|
"react-hooks-extra": plugins["@eslint-react/hooks-extra"],
|
|
@@ -1117,8 +864,7 @@ function regexp(options = {}) {
|
|
|
1117
864
|
};
|
|
1118
865
|
if (options.level === "warn") {
|
|
1119
866
|
Object.keys(rules).forEach((key) => {
|
|
1120
|
-
if (rules[key] === "error")
|
|
1121
|
-
rules[key] = "warn";
|
|
867
|
+
if (rules[key] === "error") rules[key] = "warn";
|
|
1122
868
|
});
|
|
1123
869
|
}
|
|
1124
870
|
return [
|
|
@@ -1357,13 +1103,65 @@ function sortTsconfig() {
|
|
|
1357
1103
|
];
|
|
1358
1104
|
}
|
|
1359
1105
|
|
|
1106
|
+
// src/configs/specials.ts
|
|
1107
|
+
function specials() {
|
|
1108
|
+
return [
|
|
1109
|
+
{
|
|
1110
|
+
files: [`**/scripts/${GLOB_SRC}`],
|
|
1111
|
+
name: "coderwyd/specials/scripts",
|
|
1112
|
+
rules: {
|
|
1113
|
+
"antfu/no-top-level-await": "off",
|
|
1114
|
+
"no-console": "off",
|
|
1115
|
+
"ts/explicit-function-return-type": "off"
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
|
|
1120
|
+
name: "coderwyd/specials/cli",
|
|
1121
|
+
rules: {
|
|
1122
|
+
"antfu/no-top-level-await": "off",
|
|
1123
|
+
"no-console": "off"
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
|
|
1128
|
+
name: "coderwyd/specials/bin",
|
|
1129
|
+
rules: {
|
|
1130
|
+
"antfu/no-import-dist": "off",
|
|
1131
|
+
"antfu/no-import-node-modules-by-path": "off"
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
files: [GLOB_DTS],
|
|
1136
|
+
name: "coderwyd/specials/dts",
|
|
1137
|
+
rules: {
|
|
1138
|
+
"eslint-comments/no-unlimited-disable": "off",
|
|
1139
|
+
"import/no-duplicates": "off",
|
|
1140
|
+
"no-restricted-syntax": "off",
|
|
1141
|
+
"unused-imports/no-unused-vars": "off"
|
|
1142
|
+
}
|
|
1143
|
+
},
|
|
1144
|
+
{
|
|
1145
|
+
files: ["**/*.{test,spec}.([tj])s?(x)"],
|
|
1146
|
+
name: "coderwyd/specials/test",
|
|
1147
|
+
rules: {
|
|
1148
|
+
"antfu/no-top-level-await": "off",
|
|
1149
|
+
"no-unused-expressions": "off"
|
|
1150
|
+
}
|
|
1151
|
+
},
|
|
1152
|
+
{
|
|
1153
|
+
files: ["**/*.js", "**/*.cjs"],
|
|
1154
|
+
name: "coderwyd/specials/cjs",
|
|
1155
|
+
rules: {
|
|
1156
|
+
"ts/no-require-imports": "off"
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
];
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1360
1162
|
// src/configs/svelte.ts
|
|
1361
1163
|
async function svelte(options = {}) {
|
|
1362
|
-
const { files = [GLOB_SVELTE], overrides = {}
|
|
1363
|
-
const {
|
|
1364
|
-
indent = 2,
|
|
1365
|
-
quotes = "single"
|
|
1366
|
-
} = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1164
|
+
const { files = [GLOB_SVELTE], overrides = {} } = options;
|
|
1367
1165
|
await ensurePackages(["eslint-plugin-svelte"]);
|
|
1368
1166
|
const [pluginSvelte, parserSvelte] = await Promise.all([
|
|
1369
1167
|
interopDefault(import("eslint-plugin-svelte")),
|
|
@@ -1432,23 +1230,6 @@ async function svelte(options = {}) {
|
|
|
1432
1230
|
varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
|
|
1433
1231
|
}
|
|
1434
1232
|
],
|
|
1435
|
-
...stylistic2 ? {
|
|
1436
|
-
"style/indent": "off",
|
|
1437
|
-
// superseded by svelte/indent
|
|
1438
|
-
"style/no-trailing-spaces": "off",
|
|
1439
|
-
// superseded by svelte/no-trailing-spaces
|
|
1440
|
-
"svelte/derived-has-same-inputs-outputs": "error",
|
|
1441
|
-
"svelte/html-closing-bracket-spacing": "error",
|
|
1442
|
-
"svelte/html-quotes": ["error", { prefer: quotes }],
|
|
1443
|
-
"svelte/indent": [
|
|
1444
|
-
"error",
|
|
1445
|
-
{ alignAttributesVertically: true, indent }
|
|
1446
|
-
],
|
|
1447
|
-
"svelte/mustache-spacing": "error",
|
|
1448
|
-
"svelte/no-spaces-around-equal-signs-in-attribute": "error",
|
|
1449
|
-
"svelte/no-trailing-spaces": "error",
|
|
1450
|
-
"svelte/spaced-html-comment": "error"
|
|
1451
|
-
} : {},
|
|
1452
1233
|
...overrides
|
|
1453
1234
|
}
|
|
1454
1235
|
}
|
|
@@ -1531,7 +1312,12 @@ async function test(options = {}) {
|
|
|
1531
1312
|
// src/configs/typescript.ts
|
|
1532
1313
|
var import_node_process3 = __toESM(require("process"), 1);
|
|
1533
1314
|
async function typescript(options = {}) {
|
|
1534
|
-
const {
|
|
1315
|
+
const {
|
|
1316
|
+
componentExts = [],
|
|
1317
|
+
overrides = {},
|
|
1318
|
+
overridesTypeAware = {},
|
|
1319
|
+
parserOptions = {}
|
|
1320
|
+
} = options;
|
|
1535
1321
|
const files = options.files ?? [
|
|
1536
1322
|
GLOB_TS,
|
|
1537
1323
|
GLOB_TSX,
|
|
@@ -1651,11 +1437,14 @@ async function typescript(options = {}) {
|
|
|
1651
1437
|
"ts/no-non-null-assertion": "off",
|
|
1652
1438
|
"ts/no-redeclare": ["error", { builtinGlobals: false }],
|
|
1653
1439
|
"ts/no-require-imports": "error",
|
|
1654
|
-
"ts/no-unused-expressions": [
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1440
|
+
"ts/no-unused-expressions": [
|
|
1441
|
+
"error",
|
|
1442
|
+
{
|
|
1443
|
+
allowShortCircuit: true,
|
|
1444
|
+
allowTaggedTemplates: true,
|
|
1445
|
+
allowTernary: true
|
|
1446
|
+
}
|
|
1447
|
+
],
|
|
1659
1448
|
"ts/no-unused-vars": "off",
|
|
1660
1449
|
"ts/no-use-before-define": [
|
|
1661
1450
|
"error",
|
|
@@ -1788,15 +1577,11 @@ async function unocss(options = {}) {
|
|
|
1788
1577
|
}
|
|
1789
1578
|
|
|
1790
1579
|
// src/configs/vue.ts
|
|
1791
|
-
var import_eslint_merge_processors = require("eslint-merge-processors");
|
|
1792
1580
|
async function vue(options = {}) {
|
|
1793
|
-
const { files = [GLOB_VUE], overrides = {}
|
|
1794
|
-
const
|
|
1795
|
-
const { indent = 2 } = typeof stylistic2 === "boolean" ? {} : stylistic2;
|
|
1796
|
-
const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
|
|
1581
|
+
const { files = [GLOB_VUE], overrides = {} } = options;
|
|
1582
|
+
const [pluginVue, parserVue] = await Promise.all([
|
|
1797
1583
|
interopDefault(import("eslint-plugin-vue")),
|
|
1798
|
-
interopDefault(import("vue-eslint-parser"))
|
|
1799
|
-
interopDefault(import("eslint-processor-vue-blocks"))
|
|
1584
|
+
interopDefault(import("vue-eslint-parser"))
|
|
1800
1585
|
]);
|
|
1801
1586
|
const isVue3 = getVueVersion() === 3;
|
|
1802
1587
|
const configKeys = isVue3 ? ["vue3-essential", "vue3-strongly-recommended", "vue3-recommended"] : ["essential", "strongly-recommended", "recommended"];
|
|
@@ -1808,32 +1593,6 @@ async function vue(options = {}) {
|
|
|
1808
1593
|
};
|
|
1809
1594
|
}, {});
|
|
1810
1595
|
return [
|
|
1811
|
-
{
|
|
1812
|
-
// This allows Vue plugin to work with auto imports
|
|
1813
|
-
// https://github.com/vuejs/eslint-plugin-vue/pull/2422
|
|
1814
|
-
languageOptions: {
|
|
1815
|
-
globals: {
|
|
1816
|
-
computed: "readonly",
|
|
1817
|
-
defineEmits: "readonly",
|
|
1818
|
-
defineExpose: "readonly",
|
|
1819
|
-
defineProps: "readonly",
|
|
1820
|
-
onMounted: "readonly",
|
|
1821
|
-
onUnmounted: "readonly",
|
|
1822
|
-
reactive: "readonly",
|
|
1823
|
-
ref: "readonly",
|
|
1824
|
-
shallowReactive: "readonly",
|
|
1825
|
-
shallowRef: "readonly",
|
|
1826
|
-
toRef: "readonly",
|
|
1827
|
-
toRefs: "readonly",
|
|
1828
|
-
watch: "readonly",
|
|
1829
|
-
watchEffect: "readonly"
|
|
1830
|
-
}
|
|
1831
|
-
},
|
|
1832
|
-
name: "coderwyd/vue/setup",
|
|
1833
|
-
plugins: {
|
|
1834
|
-
vue: pluginVue
|
|
1835
|
-
}
|
|
1836
|
-
},
|
|
1837
1596
|
{
|
|
1838
1597
|
files,
|
|
1839
1598
|
languageOptions: {
|
|
@@ -1850,16 +1609,10 @@ async function vue(options = {}) {
|
|
|
1850
1609
|
}
|
|
1851
1610
|
},
|
|
1852
1611
|
name: "coderwyd/vue/rules",
|
|
1853
|
-
|
|
1854
|
-
pluginVue
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
blocks: {
|
|
1858
|
-
styles: true,
|
|
1859
|
-
...sfcBlocks.blocks
|
|
1860
|
-
}
|
|
1861
|
-
})
|
|
1862
|
-
]),
|
|
1612
|
+
plugins: {
|
|
1613
|
+
vue: pluginVue
|
|
1614
|
+
},
|
|
1615
|
+
processor: pluginVue.processors[".vue"],
|
|
1863
1616
|
rules: {
|
|
1864
1617
|
...pluginVue.configs.base.rules,
|
|
1865
1618
|
...vueRules,
|
|
@@ -1891,11 +1644,7 @@ async function vue(options = {}) {
|
|
|
1891
1644
|
}
|
|
1892
1645
|
],
|
|
1893
1646
|
// 'vue/define-props-declaration': ['warn', 'type-based'],
|
|
1894
|
-
"vue/dot-location": ["error", "property"],
|
|
1895
|
-
"vue/dot-notation": ["error", { allowKeywords: true }],
|
|
1896
1647
|
"vue/eqeqeq": ["error", "smart"],
|
|
1897
|
-
"vue/html-indent": ["error", indent],
|
|
1898
|
-
"vue/html-quotes": ["error", "double"],
|
|
1899
1648
|
"vue/html-self-closing": [
|
|
1900
1649
|
"error",
|
|
1901
1650
|
{
|
|
@@ -1912,7 +1661,6 @@ async function vue(options = {}) {
|
|
|
1912
1661
|
"vue/multi-word-component-names": "off",
|
|
1913
1662
|
// 'vue/next-tick-style': ['warn', 'promise'],
|
|
1914
1663
|
"vue/no-constant-condition": "warn",
|
|
1915
|
-
"vue/no-dupe-keys": "off",
|
|
1916
1664
|
"vue/no-duplicate-attr-inheritance": "warn",
|
|
1917
1665
|
"vue/no-empty-pattern": "error",
|
|
1918
1666
|
"vue/no-extra-parens": ["error", "functions"],
|
|
@@ -1944,6 +1692,7 @@ async function vue(options = {}) {
|
|
|
1944
1692
|
ignoreConstructors: false
|
|
1945
1693
|
}
|
|
1946
1694
|
],
|
|
1695
|
+
"vue/padding-line-between-blocks": ["error", "always"],
|
|
1947
1696
|
"vue/prefer-define-options": "warn",
|
|
1948
1697
|
"vue/prefer-separate-static-class": "error",
|
|
1949
1698
|
"vue/prefer-template": "error",
|
|
@@ -1964,50 +1713,6 @@ async function vue(options = {}) {
|
|
|
1964
1713
|
"vue/space-infix-ops": "error",
|
|
1965
1714
|
"vue/space-unary-ops": ["error", { nonwords: false, words: true }],
|
|
1966
1715
|
"vue/valid-define-options": "warn",
|
|
1967
|
-
...stylistic2 ? {
|
|
1968
|
-
"vue/array-bracket-spacing": ["error", "never"],
|
|
1969
|
-
"vue/arrow-spacing": ["error", { after: true, before: true }],
|
|
1970
|
-
"vue/block-spacing": ["error", "always"],
|
|
1971
|
-
"vue/block-tag-newline": [
|
|
1972
|
-
"error",
|
|
1973
|
-
{
|
|
1974
|
-
multiline: "always",
|
|
1975
|
-
singleline: "always"
|
|
1976
|
-
}
|
|
1977
|
-
],
|
|
1978
|
-
"vue/brace-style": [
|
|
1979
|
-
"error",
|
|
1980
|
-
"stroustrup",
|
|
1981
|
-
{ allowSingleLine: true }
|
|
1982
|
-
],
|
|
1983
|
-
"vue/comma-dangle": ["error", "always-multiline"],
|
|
1984
|
-
"vue/comma-spacing": ["error", { after: true, before: false }],
|
|
1985
|
-
"vue/comma-style": ["error", "last"],
|
|
1986
|
-
"vue/html-comment-content-newline": "warn",
|
|
1987
|
-
"vue/html-comment-content-spacing": [
|
|
1988
|
-
"error",
|
|
1989
|
-
"always",
|
|
1990
|
-
{
|
|
1991
|
-
exceptions: ["-"]
|
|
1992
|
-
}
|
|
1993
|
-
],
|
|
1994
|
-
"vue/key-spacing": [
|
|
1995
|
-
"error",
|
|
1996
|
-
{ afterColon: true, beforeColon: false }
|
|
1997
|
-
],
|
|
1998
|
-
"vue/keyword-spacing": ["error", { after: true, before: true }],
|
|
1999
|
-
"vue/object-curly-newline": "off",
|
|
2000
|
-
"vue/object-curly-spacing": ["error", "always"],
|
|
2001
|
-
"vue/object-property-newline": [
|
|
2002
|
-
"error",
|
|
2003
|
-
{ allowMultiplePropertiesPerLine: true }
|
|
2004
|
-
],
|
|
2005
|
-
"vue/operator-linebreak": ["error", "before"],
|
|
2006
|
-
"vue/padding-line-between-blocks": ["error", "always"],
|
|
2007
|
-
"vue/quote-props": ["error", "consistent-as-needed"],
|
|
2008
|
-
"vue/space-in-parens": ["error", "never"],
|
|
2009
|
-
"vue/template-curly-spacing": "error"
|
|
2010
|
-
} : {},
|
|
2011
1716
|
...overrides
|
|
2012
1717
|
}
|
|
2013
1718
|
}
|
|
@@ -2029,23 +1734,17 @@ var defaultPluginRenaming = {
|
|
|
2029
1734
|
"@eslint-react/dom": "react-dom",
|
|
2030
1735
|
"@eslint-react/hooks-extra": "react-hooks-extra",
|
|
2031
1736
|
"@eslint-react/naming-convention": "react-naming-convention",
|
|
2032
|
-
"@stylistic": "style",
|
|
2033
1737
|
"@typescript-eslint": "ts",
|
|
2034
1738
|
"import-x": "import",
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
1739
|
+
n: "node",
|
|
1740
|
+
vitest: "test",
|
|
1741
|
+
yml: "yaml"
|
|
2038
1742
|
};
|
|
2039
1743
|
async function defineConfig(options = {}, ...userConfigs) {
|
|
2040
1744
|
const {
|
|
2041
1745
|
autoRenamePlugins = true,
|
|
2042
1746
|
componentExts = [],
|
|
2043
|
-
formatter: formatterOptions = {
|
|
2044
|
-
css: true,
|
|
2045
|
-
html: true
|
|
2046
|
-
},
|
|
2047
1747
|
gitignore: enableGitignore = true,
|
|
2048
|
-
jsx: enableJsx = true,
|
|
2049
1748
|
react: enableReact = false,
|
|
2050
1749
|
regexp: enableRegexp = true,
|
|
2051
1750
|
svelte: enableSvelte = false,
|
|
@@ -2058,11 +1757,10 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2058
1757
|
if (isInEditor2 == null) {
|
|
2059
1758
|
isInEditor2 = isInEditorEnv();
|
|
2060
1759
|
if (isInEditor2)
|
|
2061
|
-
console.log(
|
|
1760
|
+
console.log(
|
|
1761
|
+
"[@coderwyd/eslint-config] Detected running in editor, some rules are disabled."
|
|
1762
|
+
);
|
|
2062
1763
|
}
|
|
2063
|
-
const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
|
|
2064
|
-
if (stylisticOptions && !("jsx" in stylisticOptions))
|
|
2065
|
-
stylisticOptions.jsx = enableJsx;
|
|
2066
1764
|
const configs2 = [];
|
|
2067
1765
|
if (enableGitignore) {
|
|
2068
1766
|
if (typeof enableGitignore !== "boolean") {
|
|
@@ -2075,7 +1773,11 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2075
1773
|
])
|
|
2076
1774
|
);
|
|
2077
1775
|
} else {
|
|
2078
|
-
configs2.push(
|
|
1776
|
+
configs2.push(
|
|
1777
|
+
interopDefault(import("eslint-config-flat-gitignore")).then((r) => [
|
|
1778
|
+
r({ name: "coderwyd/gitignore", strict: false })
|
|
1779
|
+
])
|
|
1780
|
+
);
|
|
2079
1781
|
}
|
|
2080
1782
|
}
|
|
2081
1783
|
const typescriptOptions = resolveSubOptions(options, "typescript");
|
|
@@ -2088,22 +1790,15 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2088
1790
|
}),
|
|
2089
1791
|
comments(),
|
|
2090
1792
|
node(),
|
|
2091
|
-
jsdoc(
|
|
2092
|
-
|
|
2093
|
-
}),
|
|
2094
|
-
imports({
|
|
2095
|
-
stylistic: stylisticOptions
|
|
2096
|
-
}),
|
|
1793
|
+
jsdoc(),
|
|
1794
|
+
imports(),
|
|
2097
1795
|
unicorn(),
|
|
2098
1796
|
command(),
|
|
1797
|
+
prettier(),
|
|
2099
1798
|
// Optional plugins (installed but not enabled by default)
|
|
2100
1799
|
perfectionist()
|
|
2101
1800
|
);
|
|
2102
|
-
if (enableVue)
|
|
2103
|
-
componentExts.push("vue");
|
|
2104
|
-
if (enableJsx) {
|
|
2105
|
-
configs2.push(jsx());
|
|
2106
|
-
}
|
|
1801
|
+
if (enableVue) componentExts.push("vue");
|
|
2107
1802
|
if (enableTypeScript) {
|
|
2108
1803
|
configs2.push(
|
|
2109
1804
|
typescript({
|
|
@@ -2113,14 +1808,6 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2113
1808
|
})
|
|
2114
1809
|
);
|
|
2115
1810
|
}
|
|
2116
|
-
if (stylisticOptions) {
|
|
2117
|
-
configs2.push(
|
|
2118
|
-
stylistic({
|
|
2119
|
-
...stylisticOptions,
|
|
2120
|
-
overrides: getOverrides(options, "stylistic")
|
|
2121
|
-
})
|
|
2122
|
-
);
|
|
2123
|
-
}
|
|
2124
1811
|
if (enableRegexp)
|
|
2125
1812
|
configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
|
|
2126
1813
|
if (options.test ?? true) {
|
|
@@ -2136,7 +1823,6 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2136
1823
|
vue({
|
|
2137
1824
|
...resolveSubOptions(options, "vue"),
|
|
2138
1825
|
overrides: getOverrides(options, "typescript"),
|
|
2139
|
-
stylistic: stylisticOptions,
|
|
2140
1826
|
typescript: !!enableTypeScript
|
|
2141
1827
|
})
|
|
2142
1828
|
);
|
|
@@ -2153,7 +1839,6 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2153
1839
|
configs2.push(
|
|
2154
1840
|
svelte({
|
|
2155
1841
|
overrides: getOverrides(options, "svelte"),
|
|
2156
|
-
stylistic: stylisticOptions,
|
|
2157
1842
|
typescript: !!enableTypeScript
|
|
2158
1843
|
})
|
|
2159
1844
|
);
|
|
@@ -2177,32 +1862,23 @@ async function defineConfig(options = {}, ...userConfigs) {
|
|
|
2177
1862
|
if (options.jsonc ?? true) {
|
|
2178
1863
|
configs2.push(
|
|
2179
1864
|
jsonc({
|
|
2180
|
-
overrides: getOverrides(options, "jsonc")
|
|
2181
|
-
stylistic: stylisticOptions
|
|
1865
|
+
overrides: getOverrides(options, "jsonc")
|
|
2182
1866
|
}),
|
|
2183
1867
|
sortPackageJson(),
|
|
2184
1868
|
sortTsconfig()
|
|
2185
1869
|
);
|
|
2186
1870
|
}
|
|
2187
|
-
|
|
2188
|
-
configs2.push(
|
|
2189
|
-
formatter(
|
|
2190
|
-
formatterOptions,
|
|
2191
|
-
typeof stylisticOptions === "boolean" ? {} : stylisticOptions
|
|
2192
|
-
)
|
|
2193
|
-
);
|
|
2194
|
-
}
|
|
2195
|
-
configs2.push(disables());
|
|
1871
|
+
configs2.push(specials());
|
|
2196
1872
|
if ("files" in options) {
|
|
2197
|
-
throw new Error(
|
|
1873
|
+
throw new Error(
|
|
1874
|
+
'[@coderwyd/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.'
|
|
1875
|
+
);
|
|
2198
1876
|
}
|
|
2199
1877
|
const fusedConfig = flatConfigProps.reduce((acc, key) => {
|
|
2200
|
-
if (key in options)
|
|
2201
|
-
acc[key] = options[key];
|
|
1878
|
+
if (key in options) acc[key] = options[key];
|
|
2202
1879
|
return acc;
|
|
2203
1880
|
}, {});
|
|
2204
|
-
if (Object.keys(fusedConfig).length > 0)
|
|
2205
|
-
configs2.push([fusedConfig]);
|
|
1881
|
+
if (Object.keys(fusedConfig).length > 0) configs2.push([fusedConfig]);
|
|
2206
1882
|
const merged = await combine(...configs2, ...userConfigs);
|
|
2207
1883
|
if (autoRenamePlugins)
|
|
2208
1884
|
return renamePluginInConfigs(merged, defaultPluginRenaming);
|