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