@luxass/eslint-config 4.11.0 → 4.12.1

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