@2030/eslint-config 2.0.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/dist/index.cjs DELETED
@@ -1,2756 +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_SVG: () => GLOB_SVG,
56
- GLOB_TESTS: () => GLOB_TESTS,
57
- GLOB_TOML: () => GLOB_TOML,
58
- GLOB_TS: () => GLOB_TS,
59
- GLOB_TSX: () => GLOB_TSX,
60
- GLOB_VUE: () => GLOB_VUE,
61
- GLOB_XML: () => GLOB_XML,
62
- GLOB_YAML: () => GLOB_YAML,
63
- StylisticConfigDefaults: () => StylisticConfigDefaults,
64
- astro: () => astro,
65
- combine: () => combine,
66
- command: () => command,
67
- comments: () => comments,
68
- default: () => src_default,
69
- defaultPluginRenaming: () => defaultPluginRenaming,
70
- disables: () => disables,
71
- ensurePackages: () => ensurePackages,
72
- formatters: () => formatters,
73
- getOverrides: () => getOverrides,
74
- ignores: () => ignores,
75
- imports: () => imports,
76
- interopDefault: () => interopDefault,
77
- isInEditorEnv: () => isInEditorEnv,
78
- isInGitHooksOrLintStaged: () => isInGitHooksOrLintStaged,
79
- isPackageInScope: () => isPackageInScope,
80
- javascript: () => javascript,
81
- jsdoc: () => jsdoc,
82
- jsonc: () => jsonc,
83
- jsx: () => jsx,
84
- jun: () => jun,
85
- markdown: () => markdown,
86
- node: () => node,
87
- parserPlain: () => parserPlain,
88
- perfectionist: () => perfectionist,
89
- react: () => react,
90
- regexp: () => regexp,
91
- renamePluginInConfigs: () => renamePluginInConfigs,
92
- renameRules: () => renameRules,
93
- resolveSubOptions: () => resolveSubOptions,
94
- solid: () => solid,
95
- sortPackageJson: () => sortPackageJson,
96
- sortTsconfig: () => sortTsconfig,
97
- stylistic: () => stylistic,
98
- svelte: () => svelte,
99
- test: () => test,
100
- toArray: () => toArray,
101
- toml: () => toml,
102
- typescript: () => typescript,
103
- unicorn: () => unicorn,
104
- unocss: () => unocss,
105
- vue: () => vue,
106
- yaml: () => yaml
107
- });
108
- module.exports = __toCommonJS(src_exports);
109
-
110
- // node_modules/.pnpm/tsup@8.3.0_jiti@2.3.3_postcss@8.4.41_tsx@4.19.1_typescript@5.6.3_yaml@2.5.0/node_modules/tsup/assets/cjs_shims.js
111
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
112
- var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
113
-
114
- // src/factory.ts
115
- var import_eslint_flat_config_utils = require("eslint-flat-config-utils");
116
- var import_local_pkg4 = require("local-pkg");
117
-
118
- // src/globs.ts
119
- var GLOB_SRC_EXT = "?([cm])[jt]s?(x)";
120
- var GLOB_SRC = "**/*.?([cm])[jt]s?(x)";
121
- var GLOB_JS = "**/*.?([cm])js";
122
- var GLOB_JSX = "**/*.?([cm])jsx";
123
- var GLOB_TS = "**/*.?([cm])ts";
124
- var GLOB_TSX = "**/*.?([cm])tsx";
125
- var GLOB_STYLE = "**/*.{c,le,sc}ss";
126
- var GLOB_CSS = "**/*.css";
127
- var GLOB_POSTCSS = "**/*.{p,post}css";
128
- var GLOB_LESS = "**/*.less";
129
- var GLOB_SCSS = "**/*.scss";
130
- var GLOB_JSON = "**/*.json";
131
- var GLOB_JSON5 = "**/*.json5";
132
- var GLOB_JSONC = "**/*.jsonc";
133
- var GLOB_MARKDOWN = "**/*.md";
134
- var GLOB_MARKDOWN_IN_MARKDOWN = "**/*.md/*.md";
135
- var GLOB_SVELTE = "**/*.svelte";
136
- var GLOB_VUE = "**/*.vue";
137
- var GLOB_YAML = "**/*.y?(a)ml";
138
- var GLOB_TOML = "**/*.toml";
139
- var GLOB_XML = "**/*.xml";
140
- var GLOB_SVG = "**/*.svg";
141
- var GLOB_HTML = "**/*.htm?(l)";
142
- var GLOB_ASTRO = "**/*.astro";
143
- var GLOB_ASTRO_TS = "**/*.astro/*.ts";
144
- var GLOB_GRAPHQL = "**/*.{g,graph}ql";
145
- var GLOB_MARKDOWN_CODE = `${GLOB_MARKDOWN}/${GLOB_SRC}`;
146
- var GLOB_TESTS = [
147
- `**/__tests__/**/*.${GLOB_SRC_EXT}`,
148
- `**/*.spec.${GLOB_SRC_EXT}`,
149
- `**/*.test.${GLOB_SRC_EXT}`,
150
- `**/*.bench.${GLOB_SRC_EXT}`,
151
- `**/*.benchmark.${GLOB_SRC_EXT}`
152
- ];
153
- var GLOB_ALL_SRC = [
154
- GLOB_SRC,
155
- GLOB_STYLE,
156
- GLOB_JSON,
157
- GLOB_JSON5,
158
- GLOB_MARKDOWN,
159
- GLOB_SVELTE,
160
- GLOB_VUE,
161
- GLOB_YAML,
162
- GLOB_XML,
163
- GLOB_HTML
164
- ];
165
- var GLOB_EXCLUDE = [
166
- "**/node_modules",
167
- "**/dist",
168
- "**/package-lock.json",
169
- "**/yarn.lock",
170
- "**/pnpm-lock.yaml",
171
- "**/bun.lockb",
172
- "**/output",
173
- "**/coverage",
174
- "**/temp",
175
- "**/.temp",
176
- "**/tmp",
177
- "**/.tmp",
178
- "**/.history",
179
- "**/.vitepress/cache",
180
- "**/.nuxt",
181
- "**/.next",
182
- "**/.svelte-kit",
183
- "**/.vercel",
184
- "**/.changeset",
185
- "**/.idea",
186
- "**/.cache",
187
- "**/.output",
188
- "**/.vite-inspect",
189
- "**/.yarn",
190
- "**/vite.config.*.timestamp-*",
191
- "**/CHANGELOG*.md",
192
- "**/*.min.*",
193
- "**/LICENSE*",
194
- "**/__snapshots__",
195
- "**/auto-import?(s).d.ts",
196
- "**/components.d.ts"
197
- ];
198
-
199
- // src/utils.ts
200
- var import_node_process = __toESM(require("process"), 1);
201
- var import_node_url = require("url");
202
- var import_local_pkg = require("local-pkg");
203
- var scopeUrl = (0, import_node_url.fileURLToPath)(new URL(".", importMetaUrl));
204
- var isCwdInScope = (0, import_local_pkg.isPackageExists)("@jun2030/eslint-config");
205
- var parserPlain = {
206
- meta: {
207
- name: "parser-plain"
208
- },
209
- parseForESLint: (code) => ({
210
- ast: {
211
- body: [],
212
- comments: [],
213
- loc: { end: code.length, start: 0 },
214
- range: [0, code.length],
215
- tokens: [],
216
- type: "Program"
217
- },
218
- scopeManager: null,
219
- services: { isPlain: true },
220
- visitorKeys: {
221
- Program: []
222
- }
223
- })
224
- };
225
- async function combine(...configs2) {
226
- const resolved = await Promise.all(configs2);
227
- return resolved.flat();
228
- }
229
- function renameRules(rules, map) {
230
- return Object.fromEntries(
231
- Object.entries(rules).map(([key, value]) => {
232
- for (const [from, to] of Object.entries(map)) {
233
- if (key.startsWith(`${from}/`))
234
- return [to + key.slice(from.length), value];
235
- }
236
- return [key, value];
237
- })
238
- );
239
- }
240
- function renamePluginInConfigs(configs2, map) {
241
- return configs2.map((i) => {
242
- const clone = { ...i };
243
- if (clone.rules)
244
- clone.rules = renameRules(clone.rules, map);
245
- if (clone.plugins) {
246
- clone.plugins = Object.fromEntries(
247
- Object.entries(clone.plugins).map(([key, value]) => {
248
- if (key in map)
249
- return [map[key], value];
250
- return [key, value];
251
- })
252
- );
253
- }
254
- return clone;
255
- });
256
- }
257
- function toArray(value) {
258
- return Array.isArray(value) ? value : [value];
259
- }
260
- async function interopDefault(m) {
261
- const resolved = await m;
262
- return resolved.default || resolved;
263
- }
264
- function isPackageInScope(name) {
265
- return (0, import_local_pkg.isPackageExists)(name, { paths: [scopeUrl] });
266
- }
267
- async function ensurePackages(packages) {
268
- if (import_node_process.default.env.CI || import_node_process.default.stdout.isTTY === false || isCwdInScope === false)
269
- return;
270
- const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
271
- if (nonExistingPackages.length === 0)
272
- return;
273
- const p = await import("@clack/prompts");
274
- const result = await p.confirm({
275
- message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?`
276
- });
277
- if (result)
278
- await import("@antfu/install-pkg").then((i) => i.installPackage(nonExistingPackages, { dev: true }));
279
- }
280
- function isInEditorEnv() {
281
- if (import_node_process.default.env.CI)
282
- return false;
283
- if (isInGitHooksOrLintStaged())
284
- return false;
285
- 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);
286
- }
287
- function isInGitHooksOrLintStaged() {
288
- 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"));
289
- }
290
-
291
- // src/configs/astro.ts
292
- async function astro(options = {}) {
293
- const {
294
- files = [GLOB_ASTRO],
295
- overrides = {},
296
- stylistic: stylistic2 = true
297
- } = options;
298
- const [
299
- pluginAstro,
300
- parserAstro,
301
- parserTs
302
- ] = await Promise.all([
303
- interopDefault(import("eslint-plugin-astro")),
304
- interopDefault(import("astro-eslint-parser")),
305
- interopDefault(import("@typescript-eslint/parser"))
306
- ]);
307
- return [
308
- {
309
- name: "jun/astro/setup",
310
- plugins: {
311
- astro: pluginAstro
312
- }
313
- },
314
- {
315
- files,
316
- languageOptions: {
317
- globals: pluginAstro.environments.astro.globals,
318
- parser: parserAstro,
319
- parserOptions: {
320
- extraFileExtensions: [".astro"],
321
- parser: parserTs
322
- },
323
- sourceType: "module"
324
- },
325
- name: "jun/astro/rules",
326
- processor: "astro/client-side-ts",
327
- rules: {
328
- // use recommended rules
329
- "astro/missing-client-only-directive-value": "error",
330
- "astro/no-conflict-set-directives": "error",
331
- "astro/no-deprecated-astro-canonicalurl": "error",
332
- "astro/no-deprecated-astro-fetchcontent": "error",
333
- "astro/no-deprecated-astro-resolve": "error",
334
- "astro/no-deprecated-getentrybyslug": "error",
335
- "astro/no-set-html-directive": "off",
336
- "astro/no-unused-define-vars-in-style": "error",
337
- "astro/semi": "off",
338
- "astro/valid-compile": "error",
339
- ...stylistic2 ? {
340
- "style/indent": "off",
341
- "style/jsx-closing-tag-location": "off",
342
- "style/jsx-one-expression-per-line": "off",
343
- "style/no-multiple-empty-lines": "off"
344
- } : {},
345
- ...overrides
346
- }
347
- }
348
- ];
349
- }
350
-
351
- // src/configs/command.ts
352
- var import_config = __toESM(require("eslint-plugin-command/config"), 1);
353
- async function command() {
354
- return [
355
- {
356
- ...(0, import_config.default)(),
357
- name: "jun/command/rules"
358
- }
359
- ];
360
- }
361
-
362
- // src/plugins.ts
363
- var import_eslint_plugin_eslint_comments = __toESM(require("@eslint-community/eslint-plugin-eslint-comments"), 1);
364
- var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
365
- var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
366
- var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
367
- var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
368
- var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
369
- var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
370
-
371
- // src/configs/comments.ts
372
- async function comments() {
373
- return [
374
- {
375
- name: "jun/eslint-comments/rules",
376
- plugins: {
377
- "eslint-comments": import_eslint_plugin_eslint_comments.default
378
- },
379
- rules: {
380
- "eslint-comments/no-aggregating-enable": "error",
381
- "eslint-comments/no-duplicate-disable": "error",
382
- "eslint-comments/no-unlimited-disable": "error",
383
- "eslint-comments/no-unused-enable": "error"
384
- }
385
- }
386
- ];
387
- }
388
-
389
- // src/configs/disables.ts
390
- async function disables() {
391
- return [
392
- {
393
- files: [`**/scripts/${GLOB_SRC}`],
394
- name: "jun/disables/scripts",
395
- rules: {
396
- "jun/no-top-level-await": "off",
397
- "no-console": "off",
398
- "ts/explicit-function-return-type": "off"
399
- }
400
- },
401
- {
402
- files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
403
- name: "jun/disables/cli",
404
- rules: {
405
- "jun/no-top-level-await": "off",
406
- "no-console": "off"
407
- }
408
- },
409
- {
410
- files: ["**/bin/**/*", `**/bin.${GLOB_SRC_EXT}`],
411
- name: "jun/disables/bin",
412
- rules: {
413
- "jun/no-import-dist": "off",
414
- "jun/no-import-node-modules-by-path": "off"
415
- }
416
- },
417
- {
418
- files: ["**/*.d.?([cm])ts"],
419
- name: "jun/disables/dts",
420
- rules: {
421
- "eslint-comments/no-unlimited-disable": "off",
422
- "import/no-duplicates": "off",
423
- "no-restricted-syntax": "off",
424
- "unused-imports/no-unused-vars": "off"
425
- }
426
- },
427
- {
428
- files: ["**/*.js", "**/*.cjs"],
429
- name: "jun/disables/cjs",
430
- rules: {
431
- "ts/no-require-imports": "off"
432
- }
433
- },
434
- {
435
- files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
436
- name: "jun/disables/config-files",
437
- rules: {
438
- "jun/no-top-level-await": "off",
439
- "no-console": "off",
440
- "ts/explicit-function-return-type": "off"
441
- }
442
- }
443
- ];
444
- }
445
-
446
- // src/configs/formatters.ts
447
- var import_local_pkg2 = require("local-pkg");
448
-
449
- // src/configs/stylistic.ts
450
- var StylisticConfigDefaults = {
451
- braceStyle: "1tbs",
452
- indent: 2,
453
- jsx: true,
454
- quotes: "single",
455
- semi: false
456
- };
457
- async function stylistic(options = {}) {
458
- const {
459
- indent,
460
- jsx: jsx2,
461
- lessOpinionated = false,
462
- overrides = {},
463
- quotes,
464
- semi
465
- } = {
466
- ...StylisticConfigDefaults,
467
- ...options
468
- };
469
- const pluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
470
- const config = pluginStylistic.configs.customize({
471
- flat: true,
472
- indent,
473
- jsx: jsx2,
474
- pluginName: "style",
475
- quotes,
476
- semi
477
- });
478
- return [
479
- {
480
- name: "jun/stylistic/rules",
481
- plugins: {
482
- jun: import_eslint_plugin_antfu.default,
483
- style: pluginStylistic
484
- },
485
- rules: {
486
- ...config.rules,
487
- "jun/consistent-chaining": "error",
488
- "jun/consistent-list-newline": "error",
489
- "style/brace-style": ["error", "1tbs", { allowSingleLine: true }],
490
- ...lessOpinionated ? {
491
- curly: ["error", "all"]
492
- } : {
493
- "jun/curly": "error",
494
- "jun/if-newline": "error",
495
- "jun/top-level-function": "error"
496
- },
497
- ...overrides
498
- }
499
- }
500
- ];
501
- }
502
-
503
- // src/configs/formatters.ts
504
- function mergePrettierOptions(options, overrides = {}) {
505
- return {
506
- ...options,
507
- ...overrides,
508
- plugins: [
509
- ...overrides.plugins || [],
510
- ...options.plugins || []
511
- ]
512
- };
513
- }
514
- async function formatters(options = {}, stylistic2 = {}) {
515
- if (options === true) {
516
- const isPrettierPluginXmlInScope = isPackageInScope("@prettier/plugin-xml");
517
- options = {
518
- astro: isPackageInScope("prettier-plugin-astro"),
519
- css: true,
520
- graphql: true,
521
- html: true,
522
- markdown: true,
523
- slidev: (0, import_local_pkg2.isPackageExists)("@slidev/cli"),
524
- svg: isPrettierPluginXmlInScope,
525
- xml: isPrettierPluginXmlInScope
526
- };
527
- }
528
- await ensurePackages([
529
- "eslint-plugin-format",
530
- options.markdown && options.slidev ? "prettier-plugin-slidev" : void 0,
531
- options.astro ? "prettier-plugin-astro" : void 0,
532
- options.xml || options.svg ? "@prettier/plugin-xml" : void 0
533
- ]);
534
- if (options.slidev && options.markdown !== true && options.markdown !== "prettier")
535
- throw new Error("`slidev` option only works when `markdown` is enabled with `prettier`");
536
- const {
537
- indent,
538
- quotes,
539
- semi
540
- } = {
541
- ...StylisticConfigDefaults,
542
- ...stylistic2
543
- };
544
- const prettierOptions = Object.assign(
545
- {
546
- endOfLine: "auto",
547
- printWidth: 120,
548
- semi,
549
- singleQuote: quotes === "single",
550
- tabWidth: typeof indent === "number" ? indent : 2,
551
- trailingComma: "all",
552
- useTabs: indent === "tab"
553
- },
554
- options.prettierOptions || {}
555
- );
556
- const prettierXmlOptions = {
557
- xmlQuoteAttributes: "double",
558
- xmlSelfClosingSpace: true,
559
- xmlSortAttributesByKey: false,
560
- xmlWhitespaceSensitivity: "ignore"
561
- };
562
- const dprintOptions = Object.assign(
563
- {
564
- indentWidth: typeof indent === "number" ? indent : 2,
565
- quoteStyle: quotes === "single" ? "preferSingle" : "preferDouble",
566
- useTabs: indent === "tab"
567
- },
568
- options.dprintOptions || {}
569
- );
570
- const pluginFormat = await interopDefault(import("eslint-plugin-format"));
571
- const configs2 = [
572
- {
573
- name: "jun/formatter/setup",
574
- plugins: {
575
- format: pluginFormat
576
- }
577
- }
578
- ];
579
- if (options.css) {
580
- configs2.push(
581
- {
582
- files: [GLOB_CSS, GLOB_POSTCSS],
583
- languageOptions: {
584
- parser: parserPlain
585
- },
586
- name: "jun/formatter/css",
587
- rules: {
588
- "format/prettier": [
589
- "error",
590
- mergePrettierOptions(prettierOptions, {
591
- parser: "css"
592
- })
593
- ]
594
- }
595
- },
596
- {
597
- files: [GLOB_SCSS],
598
- languageOptions: {
599
- parser: parserPlain
600
- },
601
- name: "jun/formatter/scss",
602
- rules: {
603
- "format/prettier": [
604
- "error",
605
- mergePrettierOptions(prettierOptions, {
606
- parser: "scss"
607
- })
608
- ]
609
- }
610
- },
611
- {
612
- files: [GLOB_LESS],
613
- languageOptions: {
614
- parser: parserPlain
615
- },
616
- name: "jun/formatter/less",
617
- rules: {
618
- "format/prettier": [
619
- "error",
620
- mergePrettierOptions(prettierOptions, {
621
- parser: "less"
622
- })
623
- ]
624
- }
625
- }
626
- );
627
- }
628
- if (options.html) {
629
- configs2.push({
630
- files: [GLOB_HTML],
631
- languageOptions: {
632
- parser: parserPlain
633
- },
634
- name: "jun/formatter/html",
635
- rules: {
636
- "format/prettier": [
637
- "error",
638
- mergePrettierOptions(prettierOptions, {
639
- parser: "html"
640
- })
641
- ]
642
- }
643
- });
644
- }
645
- if (options.xml) {
646
- configs2.push({
647
- files: [GLOB_XML],
648
- languageOptions: {
649
- parser: parserPlain
650
- },
651
- name: "jun/formatter/xml",
652
- rules: {
653
- "format/prettier": [
654
- "error",
655
- mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
656
- parser: "xml",
657
- plugins: [
658
- "@prettier/plugin-xml"
659
- ]
660
- })
661
- ]
662
- }
663
- });
664
- }
665
- if (options.svg) {
666
- configs2.push({
667
- files: [GLOB_SVG],
668
- languageOptions: {
669
- parser: parserPlain
670
- },
671
- name: "jun/formatter/svg",
672
- rules: {
673
- "format/prettier": [
674
- "error",
675
- mergePrettierOptions({ ...prettierXmlOptions, ...prettierOptions }, {
676
- parser: "xml",
677
- plugins: [
678
- "@prettier/plugin-xml"
679
- ]
680
- })
681
- ]
682
- }
683
- });
684
- }
685
- if (options.markdown) {
686
- const formater = options.markdown === true ? "prettier" : options.markdown;
687
- const GLOB_SLIDEV = !options.slidev ? [] : options.slidev === true ? ["**/slides.md"] : options.slidev.files;
688
- configs2.push({
689
- files: [GLOB_MARKDOWN],
690
- ignores: GLOB_SLIDEV,
691
- languageOptions: {
692
- parser: parserPlain
693
- },
694
- name: "jun/formatter/markdown",
695
- rules: {
696
- [`format/${formater}`]: [
697
- "error",
698
- formater === "prettier" ? mergePrettierOptions(prettierOptions, {
699
- embeddedLanguageFormatting: "off",
700
- parser: "markdown"
701
- }) : {
702
- ...dprintOptions,
703
- language: "markdown"
704
- }
705
- ]
706
- }
707
- });
708
- if (options.slidev) {
709
- configs2.push({
710
- files: GLOB_SLIDEV,
711
- languageOptions: {
712
- parser: parserPlain
713
- },
714
- name: "jun/formatter/slidev",
715
- rules: {
716
- "format/prettier": [
717
- "error",
718
- mergePrettierOptions(prettierOptions, {
719
- embeddedLanguageFormatting: "off",
720
- parser: "slidev",
721
- plugins: [
722
- "prettier-plugin-slidev"
723
- ]
724
- })
725
- ]
726
- }
727
- });
728
- }
729
- }
730
- if (options.astro) {
731
- configs2.push({
732
- files: [GLOB_ASTRO],
733
- languageOptions: {
734
- parser: parserPlain
735
- },
736
- name: "jun/formatter/astro",
737
- rules: {
738
- "format/prettier": [
739
- "error",
740
- mergePrettierOptions(prettierOptions, {
741
- parser: "astro",
742
- plugins: [
743
- "prettier-plugin-astro"
744
- ]
745
- })
746
- ]
747
- }
748
- });
749
- configs2.push({
750
- files: [GLOB_ASTRO, GLOB_ASTRO_TS],
751
- name: "jun/formatter/astro/disables",
752
- rules: {
753
- "style/arrow-parens": "off",
754
- "style/block-spacing": "off",
755
- "style/comma-dangle": "off",
756
- "style/indent": "off",
757
- "style/no-multi-spaces": "off",
758
- "style/quotes": "off",
759
- "style/semi": "off"
760
- }
761
- });
762
- }
763
- if (options.graphql) {
764
- configs2.push({
765
- files: [GLOB_GRAPHQL],
766
- languageOptions: {
767
- parser: parserPlain
768
- },
769
- name: "jun/formatter/graphql",
770
- rules: {
771
- "format/prettier": [
772
- "error",
773
- mergePrettierOptions(prettierOptions, {
774
- parser: "graphql"
775
- })
776
- ]
777
- }
778
- });
779
- }
780
- return configs2;
781
- }
782
-
783
- // src/configs/ignores.ts
784
- async function ignores(userIgnores = []) {
785
- return [
786
- {
787
- ignores: [
788
- ...GLOB_EXCLUDE,
789
- ...userIgnores
790
- ],
791
- name: "jun/ignores"
792
- }
793
- ];
794
- }
795
-
796
- // src/configs/imports.ts
797
- async function imports(options = {}) {
798
- const {
799
- stylistic: stylistic2 = true
800
- } = options;
801
- return [
802
- {
803
- name: "jun/imports/rules",
804
- plugins: {
805
- import: pluginImport,
806
- jun: import_eslint_plugin_antfu.default
807
- },
808
- rules: {
809
- "import/first": "error",
810
- "import/no-duplicates": "error",
811
- "import/no-mutable-exports": "error",
812
- "import/no-named-default": "error",
813
- "import/no-self-import": "error",
814
- "import/no-webpack-loader-syntax": "error",
815
- "jun/import-dedupe": "error",
816
- "jun/no-import-dist": "error",
817
- "jun/no-import-node-modules-by-path": "error",
818
- ...stylistic2 ? {
819
- "import/newline-after-import": ["error", { count: 1 }]
820
- } : {}
821
- }
822
- }
823
- ];
824
- }
825
-
826
- // src/configs/javascript.ts
827
- var import_globals = __toESM(require("globals"), 1);
828
- async function javascript(options = {}) {
829
- const {
830
- isInEditor = false,
831
- overrides = {}
832
- } = options;
833
- return [
834
- {
835
- languageOptions: {
836
- ecmaVersion: 2022,
837
- globals: {
838
- ...import_globals.default.browser,
839
- ...import_globals.default.es2021,
840
- ...import_globals.default.node,
841
- document: "readonly",
842
- navigator: "readonly",
843
- window: "readonly"
844
- },
845
- parserOptions: {
846
- ecmaFeatures: {
847
- jsx: true
848
- },
849
- ecmaVersion: 2022,
850
- sourceType: "module"
851
- },
852
- sourceType: "module"
853
- },
854
- linterOptions: {
855
- reportUnusedDisableDirectives: true
856
- },
857
- name: "jun/javascript/setup"
858
- },
859
- {
860
- name: "jun/javascript/rules",
861
- plugins: {
862
- "jun": import_eslint_plugin_antfu.default,
863
- "unused-imports": import_eslint_plugin_unused_imports.default
864
- },
865
- rules: {
866
- "accessor-pairs": ["error", { enforceForClassMembers: true, setWithoutGet: true }],
867
- "array-callback-return": "error",
868
- "block-scoped-var": "error",
869
- "constructor-super": "error",
870
- "default-case-last": "error",
871
- "dot-notation": ["error", { allowKeywords: true }],
872
- "eqeqeq": ["error", "smart"],
873
- "jun/no-top-level-await": "error",
874
- "new-cap": ["error", { capIsNew: false, newIsCap: true, properties: true }],
875
- "no-alert": "error",
876
- "no-array-constructor": "error",
877
- "no-async-promise-executor": "error",
878
- "no-caller": "error",
879
- "no-case-declarations": "error",
880
- "no-class-assign": "error",
881
- "no-compare-neg-zero": "error",
882
- "no-cond-assign": ["error", "always"],
883
- "no-console": ["error", { allow: ["warn", "error"] }],
884
- "no-const-assign": "error",
885
- "no-control-regex": "error",
886
- "no-debugger": "error",
887
- "no-delete-var": "error",
888
- "no-dupe-args": "error",
889
- "no-dupe-class-members": "error",
890
- "no-dupe-keys": "error",
891
- "no-duplicate-case": "error",
892
- "no-empty": ["error", { allowEmptyCatch: true }],
893
- "no-empty-character-class": "error",
894
- "no-empty-pattern": "error",
895
- "no-eval": "error",
896
- "no-ex-assign": "error",
897
- "no-extend-native": "error",
898
- "no-extra-bind": "error",
899
- "no-extra-boolean-cast": "error",
900
- "no-fallthrough": "error",
901
- "no-func-assign": "error",
902
- "no-global-assign": "error",
903
- "no-implied-eval": "error",
904
- "no-import-assign": "error",
905
- "no-invalid-regexp": "error",
906
- "no-irregular-whitespace": "error",
907
- "no-iterator": "error",
908
- "no-labels": ["error", { allowLoop: false, allowSwitch: false }],
909
- "no-lone-blocks": "error",
910
- "no-loss-of-precision": "error",
911
- "no-misleading-character-class": "error",
912
- "no-multi-str": "error",
913
- "no-new": "error",
914
- "no-new-func": "error",
915
- "no-new-native-nonconstructor": "error",
916
- "no-new-wrappers": "error",
917
- "no-obj-calls": "error",
918
- "no-octal": "error",
919
- "no-octal-escape": "error",
920
- "no-proto": "error",
921
- "no-prototype-builtins": "error",
922
- "no-redeclare": ["error", { builtinGlobals: false }],
923
- "no-regex-spaces": "error",
924
- "no-restricted-globals": [
925
- "error",
926
- { message: "Use `globalThis` instead.", name: "global" },
927
- { message: "Use `globalThis` instead.", name: "self" }
928
- ],
929
- "no-restricted-properties": [
930
- "error",
931
- { message: "Use `Object.getPrototypeOf` or `Object.setPrototypeOf` instead.", property: "__proto__" },
932
- { message: "Use `Object.defineProperty` instead.", property: "__defineGetter__" },
933
- { message: "Use `Object.defineProperty` instead.", property: "__defineSetter__" },
934
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupGetter__" },
935
- { message: "Use `Object.getOwnPropertyDescriptor` instead.", property: "__lookupSetter__" }
936
- ],
937
- "no-restricted-syntax": [
938
- "error",
939
- "TSEnumDeclaration[const=true]",
940
- "TSExportAssignment"
941
- ],
942
- "no-self-assign": ["error", { props: true }],
943
- "no-self-compare": "error",
944
- "no-sequences": "error",
945
- "no-shadow-restricted-names": "error",
946
- "no-sparse-arrays": "error",
947
- "no-template-curly-in-string": "error",
948
- "no-this-before-super": "error",
949
- "no-throw-literal": "error",
950
- "no-undef": "error",
951
- "no-undef-init": "error",
952
- "no-unexpected-multiline": "error",
953
- "no-unmodified-loop-condition": "error",
954
- "no-unneeded-ternary": ["error", { defaultAssignment: false }],
955
- "no-unreachable": "error",
956
- "no-unreachable-loop": "error",
957
- "no-unsafe-finally": "error",
958
- "no-unsafe-negation": "error",
959
- "no-unused-expressions": ["error", {
960
- allowShortCircuit: true,
961
- allowTaggedTemplates: true,
962
- allowTernary: true
963
- }],
964
- "no-unused-vars": ["error", {
965
- args: "none",
966
- caughtErrors: "none",
967
- ignoreRestSiblings: true,
968
- vars: "all"
969
- }],
970
- "no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
971
- "no-useless-backreference": "error",
972
- "no-useless-call": "error",
973
- "no-useless-catch": "error",
974
- "no-useless-computed-key": "error",
975
- "no-useless-constructor": "error",
976
- "no-useless-rename": "error",
977
- "no-useless-return": "error",
978
- "no-var": "error",
979
- "no-with": "error",
980
- "object-shorthand": [
981
- "error",
982
- "always",
983
- {
984
- avoidQuotes: true,
985
- ignoreConstructors: false
986
- }
987
- ],
988
- "one-var": ["error", { initialized: "never" }],
989
- "prefer-arrow-callback": [
990
- "error",
991
- {
992
- allowNamedFunctions: false,
993
- allowUnboundThis: true
994
- }
995
- ],
996
- "prefer-const": [
997
- "error",
998
- {
999
- destructuring: "all",
1000
- ignoreReadBeforeAssign: true
1001
- }
1002
- ],
1003
- "prefer-exponentiation-operator": "error",
1004
- "prefer-promise-reject-errors": "error",
1005
- "prefer-regex-literals": ["error", { disallowRedundantWrapping: true }],
1006
- "prefer-rest-params": "error",
1007
- "prefer-spread": "error",
1008
- "prefer-template": "error",
1009
- "symbol-description": "error",
1010
- "unicode-bom": ["error", "never"],
1011
- "unused-imports/no-unused-imports": isInEditor ? "off" : "error",
1012
- "unused-imports/no-unused-vars": [
1013
- "error",
1014
- {
1015
- args: "after-used",
1016
- argsIgnorePattern: "^_",
1017
- ignoreRestSiblings: true,
1018
- vars: "all",
1019
- varsIgnorePattern: "^_"
1020
- }
1021
- ],
1022
- "use-isnan": ["error", { enforceForIndexOf: true, enforceForSwitchCase: true }],
1023
- "valid-typeof": ["error", { requireStringLiterals: true }],
1024
- "vars-on-top": "error",
1025
- "yoda": ["error", "never"],
1026
- ...overrides
1027
- }
1028
- }
1029
- ];
1030
- }
1031
-
1032
- // src/configs/jsdoc.ts
1033
- async function jsdoc(options = {}) {
1034
- const {
1035
- stylistic: stylistic2 = true
1036
- } = options;
1037
- return [
1038
- {
1039
- name: "jun/jsdoc/rules",
1040
- plugins: {
1041
- jsdoc: await interopDefault(import("eslint-plugin-jsdoc"))
1042
- },
1043
- rules: {
1044
- "jsdoc/check-access": "warn",
1045
- "jsdoc/check-param-names": "warn",
1046
- "jsdoc/check-property-names": "warn",
1047
- "jsdoc/check-types": "warn",
1048
- "jsdoc/empty-tags": "warn",
1049
- "jsdoc/implements-on-classes": "warn",
1050
- "jsdoc/no-defaults": "warn",
1051
- "jsdoc/no-multi-asterisks": "warn",
1052
- "jsdoc/require-param-name": "warn",
1053
- "jsdoc/require-property": "warn",
1054
- "jsdoc/require-property-description": "warn",
1055
- "jsdoc/require-property-name": "warn",
1056
- "jsdoc/require-returns-check": "warn",
1057
- "jsdoc/require-returns-description": "warn",
1058
- "jsdoc/require-yields-check": "warn",
1059
- ...stylistic2 ? {
1060
- "jsdoc/check-alignment": "warn",
1061
- "jsdoc/multiline-blocks": "warn"
1062
- } : {}
1063
- }
1064
- }
1065
- ];
1066
- }
1067
-
1068
- // src/configs/jsonc.ts
1069
- async function jsonc(options = {}) {
1070
- const {
1071
- files = [GLOB_JSON, GLOB_JSON5, GLOB_JSONC],
1072
- overrides = {},
1073
- stylistic: stylistic2 = true
1074
- } = options;
1075
- const {
1076
- indent = 2
1077
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1078
- const [
1079
- pluginJsonc,
1080
- parserJsonc
1081
- ] = await Promise.all([
1082
- interopDefault(import("eslint-plugin-jsonc")),
1083
- interopDefault(import("jsonc-eslint-parser"))
1084
- ]);
1085
- return [
1086
- {
1087
- name: "jun/jsonc/setup",
1088
- plugins: {
1089
- jsonc: pluginJsonc
1090
- }
1091
- },
1092
- {
1093
- files,
1094
- languageOptions: {
1095
- parser: parserJsonc
1096
- },
1097
- name: "jun/jsonc/rules",
1098
- rules: {
1099
- "jsonc/no-bigint-literals": "error",
1100
- "jsonc/no-binary-expression": "error",
1101
- "jsonc/no-binary-numeric-literals": "error",
1102
- "jsonc/no-dupe-keys": "error",
1103
- "jsonc/no-escape-sequence-in-identifier": "error",
1104
- "jsonc/no-floating-decimal": "error",
1105
- "jsonc/no-hexadecimal-numeric-literals": "error",
1106
- "jsonc/no-infinity": "error",
1107
- "jsonc/no-multi-str": "error",
1108
- "jsonc/no-nan": "error",
1109
- "jsonc/no-number-props": "error",
1110
- "jsonc/no-numeric-separators": "error",
1111
- "jsonc/no-octal": "error",
1112
- "jsonc/no-octal-escape": "error",
1113
- "jsonc/no-octal-numeric-literals": "error",
1114
- "jsonc/no-parenthesized": "error",
1115
- "jsonc/no-plus-sign": "error",
1116
- "jsonc/no-regexp-literals": "error",
1117
- "jsonc/no-sparse-arrays": "error",
1118
- "jsonc/no-template-literals": "error",
1119
- "jsonc/no-undefined-value": "error",
1120
- "jsonc/no-unicode-codepoint-escapes": "error",
1121
- "jsonc/no-useless-escape": "error",
1122
- "jsonc/space-unary-ops": "error",
1123
- "jsonc/valid-json-number": "error",
1124
- "jsonc/vue-custom-block/no-parsing-error": "error",
1125
- ...stylistic2 ? {
1126
- "jsonc/array-bracket-spacing": ["error", "never"],
1127
- "jsonc/comma-dangle": ["error", "never"],
1128
- "jsonc/comma-style": ["error", "last"],
1129
- "jsonc/indent": ["error", indent],
1130
- "jsonc/key-spacing": ["error", { afterColon: true, beforeColon: false }],
1131
- "jsonc/object-curly-newline": ["error", { consistent: true, multiline: true }],
1132
- "jsonc/object-curly-spacing": ["error", "always"],
1133
- "jsonc/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
1134
- "jsonc/quote-props": "error",
1135
- "jsonc/quotes": "error"
1136
- } : {},
1137
- ...overrides
1138
- }
1139
- }
1140
- ];
1141
- }
1142
-
1143
- // src/configs/jsx.ts
1144
- async function jsx() {
1145
- return [
1146
- {
1147
- files: [GLOB_JSX, GLOB_TSX],
1148
- languageOptions: {
1149
- parserOptions: {
1150
- ecmaFeatures: {
1151
- jsx: true
1152
- }
1153
- }
1154
- },
1155
- name: "jun/jsx/setup"
1156
- }
1157
- ];
1158
- }
1159
-
1160
- // src/configs/markdown.ts
1161
- var import_eslint_merge_processors = require("eslint-merge-processors");
1162
- async function markdown(options = {}) {
1163
- const {
1164
- componentExts = [],
1165
- files = [GLOB_MARKDOWN],
1166
- overrides = {}
1167
- } = options;
1168
- const markdown2 = await interopDefault(import("@eslint/markdown"));
1169
- return [
1170
- {
1171
- name: "jun/markdown/setup",
1172
- plugins: {
1173
- markdown: markdown2
1174
- }
1175
- },
1176
- {
1177
- files,
1178
- ignores: [GLOB_MARKDOWN_IN_MARKDOWN],
1179
- name: "jun/markdown/processor",
1180
- // `eslint-plugin-markdown` only creates virtual files for code blocks,
1181
- // but not the markdown file itself. We use `eslint-merge-processors` to
1182
- // add a pass-through processor for the markdown file itself.
1183
- processor: (0, import_eslint_merge_processors.mergeProcessors)([
1184
- markdown2.processors.markdown,
1185
- import_eslint_merge_processors.processorPassThrough
1186
- ])
1187
- },
1188
- {
1189
- files,
1190
- languageOptions: {
1191
- parser: parserPlain
1192
- },
1193
- name: "jun/markdown/parser"
1194
- },
1195
- {
1196
- files: [
1197
- GLOB_MARKDOWN_CODE,
1198
- ...componentExts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)
1199
- ],
1200
- languageOptions: {
1201
- parserOptions: {
1202
- ecmaFeatures: {
1203
- impliedStrict: true
1204
- }
1205
- }
1206
- },
1207
- name: "jun/markdown/disables",
1208
- rules: {
1209
- "import/newline-after-import": "off",
1210
- "jun/no-top-level-await": "off",
1211
- "no-alert": "off",
1212
- "no-console": "off",
1213
- "no-labels": "off",
1214
- "no-lone-blocks": "off",
1215
- "no-restricted-syntax": "off",
1216
- "no-undef": "off",
1217
- "no-unused-expressions": "off",
1218
- "no-unused-labels": "off",
1219
- "no-unused-vars": "off",
1220
- "node/prefer-global/process": "off",
1221
- "style/comma-dangle": "off",
1222
- "style/eol-last": "off",
1223
- "ts/consistent-type-imports": "off",
1224
- "ts/explicit-function-return-type": "off",
1225
- "ts/no-namespace": "off",
1226
- "ts/no-redeclare": "off",
1227
- "ts/no-require-imports": "off",
1228
- "ts/no-unused-expressions": "off",
1229
- "ts/no-unused-vars": "off",
1230
- "ts/no-use-before-define": "off",
1231
- "unicode-bom": "off",
1232
- "unused-imports/no-unused-imports": "off",
1233
- "unused-imports/no-unused-vars": "off",
1234
- ...overrides
1235
- }
1236
- }
1237
- ];
1238
- }
1239
-
1240
- // src/configs/node.ts
1241
- async function node() {
1242
- return [
1243
- {
1244
- name: "jun/node/rules",
1245
- plugins: {
1246
- node: import_eslint_plugin_n.default
1247
- },
1248
- rules: {
1249
- "node/handle-callback-err": ["error", "^(err|error)$"],
1250
- "node/no-deprecated-api": "error",
1251
- "node/no-exports-assign": "error",
1252
- "node/no-new-require": "error",
1253
- "node/no-path-concat": "error",
1254
- "node/prefer-global/buffer": ["error", "never"],
1255
- "node/prefer-global/process": ["error", "never"],
1256
- "node/process-exit-as-throw": "error"
1257
- }
1258
- }
1259
- ];
1260
- }
1261
-
1262
- // src/configs/perfectionist.ts
1263
- async function perfectionist() {
1264
- return [
1265
- {
1266
- name: "jun/perfectionist/setup",
1267
- plugins: {
1268
- perfectionist: import_eslint_plugin_perfectionist.default
1269
- },
1270
- rules: {
1271
- "perfectionist/sort-exports": ["error", { order: "asc", type: "natural" }],
1272
- "perfectionist/sort-imports": ["error", {
1273
- groups: [
1274
- "type",
1275
- ["parent-type", "sibling-type", "index-type"],
1276
- "builtin",
1277
- "external",
1278
- ["internal", "internal-type"],
1279
- ["parent", "sibling", "index"],
1280
- "side-effect",
1281
- "object",
1282
- "unknown"
1283
- ],
1284
- newlinesBetween: "ignore",
1285
- order: "asc",
1286
- type: "natural"
1287
- }],
1288
- "perfectionist/sort-named-exports": ["error", { order: "asc", type: "natural" }],
1289
- "perfectionist/sort-named-imports": ["error", { order: "asc", type: "natural" }]
1290
- }
1291
- }
1292
- ];
1293
- }
1294
-
1295
- // src/configs/react.ts
1296
- var import_local_pkg3 = require("local-pkg");
1297
- var ReactRefreshAllowConstantExportPackages = [
1298
- "vite"
1299
- ];
1300
- var RemixPackages = [
1301
- "@remix-run/node",
1302
- "@remix-run/react",
1303
- "@remix-run/serve",
1304
- "@remix-run/dev"
1305
- ];
1306
- var NextJsPackages = [
1307
- "next"
1308
- ];
1309
- async function react(options = {}) {
1310
- const {
1311
- files = [GLOB_SRC],
1312
- overrides = {}
1313
- } = options;
1314
- await ensurePackages([
1315
- "@eslint-react/eslint-plugin",
1316
- "eslint-plugin-react-hooks",
1317
- "eslint-plugin-react-refresh"
1318
- ]);
1319
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1320
- const isTypeAware = !!tsconfigPath;
1321
- const [
1322
- pluginReact,
1323
- pluginReactHooks,
1324
- pluginReactRefresh,
1325
- parserTs
1326
- ] = await Promise.all([
1327
- interopDefault(import("@eslint-react/eslint-plugin")),
1328
- interopDefault(import("eslint-plugin-react-hooks")),
1329
- interopDefault(import("eslint-plugin-react-refresh")),
1330
- interopDefault(import("@typescript-eslint/parser"))
1331
- ]);
1332
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1333
- const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1334
- const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg3.isPackageExists)(i));
1335
- const plugins = pluginReact.configs.all.plugins;
1336
- return [
1337
- {
1338
- name: "jun/react/setup",
1339
- plugins: {
1340
- "react": plugins["@eslint-react"],
1341
- "react-dom": plugins["@eslint-react/dom"],
1342
- "react-hooks": pluginReactHooks,
1343
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
1344
- "react-naming-convention": plugins["@eslint-react/naming-convention"],
1345
- "react-refresh": pluginReactRefresh
1346
- }
1347
- },
1348
- {
1349
- files,
1350
- languageOptions: {
1351
- parser: parserTs,
1352
- parserOptions: {
1353
- ecmaFeatures: {
1354
- jsx: true
1355
- },
1356
- ...isTypeAware ? { project: tsconfigPath } : {}
1357
- },
1358
- sourceType: "module"
1359
- },
1360
- name: "jun/react/rules",
1361
- rules: {
1362
- // recommended rules from @eslint-react/dom
1363
- "react-dom/no-children-in-void-dom-elements": "warn",
1364
- "react-dom/no-dangerously-set-innerhtml": "warn",
1365
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
1366
- "react-dom/no-find-dom-node": "error",
1367
- "react-dom/no-missing-button-type": "warn",
1368
- "react-dom/no-missing-iframe-sandbox": "warn",
1369
- "react-dom/no-namespace": "error",
1370
- "react-dom/no-render-return-value": "error",
1371
- "react-dom/no-script-url": "warn",
1372
- "react-dom/no-unsafe-iframe-sandbox": "warn",
1373
- "react-dom/no-unsafe-target-blank": "warn",
1374
- // recommended rules react-hooks
1375
- "react-hooks/exhaustive-deps": "warn",
1376
- "react-hooks/rules-of-hooks": "error",
1377
- // react refresh
1378
- "react-refresh/only-export-components": [
1379
- "warn",
1380
- {
1381
- allowConstantExport: isAllowConstantExport,
1382
- allowExportNames: [
1383
- ...isUsingNext ? [
1384
- "dynamic",
1385
- "dynamicParams",
1386
- "revalidate",
1387
- "fetchCache",
1388
- "runtime",
1389
- "preferredRegion",
1390
- "maxDuration",
1391
- "config",
1392
- "generateStaticParams",
1393
- "metadata",
1394
- "generateMetadata",
1395
- "viewport",
1396
- "generateViewport"
1397
- ] : [],
1398
- ...isUsingRemix ? [
1399
- "meta",
1400
- "links",
1401
- "headers",
1402
- "loader",
1403
- "action"
1404
- ] : []
1405
- ]
1406
- }
1407
- ],
1408
- // recommended rules from @eslint-react
1409
- "react/ensure-forward-ref-using-ref": "warn",
1410
- "react/no-access-state-in-setstate": "error",
1411
- "react/no-array-index-key": "warn",
1412
- "react/no-children-count": "warn",
1413
- "react/no-children-for-each": "warn",
1414
- "react/no-children-map": "warn",
1415
- "react/no-children-only": "warn",
1416
- "react/no-children-prop": "warn",
1417
- "react/no-children-to-array": "warn",
1418
- "react/no-clone-element": "warn",
1419
- "react/no-comment-textnodes": "warn",
1420
- "react/no-component-will-mount": "error",
1421
- "react/no-component-will-receive-props": "error",
1422
- "react/no-component-will-update": "error",
1423
- "react/no-create-ref": "error",
1424
- "react/no-direct-mutation-state": "error",
1425
- "react/no-duplicate-key": "error",
1426
- "react/no-implicit-key": "error",
1427
- "react/no-missing-key": "error",
1428
- "react/no-nested-components": "warn",
1429
- "react/no-redundant-should-component-update": "error",
1430
- "react/no-set-state-in-component-did-mount": "warn",
1431
- "react/no-set-state-in-component-did-update": "warn",
1432
- "react/no-set-state-in-component-will-update": "warn",
1433
- "react/no-string-refs": "error",
1434
- "react/no-unsafe-component-will-mount": "warn",
1435
- "react/no-unsafe-component-will-receive-props": "warn",
1436
- "react/no-unsafe-component-will-update": "warn",
1437
- "react/no-unstable-context-value": "error",
1438
- "react/no-unstable-default-props": "error",
1439
- "react/no-unused-class-component-members": "warn",
1440
- "react/no-unused-state": "warn",
1441
- "react/no-useless-fragment": "warn",
1442
- "react/prefer-destructuring-assignment": "warn",
1443
- "react/prefer-shorthand-boolean": "warn",
1444
- "react/prefer-shorthand-fragment": "warn",
1445
- ...isTypeAware ? {
1446
- "react/no-leaked-conditional-rendering": "warn"
1447
- } : {},
1448
- // overrides
1449
- ...overrides
1450
- }
1451
- }
1452
- ];
1453
- }
1454
-
1455
- // src/configs/regexp.ts
1456
- var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1457
- async function regexp(options = {}) {
1458
- const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1459
- const rules = {
1460
- ...config.rules
1461
- };
1462
- if (options.level === "warn") {
1463
- for (const key in rules) {
1464
- if (rules[key] === "error")
1465
- rules[key] = "warn";
1466
- }
1467
- }
1468
- return [
1469
- {
1470
- ...config,
1471
- name: "jun/regexp/rules",
1472
- rules: {
1473
- ...rules,
1474
- ...options.overrides
1475
- }
1476
- }
1477
- ];
1478
- }
1479
-
1480
- // src/configs/solid.ts
1481
- async function solid(options = {}) {
1482
- const {
1483
- files = [GLOB_JSX, GLOB_TSX],
1484
- overrides = {},
1485
- typescript: typescript2 = true
1486
- } = options;
1487
- await ensurePackages([
1488
- "eslint-plugin-solid"
1489
- ]);
1490
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1491
- const isTypeAware = !!tsconfigPath;
1492
- const [
1493
- pluginSolid,
1494
- parserTs
1495
- ] = await Promise.all([
1496
- interopDefault(import("eslint-plugin-solid")),
1497
- interopDefault(import("@typescript-eslint/parser"))
1498
- ]);
1499
- return [
1500
- {
1501
- name: "jun/solid/setup",
1502
- plugins: {
1503
- solid: pluginSolid
1504
- }
1505
- },
1506
- {
1507
- files,
1508
- languageOptions: {
1509
- parser: parserTs,
1510
- parserOptions: {
1511
- ecmaFeatures: {
1512
- jsx: true
1513
- },
1514
- ...isTypeAware ? { project: tsconfigPath } : {}
1515
- },
1516
- sourceType: "module"
1517
- },
1518
- name: "jun/solid/rules",
1519
- rules: {
1520
- // reactivity
1521
- "solid/components-return-once": "warn",
1522
- "solid/event-handlers": ["error", {
1523
- // if true, don't warn on ambiguously named event handlers like `onclick` or `onchange`
1524
- ignoreCase: false,
1525
- // if true, warn when spreading event handlers onto JSX. Enable for Solid < v1.6.
1526
- warnOnSpread: false
1527
- }],
1528
- // these rules are mostly style suggestions
1529
- "solid/imports": "error",
1530
- // identifier usage is important
1531
- "solid/jsx-no-duplicate-props": "error",
1532
- "solid/jsx-no-script-url": "error",
1533
- "solid/jsx-no-undef": "error",
1534
- "solid/jsx-uses-vars": "error",
1535
- "solid/no-destructure": "error",
1536
- // security problems
1537
- "solid/no-innerhtml": ["error", { allowStatic: true }],
1538
- "solid/no-react-deps": "error",
1539
- "solid/no-react-specific-props": "error",
1540
- "solid/no-unknown-namespaces": "error",
1541
- "solid/prefer-for": "error",
1542
- "solid/reactivity": "warn",
1543
- "solid/self-closing-comp": "error",
1544
- "solid/style-prop": ["error", { styleProps: ["style", "css"] }],
1545
- ...typescript2 ? {
1546
- "solid/jsx-no-undef": ["error", { typescriptEnabled: true }],
1547
- "solid/no-unknown-namespaces": "off"
1548
- } : {},
1549
- // overrides
1550
- ...overrides
1551
- }
1552
- }
1553
- ];
1554
- }
1555
-
1556
- // src/configs/sort.ts
1557
- async function sortPackageJson() {
1558
- return [
1559
- {
1560
- files: ["**/package.json"],
1561
- name: "jun/sort/package-json",
1562
- rules: {
1563
- "jsonc/sort-array-values": [
1564
- "error",
1565
- {
1566
- order: { type: "asc" },
1567
- pathPattern: "^files$"
1568
- }
1569
- ],
1570
- "jsonc/sort-keys": [
1571
- "error",
1572
- {
1573
- order: [
1574
- "publisher",
1575
- "name",
1576
- "displayName",
1577
- "type",
1578
- "version",
1579
- "private",
1580
- "packageManager",
1581
- "description",
1582
- "author",
1583
- "contributors",
1584
- "license",
1585
- "funding",
1586
- "homepage",
1587
- "repository",
1588
- "bugs",
1589
- "keywords",
1590
- "categories",
1591
- "sideEffects",
1592
- "exports",
1593
- "main",
1594
- "module",
1595
- "unpkg",
1596
- "jsdelivr",
1597
- "types",
1598
- "typesVersions",
1599
- "bin",
1600
- "icon",
1601
- "files",
1602
- "engines",
1603
- "activationEvents",
1604
- "contributes",
1605
- "scripts",
1606
- "peerDependencies",
1607
- "peerDependenciesMeta",
1608
- "dependencies",
1609
- "optionalDependencies",
1610
- "devDependencies",
1611
- "pnpm",
1612
- "overrides",
1613
- "resolutions",
1614
- "husky",
1615
- "simple-git-hooks",
1616
- "lint-staged",
1617
- "eslintConfig"
1618
- ],
1619
- pathPattern: "^$"
1620
- },
1621
- {
1622
- order: { type: "asc" },
1623
- pathPattern: "^(?:dev|peer|optional|bundled)?[Dd]ependencies(Meta)?$"
1624
- },
1625
- {
1626
- order: { type: "asc" },
1627
- pathPattern: "^(?:resolutions|overrides|pnpm.overrides)$"
1628
- },
1629
- {
1630
- order: [
1631
- "types",
1632
- "import",
1633
- "require",
1634
- "default"
1635
- ],
1636
- pathPattern: "^exports.*$"
1637
- },
1638
- {
1639
- order: [
1640
- // client hooks only
1641
- "pre-commit",
1642
- "prepare-commit-msg",
1643
- "commit-msg",
1644
- "post-commit",
1645
- "pre-rebase",
1646
- "post-rewrite",
1647
- "post-checkout",
1648
- "post-merge",
1649
- "pre-push",
1650
- "pre-auto-gc"
1651
- ],
1652
- pathPattern: "^(?:gitHooks|husky|simple-git-hooks)$"
1653
- }
1654
- ]
1655
- }
1656
- }
1657
- ];
1658
- }
1659
- function sortTsconfig() {
1660
- return [
1661
- {
1662
- files: ["**/tsconfig.json", "**/tsconfig.*.json"],
1663
- name: "jun/sort/tsconfig-json",
1664
- rules: {
1665
- "jsonc/sort-keys": [
1666
- "error",
1667
- {
1668
- order: [
1669
- "extends",
1670
- "compilerOptions",
1671
- "references",
1672
- "files",
1673
- "include",
1674
- "exclude"
1675
- ],
1676
- pathPattern: "^$"
1677
- },
1678
- {
1679
- order: [
1680
- /* Projects */
1681
- "incremental",
1682
- "composite",
1683
- "tsBuildInfoFile",
1684
- "disableSourceOfProjectReferenceRedirect",
1685
- "disableSolutionSearching",
1686
- "disableReferencedProjectLoad",
1687
- /* Language and Environment */
1688
- "target",
1689
- "jsx",
1690
- "jsxFactory",
1691
- "jsxFragmentFactory",
1692
- "jsxImportSource",
1693
- "lib",
1694
- "moduleDetection",
1695
- "noLib",
1696
- "reactNamespace",
1697
- "useDefineForClassFields",
1698
- "emitDecoratorMetadata",
1699
- "experimentalDecorators",
1700
- /* Modules */
1701
- "baseUrl",
1702
- "rootDir",
1703
- "rootDirs",
1704
- "customConditions",
1705
- "module",
1706
- "moduleResolution",
1707
- "moduleSuffixes",
1708
- "noResolve",
1709
- "paths",
1710
- "resolveJsonModule",
1711
- "resolvePackageJsonExports",
1712
- "resolvePackageJsonImports",
1713
- "typeRoots",
1714
- "types",
1715
- "allowArbitraryExtensions",
1716
- "allowImportingTsExtensions",
1717
- "allowUmdGlobalAccess",
1718
- /* JavaScript Support */
1719
- "allowJs",
1720
- "checkJs",
1721
- "maxNodeModuleJsDepth",
1722
- /* Type Checking */
1723
- "strict",
1724
- "strictBindCallApply",
1725
- "strictFunctionTypes",
1726
- "strictNullChecks",
1727
- "strictPropertyInitialization",
1728
- "allowUnreachableCode",
1729
- "allowUnusedLabels",
1730
- "alwaysStrict",
1731
- "exactOptionalPropertyTypes",
1732
- "noFallthroughCasesInSwitch",
1733
- "noImplicitAny",
1734
- "noImplicitOverride",
1735
- "noImplicitReturns",
1736
- "noImplicitThis",
1737
- "noPropertyAccessFromIndexSignature",
1738
- "noUncheckedIndexedAccess",
1739
- "noUnusedLocals",
1740
- "noUnusedParameters",
1741
- "useUnknownInCatchVariables",
1742
- /* Emit */
1743
- "declaration",
1744
- "declarationDir",
1745
- "declarationMap",
1746
- "downlevelIteration",
1747
- "emitBOM",
1748
- "emitDeclarationOnly",
1749
- "importHelpers",
1750
- "importsNotUsedAsValues",
1751
- "inlineSourceMap",
1752
- "inlineSources",
1753
- "mapRoot",
1754
- "newLine",
1755
- "noEmit",
1756
- "noEmitHelpers",
1757
- "noEmitOnError",
1758
- "outDir",
1759
- "outFile",
1760
- "preserveConstEnums",
1761
- "preserveValueImports",
1762
- "removeComments",
1763
- "sourceMap",
1764
- "sourceRoot",
1765
- "stripInternal",
1766
- /* Interop Constraints */
1767
- "allowSyntheticDefaultImports",
1768
- "esModuleInterop",
1769
- "forceConsistentCasingInFileNames",
1770
- "isolatedDeclarations",
1771
- "isolatedModules",
1772
- "preserveSymlinks",
1773
- "verbatimModuleSyntax",
1774
- /* Completeness */
1775
- "skipDefaultLibCheck",
1776
- "skipLibCheck"
1777
- ],
1778
- pathPattern: "^compilerOptions$"
1779
- }
1780
- ]
1781
- }
1782
- }
1783
- ];
1784
- }
1785
-
1786
- // src/configs/svelte.ts
1787
- async function svelte(options = {}) {
1788
- const {
1789
- files = [GLOB_SVELTE],
1790
- overrides = {},
1791
- stylistic: stylistic2 = true
1792
- } = options;
1793
- const {
1794
- indent = 2,
1795
- quotes = "single"
1796
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1797
- await ensurePackages([
1798
- "eslint-plugin-svelte"
1799
- ]);
1800
- const [
1801
- pluginSvelte,
1802
- parserSvelte
1803
- ] = await Promise.all([
1804
- interopDefault(import("eslint-plugin-svelte")),
1805
- interopDefault(import("svelte-eslint-parser"))
1806
- ]);
1807
- return [
1808
- {
1809
- name: "jun/svelte/setup",
1810
- plugins: {
1811
- svelte: pluginSvelte
1812
- }
1813
- },
1814
- {
1815
- files,
1816
- languageOptions: {
1817
- parser: parserSvelte,
1818
- parserOptions: {
1819
- extraFileExtensions: [".svelte"],
1820
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null
1821
- }
1822
- },
1823
- name: "jun/svelte/rules",
1824
- processor: pluginSvelte.processors[".svelte"],
1825
- rules: {
1826
- "import/no-mutable-exports": "off",
1827
- "no-undef": "off",
1828
- // incompatible with most recent (attribute-form) generic types RFC
1829
- "no-unused-vars": ["error", {
1830
- args: "none",
1831
- caughtErrors: "none",
1832
- ignoreRestSiblings: true,
1833
- vars: "all",
1834
- varsIgnorePattern: "^(\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1835
- }],
1836
- "svelte/comment-directive": "error",
1837
- "svelte/no-at-debug-tags": "warn",
1838
- "svelte/no-at-html-tags": "error",
1839
- "svelte/no-dupe-else-if-blocks": "error",
1840
- "svelte/no-dupe-style-properties": "error",
1841
- "svelte/no-dupe-use-directives": "error",
1842
- "svelte/no-dynamic-slot-name": "error",
1843
- "svelte/no-export-load-in-svelte-module-in-kit-pages": "error",
1844
- "svelte/no-inner-declarations": "error",
1845
- "svelte/no-not-function-handler": "error",
1846
- "svelte/no-object-in-text-mustaches": "error",
1847
- "svelte/no-reactive-functions": "error",
1848
- "svelte/no-reactive-literals": "error",
1849
- "svelte/no-shorthand-style-property-overrides": "error",
1850
- "svelte/no-unknown-style-directive-property": "error",
1851
- "svelte/no-unused-svelte-ignore": "error",
1852
- "svelte/no-useless-mustaches": "error",
1853
- "svelte/require-store-callbacks-use-set-param": "error",
1854
- "svelte/system": "error",
1855
- "svelte/valid-each-key": "error",
1856
- "unused-imports/no-unused-vars": [
1857
- "error",
1858
- {
1859
- args: "after-used",
1860
- argsIgnorePattern: "^_",
1861
- vars: "all",
1862
- varsIgnorePattern: "^(_|\\$\\$Props$|\\$\\$Events$|\\$\\$Slots$)"
1863
- }
1864
- ],
1865
- ...stylistic2 ? {
1866
- "style/indent": "off",
1867
- // superseded by svelte/indent
1868
- "style/no-trailing-spaces": "off",
1869
- // superseded by svelte/no-trailing-spaces
1870
- "svelte/derived-has-same-inputs-outputs": "error",
1871
- "svelte/html-closing-bracket-spacing": "error",
1872
- "svelte/html-quotes": ["error", { prefer: quotes }],
1873
- "svelte/indent": ["error", { alignAttributesVertically: true, indent }],
1874
- "svelte/mustache-spacing": "error",
1875
- "svelte/no-spaces-around-equal-signs-in-attribute": "error",
1876
- "svelte/no-trailing-spaces": "error",
1877
- "svelte/spaced-html-comment": "error"
1878
- } : {},
1879
- ...overrides
1880
- }
1881
- }
1882
- ];
1883
- }
1884
-
1885
- // src/configs/test.ts
1886
- var _pluginTest;
1887
- async function test(options = {}) {
1888
- const {
1889
- files = GLOB_TESTS,
1890
- isInEditor = false,
1891
- overrides = {}
1892
- } = options;
1893
- const [
1894
- pluginVitest,
1895
- pluginNoOnlyTests
1896
- ] = await Promise.all([
1897
- interopDefault(import("@vitest/eslint-plugin")),
1898
- // @ts-expect-error missing types
1899
- interopDefault(import("eslint-plugin-no-only-tests"))
1900
- ]);
1901
- _pluginTest = _pluginTest || {
1902
- ...pluginVitest,
1903
- rules: {
1904
- ...pluginVitest.rules,
1905
- // extend `test/no-only-tests` rule
1906
- ...pluginNoOnlyTests.rules
1907
- }
1908
- };
1909
- return [
1910
- {
1911
- name: "jun/test/setup",
1912
- plugins: {
1913
- test: _pluginTest
1914
- }
1915
- },
1916
- {
1917
- files,
1918
- name: "jun/test/rules",
1919
- rules: {
1920
- "test/consistent-test-it": ["error", { fn: "it", withinDescribe: "it" }],
1921
- "test/no-identical-title": "error",
1922
- "test/no-import-node-test": "error",
1923
- "test/no-only-tests": isInEditor ? "off" : "error",
1924
- "test/prefer-hooks-in-order": "error",
1925
- "test/prefer-lowercase-title": "error",
1926
- // Disables
1927
- ...{
1928
- "jun/no-top-level-await": "off",
1929
- "no-unused-expressions": "off",
1930
- "node/prefer-global/process": "off",
1931
- "ts/explicit-function-return-type": "off"
1932
- },
1933
- ...overrides
1934
- }
1935
- }
1936
- ];
1937
- }
1938
-
1939
- // src/configs/toml.ts
1940
- async function toml(options = {}) {
1941
- const {
1942
- files = [GLOB_TOML],
1943
- overrides = {},
1944
- stylistic: stylistic2 = true
1945
- } = options;
1946
- const {
1947
- indent = 2
1948
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
1949
- const [
1950
- pluginToml,
1951
- parserToml
1952
- ] = await Promise.all([
1953
- interopDefault(import("eslint-plugin-toml")),
1954
- interopDefault(import("toml-eslint-parser"))
1955
- ]);
1956
- return [
1957
- {
1958
- name: "jun/toml/setup",
1959
- plugins: {
1960
- toml: pluginToml
1961
- }
1962
- },
1963
- {
1964
- files,
1965
- languageOptions: {
1966
- parser: parserToml
1967
- },
1968
- name: "jun/toml/rules",
1969
- rules: {
1970
- "style/spaced-comment": "off",
1971
- "toml/comma-style": "error",
1972
- "toml/keys-order": "error",
1973
- "toml/no-space-dots": "error",
1974
- "toml/no-unreadable-number-separator": "error",
1975
- "toml/precision-of-fractional-seconds": "error",
1976
- "toml/precision-of-integer": "error",
1977
- "toml/tables-order": "error",
1978
- "toml/vue-custom-block/no-parsing-error": "error",
1979
- ...stylistic2 ? {
1980
- "toml/array-bracket-newline": "error",
1981
- "toml/array-bracket-spacing": "error",
1982
- "toml/array-element-newline": "error",
1983
- "toml/indent": ["error", indent === "tab" ? 2 : indent],
1984
- "toml/inline-table-curly-spacing": "error",
1985
- "toml/key-spacing": "error",
1986
- "toml/padding-line-between-pairs": "error",
1987
- "toml/padding-line-between-tables": "error",
1988
- "toml/quoted-keys": "error",
1989
- "toml/spaced-comment": "error",
1990
- "toml/table-bracket-spacing": "error"
1991
- } : {},
1992
- ...overrides
1993
- }
1994
- }
1995
- ];
1996
- }
1997
-
1998
- // src/configs/typescript.ts
1999
- var import_node_process2 = __toESM(require("process"), 1);
2000
- async function typescript(options = {}) {
2001
- const {
2002
- componentExts = [],
2003
- overrides = {},
2004
- overridesTypeAware = {},
2005
- parserOptions = {},
2006
- type = "app"
2007
- } = options;
2008
- const files = options.files ?? [
2009
- GLOB_TS,
2010
- GLOB_TSX,
2011
- ...componentExts.map((ext) => `**/*.${ext}`)
2012
- ];
2013
- const filesTypeAware = options.filesTypeAware ?? [GLOB_TS, GLOB_TSX];
2014
- const ignoresTypeAware = options.ignoresTypeAware ?? [
2015
- `${GLOB_MARKDOWN}/**`,
2016
- GLOB_ASTRO_TS
2017
- ];
2018
- const tsconfigPath = options?.tsconfigPath ? options.tsconfigPath : void 0;
2019
- const isTypeAware = !!tsconfigPath;
2020
- const typeAwareRules = {
2021
- "dot-notation": "off",
2022
- "no-implied-eval": "off",
2023
- "ts/await-thenable": "error",
2024
- "ts/dot-notation": ["error", { allowKeywords: true }],
2025
- "ts/no-floating-promises": "error",
2026
- "ts/no-for-in-array": "error",
2027
- "ts/no-implied-eval": "error",
2028
- "ts/no-misused-promises": "error",
2029
- "ts/no-unnecessary-type-assertion": "error",
2030
- "ts/no-unsafe-argument": "error",
2031
- "ts/no-unsafe-assignment": "error",
2032
- "ts/no-unsafe-call": "error",
2033
- "ts/no-unsafe-member-access": "error",
2034
- "ts/no-unsafe-return": "error",
2035
- "ts/promise-function-async": "error",
2036
- "ts/restrict-plus-operands": "error",
2037
- "ts/restrict-template-expressions": "error",
2038
- "ts/return-await": ["error", "in-try-catch"],
2039
- "ts/strict-boolean-expressions": ["error", { allowNullableBoolean: true, allowNullableObject: true }],
2040
- "ts/switch-exhaustiveness-check": "error",
2041
- "ts/unbound-method": "error"
2042
- };
2043
- const [
2044
- pluginTs,
2045
- parserTs
2046
- ] = await Promise.all([
2047
- interopDefault(import("@typescript-eslint/eslint-plugin")),
2048
- interopDefault(import("@typescript-eslint/parser"))
2049
- ]);
2050
- function makeParser(typeAware, files2, ignores2) {
2051
- return {
2052
- files: files2,
2053
- ...ignores2 ? { ignores: ignores2 } : {},
2054
- languageOptions: {
2055
- parser: parserTs,
2056
- parserOptions: {
2057
- extraFileExtensions: componentExts.map((ext) => `.${ext}`),
2058
- sourceType: "module",
2059
- ...typeAware ? {
2060
- projectService: {
2061
- allowDefaultProject: ["./*.js"],
2062
- defaultProject: tsconfigPath
2063
- },
2064
- tsconfigRootDir: import_node_process2.default.cwd()
2065
- } : {},
2066
- ...parserOptions
2067
- }
2068
- },
2069
- name: `jun/typescript/${typeAware ? "type-aware-parser" : "parser"}`
2070
- };
2071
- }
2072
- return [
2073
- {
2074
- // Install the plugins without globs, so they can be configured separately.
2075
- name: "jun/typescript/setup",
2076
- plugins: {
2077
- jun: import_eslint_plugin_antfu.default,
2078
- ts: pluginTs
2079
- }
2080
- },
2081
- // assign type-aware parser for type-aware files and type-unaware parser for the rest
2082
- ...isTypeAware ? [
2083
- makeParser(false, files),
2084
- makeParser(true, filesTypeAware, ignoresTypeAware)
2085
- ] : [
2086
- makeParser(false, files)
2087
- ],
2088
- {
2089
- files,
2090
- name: "jun/typescript/rules",
2091
- rules: {
2092
- ...renameRules(
2093
- pluginTs.configs["eslint-recommended"].overrides[0].rules,
2094
- { "@typescript-eslint": "ts" }
2095
- ),
2096
- ...renameRules(
2097
- pluginTs.configs.strict.rules,
2098
- { "@typescript-eslint": "ts" }
2099
- ),
2100
- "no-dupe-class-members": "off",
2101
- "no-redeclare": "off",
2102
- "no-use-before-define": "off",
2103
- "no-useless-constructor": "off",
2104
- "ts/ban-ts-comment": ["error", { "ts-expect-error": "allow-with-description" }],
2105
- "ts/consistent-type-definitions": ["error", "interface"],
2106
- "ts/consistent-type-imports": ["error", {
2107
- disallowTypeAnnotations: false,
2108
- prefer: "type-imports"
2109
- }],
2110
- "ts/method-signature-style": ["error", "property"],
2111
- // https://www.totaltypescript.com/method-shorthand-syntax-considered-harmful
2112
- "ts/no-dupe-class-members": "error",
2113
- "ts/no-dynamic-delete": "off",
2114
- "ts/no-empty-object-type": ["error", { allowInterfaces: "always" }],
2115
- "ts/no-explicit-any": "off",
2116
- "ts/no-extraneous-class": "off",
2117
- "ts/no-import-type-side-effects": "error",
2118
- "ts/no-invalid-void-type": "off",
2119
- "ts/no-non-null-assertion": "off",
2120
- "ts/no-redeclare": ["error", { builtinGlobals: false }],
2121
- "ts/no-require-imports": "error",
2122
- "ts/no-unused-expressions": ["error", {
2123
- allowShortCircuit: true,
2124
- allowTaggedTemplates: true,
2125
- allowTernary: true
2126
- }],
2127
- "ts/no-unused-vars": "off",
2128
- "ts/no-use-before-define": ["error", { classes: false, functions: false, variables: true }],
2129
- "ts/no-useless-constructor": "off",
2130
- "ts/no-wrapper-object-types": "error",
2131
- "ts/triple-slash-reference": "off",
2132
- "ts/unified-signatures": "off",
2133
- ...type === "lib" ? {
2134
- "ts/explicit-function-return-type": ["error", {
2135
- allowExpressions: true,
2136
- allowHigherOrderFunctions: true,
2137
- allowIIFEs: true
2138
- }]
2139
- } : {},
2140
- ...overrides
2141
- }
2142
- },
2143
- ...isTypeAware ? [{
2144
- files: filesTypeAware,
2145
- ignores: ignoresTypeAware,
2146
- name: "jun/typescript/rules-type-aware",
2147
- rules: {
2148
- ...typeAwareRules,
2149
- ...overridesTypeAware
2150
- }
2151
- }] : []
2152
- ];
2153
- }
2154
-
2155
- // src/configs/unicorn.ts
2156
- async function unicorn(options = {}) {
2157
- return [
2158
- {
2159
- name: "jun/unicorn/rules",
2160
- plugins: {
2161
- unicorn: import_eslint_plugin_unicorn.default
2162
- },
2163
- rules: {
2164
- ...options.allRecommended ? import_eslint_plugin_unicorn.default.configs["flat/recommended"].rules : {
2165
- "unicorn/consistent-empty-array-spread": "error",
2166
- "unicorn/error-message": "error",
2167
- "unicorn/escape-case": "error",
2168
- "unicorn/new-for-builtins": "error",
2169
- "unicorn/no-instanceof-array": "error",
2170
- "unicorn/no-new-array": "error",
2171
- "unicorn/no-new-buffer": "error",
2172
- "unicorn/number-literal-case": "error",
2173
- "unicorn/prefer-dom-node-text-content": "error",
2174
- "unicorn/prefer-includes": "error",
2175
- "unicorn/prefer-node-protocol": "error",
2176
- "unicorn/prefer-number-properties": "error",
2177
- "unicorn/prefer-string-starts-ends-with": "error",
2178
- "unicorn/prefer-type-error": "error",
2179
- "unicorn/throw-new-error": "error"
2180
- }
2181
- }
2182
- }
2183
- ];
2184
- }
2185
-
2186
- // src/configs/unocss.ts
2187
- async function unocss(options = {}) {
2188
- const {
2189
- attributify = true,
2190
- strict = false
2191
- } = options;
2192
- await ensurePackages([
2193
- "@unocss/eslint-plugin"
2194
- ]);
2195
- const [
2196
- pluginUnoCSS
2197
- ] = await Promise.all([
2198
- interopDefault(import("@unocss/eslint-plugin"))
2199
- ]);
2200
- return [
2201
- {
2202
- name: "jun/unocss",
2203
- plugins: {
2204
- unocss: pluginUnoCSS
2205
- },
2206
- rules: {
2207
- "unocss/order": "warn",
2208
- ...attributify ? {
2209
- "unocss/order-attributify": "warn"
2210
- } : {},
2211
- ...strict ? {
2212
- "unocss/blocklist": "error"
2213
- } : {}
2214
- }
2215
- }
2216
- ];
2217
- }
2218
-
2219
- // src/configs/vue.ts
2220
- var import_eslint_merge_processors2 = require("eslint-merge-processors");
2221
- async function vue(options = {}) {
2222
- const {
2223
- files = [GLOB_VUE],
2224
- overrides = {},
2225
- stylistic: stylistic2 = true,
2226
- vueVersion = 3
2227
- } = options;
2228
- const sfcBlocks = options.sfcBlocks === true ? {} : options.sfcBlocks ?? {};
2229
- const {
2230
- indent = 2
2231
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2232
- const [
2233
- pluginVue,
2234
- parserVue,
2235
- processorVueBlocks
2236
- ] = await Promise.all([
2237
- // @ts-expect-error missing types
2238
- interopDefault(import("eslint-plugin-vue")),
2239
- interopDefault(import("vue-eslint-parser")),
2240
- interopDefault(import("eslint-processor-vue-blocks"))
2241
- ]);
2242
- return [
2243
- {
2244
- // This allows Vue plugin to work with auto imports
2245
- // https://github.com/vuejs/eslint-plugin-vue/pull/2422
2246
- languageOptions: {
2247
- globals: {
2248
- computed: "readonly",
2249
- defineEmits: "readonly",
2250
- defineExpose: "readonly",
2251
- defineProps: "readonly",
2252
- onMounted: "readonly",
2253
- onUnmounted: "readonly",
2254
- reactive: "readonly",
2255
- ref: "readonly",
2256
- shallowReactive: "readonly",
2257
- shallowRef: "readonly",
2258
- toRef: "readonly",
2259
- toRefs: "readonly",
2260
- watch: "readonly",
2261
- watchEffect: "readonly"
2262
- }
2263
- },
2264
- name: "jun/vue/setup",
2265
- plugins: {
2266
- vue: pluginVue
2267
- }
2268
- },
2269
- {
2270
- files,
2271
- languageOptions: {
2272
- parser: parserVue,
2273
- parserOptions: {
2274
- ecmaFeatures: {
2275
- jsx: true
2276
- },
2277
- extraFileExtensions: [".vue"],
2278
- parser: options.typescript ? await interopDefault(import("@typescript-eslint/parser")) : null,
2279
- sourceType: "module"
2280
- }
2281
- },
2282
- name: "jun/vue/rules",
2283
- processor: sfcBlocks === false ? pluginVue.processors[".vue"] : (0, import_eslint_merge_processors2.mergeProcessors)([
2284
- pluginVue.processors[".vue"],
2285
- processorVueBlocks({
2286
- ...sfcBlocks,
2287
- blocks: {
2288
- styles: true,
2289
- ...sfcBlocks.blocks
2290
- }
2291
- })
2292
- ]),
2293
- rules: {
2294
- ...pluginVue.configs.base.rules,
2295
- ...vueVersion === 2 ? {
2296
- ...pluginVue.configs.essential.rules,
2297
- ...pluginVue.configs["strongly-recommended"].rules,
2298
- ...pluginVue.configs.recommended.rules
2299
- } : {
2300
- ...pluginVue.configs["vue3-essential"].rules,
2301
- ...pluginVue.configs["vue3-strongly-recommended"].rules,
2302
- ...pluginVue.configs["vue3-recommended"].rules
2303
- },
2304
- "jun/no-top-level-await": "off",
2305
- "node/prefer-global/process": "off",
2306
- "ts/explicit-function-return-type": "off",
2307
- "vue/block-order": ["error", {
2308
- order: ["script", "template", "style"]
2309
- }],
2310
- "vue/component-name-in-template-casing": ["error", "PascalCase"],
2311
- "vue/component-options-name-casing": ["error", "PascalCase"],
2312
- // this is deprecated
2313
- "vue/component-tags-order": "off",
2314
- "vue/custom-event-name-casing": ["error", "camelCase"],
2315
- "vue/define-macros-order": ["error", {
2316
- order: ["defineOptions", "defineProps", "defineEmits", "defineSlots"]
2317
- }],
2318
- "vue/dot-location": ["error", "property"],
2319
- "vue/dot-notation": ["error", { allowKeywords: true }],
2320
- "vue/eqeqeq": ["error", "smart"],
2321
- "vue/html-indent": ["error", indent],
2322
- "vue/html-quotes": ["error", "double"],
2323
- "vue/max-attributes-per-line": "off",
2324
- "vue/multi-word-component-names": "off",
2325
- "vue/no-dupe-keys": "off",
2326
- "vue/no-empty-pattern": "error",
2327
- "vue/no-irregular-whitespace": "error",
2328
- "vue/no-loss-of-precision": "error",
2329
- "vue/no-restricted-syntax": [
2330
- "error",
2331
- "DebuggerStatement",
2332
- "LabeledStatement",
2333
- "WithStatement"
2334
- ],
2335
- "vue/no-restricted-v-bind": ["error", "/^v-/"],
2336
- "vue/no-setup-props-reactivity-loss": "off",
2337
- "vue/no-sparse-arrays": "error",
2338
- "vue/no-unused-refs": "error",
2339
- "vue/no-useless-v-bind": "error",
2340
- "vue/no-v-html": "off",
2341
- "vue/object-shorthand": [
2342
- "error",
2343
- "always",
2344
- {
2345
- avoidQuotes: true,
2346
- ignoreConstructors: false
2347
- }
2348
- ],
2349
- "vue/prefer-separate-static-class": "error",
2350
- "vue/prefer-template": "error",
2351
- "vue/prop-name-casing": ["error", "camelCase"],
2352
- "vue/require-default-prop": "off",
2353
- "vue/require-prop-types": "off",
2354
- "vue/space-infix-ops": "error",
2355
- "vue/space-unary-ops": ["error", { nonwords: false, words: true }],
2356
- ...stylistic2 ? {
2357
- "vue/array-bracket-spacing": ["error", "never"],
2358
- "vue/arrow-spacing": ["error", { after: true, before: true }],
2359
- "vue/block-spacing": ["error", "always"],
2360
- "vue/block-tag-newline": ["error", {
2361
- multiline: "always",
2362
- singleline: "always"
2363
- }],
2364
- "vue/brace-style": ["error", "1tbs", { allowSingleLine: true }],
2365
- "vue/comma-dangle": ["error", "always-multiline"],
2366
- "vue/comma-spacing": ["error", { after: true, before: false }],
2367
- "vue/comma-style": ["error", "last"],
2368
- "vue/html-comment-content-spacing": ["error", "always", {
2369
- exceptions: ["-"]
2370
- }],
2371
- "vue/key-spacing": ["error", { afterColon: true, beforeColon: false }],
2372
- "vue/keyword-spacing": ["error", { after: true, before: true }],
2373
- "vue/object-curly-newline": "off",
2374
- "vue/object-curly-spacing": ["error", "always"],
2375
- "vue/object-property-newline": ["error", { allowMultiplePropertiesPerLine: true }],
2376
- "vue/operator-linebreak": ["error", "before"],
2377
- "vue/padding-line-between-blocks": ["error", "always"],
2378
- "vue/quote-props": ["error", "consistent-as-needed"],
2379
- "vue/space-in-parens": ["error", "never"],
2380
- "vue/template-curly-spacing": "error"
2381
- } : {},
2382
- ...overrides
2383
- }
2384
- }
2385
- ];
2386
- }
2387
-
2388
- // src/configs/yaml.ts
2389
- async function yaml(options = {}) {
2390
- const {
2391
- files = [GLOB_YAML],
2392
- overrides = {},
2393
- stylistic: stylistic2 = true
2394
- } = options;
2395
- const {
2396
- indent = 2,
2397
- quotes = "single"
2398
- } = typeof stylistic2 === "boolean" ? {} : stylistic2;
2399
- const [
2400
- pluginYaml,
2401
- parserYaml
2402
- ] = await Promise.all([
2403
- interopDefault(import("eslint-plugin-yml")),
2404
- interopDefault(import("yaml-eslint-parser"))
2405
- ]);
2406
- return [
2407
- {
2408
- name: "jun/yaml/setup",
2409
- plugins: {
2410
- yaml: pluginYaml
2411
- }
2412
- },
2413
- {
2414
- files,
2415
- languageOptions: {
2416
- parser: parserYaml
2417
- },
2418
- name: "jun/yaml/rules",
2419
- rules: {
2420
- "style/spaced-comment": "off",
2421
- "yaml/block-mapping": "error",
2422
- "yaml/block-sequence": "error",
2423
- "yaml/no-empty-key": "error",
2424
- "yaml/no-empty-sequence-entry": "error",
2425
- "yaml/no-irregular-whitespace": "error",
2426
- "yaml/plain-scalar": "error",
2427
- "yaml/vue-custom-block/no-parsing-error": "error",
2428
- ...stylistic2 ? {
2429
- "yaml/block-mapping-question-indicator-newline": "error",
2430
- "yaml/block-sequence-hyphen-indicator-newline": "error",
2431
- "yaml/flow-mapping-curly-newline": "error",
2432
- "yaml/flow-mapping-curly-spacing": "error",
2433
- "yaml/flow-sequence-bracket-newline": "error",
2434
- "yaml/flow-sequence-bracket-spacing": "error",
2435
- "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2436
- "yaml/key-spacing": "error",
2437
- "yaml/no-tab-indent": "error",
2438
- "yaml/quotes": ["error", { avoidEscape: false, prefer: quotes }],
2439
- "yaml/spaced-comment": "error"
2440
- } : {},
2441
- ...overrides
2442
- }
2443
- }
2444
- ];
2445
- }
2446
-
2447
- // src/factory.ts
2448
- var flatConfigProps = [
2449
- "name",
2450
- "languageOptions",
2451
- "linterOptions",
2452
- "processor",
2453
- "plugins",
2454
- "rules",
2455
- "settings"
2456
- ];
2457
- var VuePackages = [
2458
- "vue",
2459
- "nuxt",
2460
- "vitepress",
2461
- "@slidev/cli"
2462
- ];
2463
- var defaultPluginRenaming = {
2464
- "@eslint-react": "react",
2465
- "@eslint-react/dom": "react-dom",
2466
- "@eslint-react/hooks-extra": "react-hooks-extra",
2467
- "@eslint-react/naming-convention": "react-naming-convention",
2468
- "@stylistic": "style",
2469
- "@typescript-eslint": "ts",
2470
- "import-x": "import",
2471
- "n": "node",
2472
- "vitest": "test",
2473
- "yml": "yaml"
2474
- };
2475
- function jun(options = {}, ...userConfigs) {
2476
- const {
2477
- astro: enableAstro = false,
2478
- autoRenamePlugins = true,
2479
- componentExts = [],
2480
- gitignore: enableGitignore = true,
2481
- jsx: enableJsx = true,
2482
- react: enableReact = false,
2483
- regexp: enableRegexp = true,
2484
- solid: enableSolid = false,
2485
- svelte: enableSvelte = false,
2486
- typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
2487
- unicorn: enableUnicorn = true,
2488
- unocss: enableUnoCSS = false,
2489
- vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
2490
- } = options;
2491
- let isInEditor = options.isInEditor;
2492
- if (isInEditor == null) {
2493
- isInEditor = isInEditorEnv();
2494
- if (isInEditor)
2495
- console.log("[@jun2030/eslint-config] Detected running in editor, some rules are disabled.");
2496
- }
2497
- const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2498
- if (stylisticOptions && !("jsx" in stylisticOptions))
2499
- stylisticOptions.jsx = enableJsx;
2500
- const configs2 = [];
2501
- if (enableGitignore) {
2502
- if (typeof enableGitignore !== "boolean") {
2503
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2504
- name: "jun/gitignore",
2505
- ...enableGitignore
2506
- })]));
2507
- } else {
2508
- configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
2509
- name: "jun/gitignore",
2510
- strict: false
2511
- })]));
2512
- }
2513
- }
2514
- const typescriptOptions = resolveSubOptions(options, "typescript");
2515
- const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2516
- configs2.push(
2517
- ignores(options.ignores),
2518
- javascript({
2519
- isInEditor,
2520
- overrides: getOverrides(options, "javascript")
2521
- }),
2522
- comments(),
2523
- node(),
2524
- jsdoc({
2525
- stylistic: stylisticOptions
2526
- }),
2527
- imports({
2528
- stylistic: stylisticOptions
2529
- }),
2530
- command(),
2531
- // Optional plugins (installed but not enabled by default)
2532
- perfectionist()
2533
- );
2534
- if (enableUnicorn) {
2535
- configs2.push(unicorn(enableUnicorn === true ? {} : enableUnicorn));
2536
- }
2537
- if (enableVue) {
2538
- componentExts.push("vue");
2539
- }
2540
- if (enableJsx) {
2541
- configs2.push(jsx());
2542
- }
2543
- if (enableTypeScript) {
2544
- configs2.push(typescript({
2545
- ...typescriptOptions,
2546
- componentExts,
2547
- overrides: getOverrides(options, "typescript"),
2548
- type: options.type
2549
- }));
2550
- }
2551
- if (stylisticOptions) {
2552
- configs2.push(stylistic({
2553
- ...stylisticOptions,
2554
- lessOpinionated: options.lessOpinionated,
2555
- overrides: getOverrides(options, "stylistic")
2556
- }));
2557
- }
2558
- if (enableRegexp) {
2559
- configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2560
- }
2561
- if (options.test ?? true) {
2562
- configs2.push(test({
2563
- isInEditor,
2564
- overrides: getOverrides(options, "test")
2565
- }));
2566
- }
2567
- if (enableVue) {
2568
- configs2.push(vue({
2569
- ...resolveSubOptions(options, "vue"),
2570
- overrides: getOverrides(options, "vue"),
2571
- stylistic: stylisticOptions,
2572
- typescript: !!enableTypeScript
2573
- }));
2574
- }
2575
- if (enableReact) {
2576
- configs2.push(react({
2577
- overrides: getOverrides(options, "react"),
2578
- tsconfigPath
2579
- }));
2580
- }
2581
- if (enableSolid) {
2582
- configs2.push(solid({
2583
- overrides: getOverrides(options, "solid"),
2584
- tsconfigPath,
2585
- typescript: !!enableTypeScript
2586
- }));
2587
- }
2588
- if (enableSvelte) {
2589
- configs2.push(svelte({
2590
- overrides: getOverrides(options, "svelte"),
2591
- stylistic: stylisticOptions,
2592
- typescript: !!enableTypeScript
2593
- }));
2594
- }
2595
- if (enableUnoCSS) {
2596
- configs2.push(unocss({
2597
- ...resolveSubOptions(options, "unocss"),
2598
- overrides: getOverrides(options, "unocss")
2599
- }));
2600
- }
2601
- if (enableAstro) {
2602
- configs2.push(astro({
2603
- overrides: getOverrides(options, "astro"),
2604
- stylistic: stylisticOptions
2605
- }));
2606
- }
2607
- if (options.jsonc ?? true) {
2608
- configs2.push(
2609
- jsonc({
2610
- overrides: getOverrides(options, "jsonc"),
2611
- stylistic: stylisticOptions
2612
- }),
2613
- sortPackageJson(),
2614
- sortTsconfig()
2615
- );
2616
- }
2617
- if (options.yaml ?? true) {
2618
- configs2.push(yaml({
2619
- overrides: getOverrides(options, "yaml"),
2620
- stylistic: stylisticOptions
2621
- }));
2622
- }
2623
- if (options.toml ?? true) {
2624
- configs2.push(toml({
2625
- overrides: getOverrides(options, "toml"),
2626
- stylistic: stylisticOptions
2627
- }));
2628
- }
2629
- if (options.markdown ?? true) {
2630
- configs2.push(
2631
- markdown(
2632
- {
2633
- componentExts,
2634
- overrides: getOverrides(options, "markdown")
2635
- }
2636
- )
2637
- );
2638
- }
2639
- if (options.formatters) {
2640
- configs2.push(formatters(
2641
- options.formatters,
2642
- typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2643
- ));
2644
- }
2645
- configs2.push(
2646
- disables()
2647
- );
2648
- if ("files" in options) {
2649
- throw new Error('[@jun2030/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.');
2650
- }
2651
- const fusedConfig = flatConfigProps.reduce((acc, key) => {
2652
- if (key in options)
2653
- acc[key] = options[key];
2654
- return acc;
2655
- }, {});
2656
- if (Object.keys(fusedConfig).length)
2657
- configs2.push([fusedConfig]);
2658
- let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2659
- composer = composer.append(
2660
- ...configs2,
2661
- ...userConfigs
2662
- );
2663
- if (autoRenamePlugins) {
2664
- composer = composer.renamePlugins(defaultPluginRenaming);
2665
- }
2666
- return composer;
2667
- }
2668
- function resolveSubOptions(options, key) {
2669
- return typeof options[key] === "boolean" ? {} : options[key] || {};
2670
- }
2671
- function getOverrides(options, key) {
2672
- const sub = resolveSubOptions(options, key);
2673
- return {
2674
- ...options.overrides?.[key],
2675
- ..."overrides" in sub ? sub.overrides : {}
2676
- };
2677
- }
2678
-
2679
- // src/index.ts
2680
- var src_default = jun;
2681
- // Annotate the CommonJS export names for ESM import in node:
2682
- 0 && (module.exports = {
2683
- GLOB_ALL_SRC,
2684
- GLOB_ASTRO,
2685
- GLOB_ASTRO_TS,
2686
- GLOB_CSS,
2687
- GLOB_EXCLUDE,
2688
- GLOB_GRAPHQL,
2689
- GLOB_HTML,
2690
- GLOB_JS,
2691
- GLOB_JSON,
2692
- GLOB_JSON5,
2693
- GLOB_JSONC,
2694
- GLOB_JSX,
2695
- GLOB_LESS,
2696
- GLOB_MARKDOWN,
2697
- GLOB_MARKDOWN_CODE,
2698
- GLOB_MARKDOWN_IN_MARKDOWN,
2699
- GLOB_POSTCSS,
2700
- GLOB_SCSS,
2701
- GLOB_SRC,
2702
- GLOB_SRC_EXT,
2703
- GLOB_STYLE,
2704
- GLOB_SVELTE,
2705
- GLOB_SVG,
2706
- GLOB_TESTS,
2707
- GLOB_TOML,
2708
- GLOB_TS,
2709
- GLOB_TSX,
2710
- GLOB_VUE,
2711
- GLOB_XML,
2712
- GLOB_YAML,
2713
- StylisticConfigDefaults,
2714
- astro,
2715
- combine,
2716
- command,
2717
- comments,
2718
- defaultPluginRenaming,
2719
- disables,
2720
- ensurePackages,
2721
- formatters,
2722
- getOverrides,
2723
- ignores,
2724
- imports,
2725
- interopDefault,
2726
- isInEditorEnv,
2727
- isInGitHooksOrLintStaged,
2728
- isPackageInScope,
2729
- javascript,
2730
- jsdoc,
2731
- jsonc,
2732
- jsx,
2733
- jun,
2734
- markdown,
2735
- node,
2736
- parserPlain,
2737
- perfectionist,
2738
- react,
2739
- regexp,
2740
- renamePluginInConfigs,
2741
- renameRules,
2742
- resolveSubOptions,
2743
- solid,
2744
- sortPackageJson,
2745
- sortTsconfig,
2746
- stylistic,
2747
- svelte,
2748
- test,
2749
- toArray,
2750
- toml,
2751
- typescript,
2752
- unicorn,
2753
- unocss,
2754
- vue,
2755
- yaml
2756
- });