@luxass/eslint-config 4.11.0 → 4.12.0

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