@luxass/eslint-config 4.12.1 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -102,7 +102,7 @@ __export(src_exports, {
102
102
  });
103
103
  module.exports = __toCommonJS(src_exports);
104
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
105
+ // node_modules/.pnpm/tsup@8.3.5_jiti@2.4.0_postcss@8.4.47_tsx@4.19.2_typescript@5.7.2_yaml@2.6.0/node_modules/tsup/assets/cjs_shims.js
106
106
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
107
107
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
108
108
 
@@ -345,6 +345,7 @@ async function astro(options = {}) {
345
345
  },
346
346
  processor: "astro/client-side-ts",
347
347
  rules: {
348
+ // use recommended rules
348
349
  "astro/missing-client-only-directive-value": "error",
349
350
  "astro/no-conflict-set-directives": "error",
350
351
  "astro/no-deprecated-astro-canonicalurl": "error",
@@ -353,12 +354,11 @@ async function astro(options = {}) {
353
354
  "astro/no-deprecated-getentrybyslug": "error",
354
355
  "astro/no-set-html-directive": "off",
355
356
  "astro/no-unused-define-vars-in-style": "error",
356
- "astro/semi": "error",
357
+ "astro/semi": "off",
357
358
  "astro/valid-compile": "error",
358
359
  ...stylistic2 ? {
359
360
  "style/indent": "off",
360
361
  "style/jsx-closing-tag-location": "off",
361
- "style/jsx-indent": "off",
362
362
  "style/jsx-one-expression-per-line": "off",
363
363
  "style/no-multiple-empty-lines": "off"
364
364
  } : {},
@@ -384,9 +384,8 @@ async function comments() {
384
384
  "eslint-comments/no-duplicate-disable": "error",
385
385
  // https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-unlimited-disable.md
386
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"
387
+ // https://github.com/eslint-community/eslint-plugin-eslint-comments/blob/main/docs/rules/no-unused-enable.md
388
+ "eslint-comments/no-unused-enable": "error"
390
389
  }
391
390
  }
392
391
  ];
@@ -396,17 +395,19 @@ async function comments() {
396
395
  async function disables() {
397
396
  return [
398
397
  {
399
- files: [`scripts/${GLOB_SRC}`],
398
+ files: [`**/scripts/${GLOB_SRC}`],
400
399
  name: "luxass/disables/scripts",
401
400
  rules: {
401
+ "antfu/no-top-level-await": "off",
402
402
  "no-console": "off",
403
403
  "ts/explicit-function-return-type": "off"
404
404
  }
405
405
  },
406
406
  {
407
- files: [`cli/${GLOB_SRC}`, `cli.${GLOB_SRC_EXT}`],
407
+ files: [`**/cli/${GLOB_SRC}`, `**/cli.${GLOB_SRC_EXT}`],
408
408
  name: "luxass/disables/cli",
409
409
  rules: {
410
+ "antfu/no-top-level-await": "off",
410
411
  "no-console": "off"
411
412
  }
412
413
  },
@@ -428,13 +429,6 @@ async function disables() {
428
429
  "unused-imports/no-unused-vars": "off"
429
430
  }
430
431
  },
431
- {
432
- files: ["**/*.{test,spec}.([tj])s?(x)"],
433
- name: "luxass/disables/test",
434
- rules: {
435
- "no-unused-expressions": "off"
436
- }
437
- },
438
432
  {
439
433
  files: ["**/*.js", "**/*.cjs"],
440
434
  name: "luxass/disables/cjs",
@@ -449,6 +443,15 @@ async function disables() {
449
443
  // GitHub Actions supports empty values to enable features
450
444
  "yaml/no-empty-mapping-value": "off"
451
445
  }
446
+ },
447
+ {
448
+ files: [`**/*.config.${GLOB_SRC_EXT}`, `**/*.config.*.${GLOB_SRC_EXT}`],
449
+ name: "luxass/disables/config-files",
450
+ rules: {
451
+ "antfu/no-top-level-await": "off",
452
+ "no-console": "off",
453
+ "ts/explicit-function-return-type": "off"
454
+ }
452
455
  }
453
456
  ];
454
457
  }
@@ -503,6 +506,16 @@ async function stylistic(options = {}) {
503
506
  }
504
507
 
505
508
  // src/configs/formatters.ts
509
+ function mergePrettierOptions(options, overrides = {}) {
510
+ return {
511
+ ...options,
512
+ ...overrides,
513
+ plugins: [
514
+ ...overrides.plugins || [],
515
+ ...options.plugins || []
516
+ ]
517
+ };
518
+ }
506
519
  async function formatters(options = {}, stylistic2 = {}) {
507
520
  if (options === true) {
508
521
  options = {
@@ -565,10 +578,9 @@ async function formatters(options = {}, stylistic2 = {}) {
565
578
  rules: {
566
579
  "format/prettier": [
567
580
  "error",
568
- {
569
- ...prettierOptions,
581
+ mergePrettierOptions(prettierOptions, {
570
582
  parser: "css"
571
- }
583
+ })
572
584
  ]
573
585
  }
574
586
  },
@@ -581,10 +593,9 @@ async function formatters(options = {}, stylistic2 = {}) {
581
593
  rules: {
582
594
  "format/prettier": [
583
595
  "error",
584
- {
585
- ...prettierOptions,
596
+ mergePrettierOptions(prettierOptions, {
586
597
  parser: "scss"
587
- }
598
+ })
588
599
  ]
589
600
  }
590
601
  },
@@ -597,10 +608,9 @@ async function formatters(options = {}, stylistic2 = {}) {
597
608
  rules: {
598
609
  "format/prettier": [
599
610
  "error",
600
- {
601
- ...prettierOptions,
611
+ mergePrettierOptions(prettierOptions, {
602
612
  parser: "less"
603
- }
613
+ })
604
614
  ]
605
615
  }
606
616
  }
@@ -616,10 +626,9 @@ async function formatters(options = {}, stylistic2 = {}) {
616
626
  rules: {
617
627
  "format/prettier": [
618
628
  "error",
619
- {
620
- ...prettierOptions,
629
+ mergePrettierOptions(prettierOptions, {
621
630
  parser: "html"
622
- }
631
+ })
623
632
  ]
624
633
  }
625
634
  });
@@ -635,11 +644,10 @@ async function formatters(options = {}, stylistic2 = {}) {
635
644
  rules: {
636
645
  [`format/${formater}`]: [
637
646
  "error",
638
- formater === "prettier" ? {
639
- ...prettierOptions,
647
+ formater === "prettier" ? mergePrettierOptions(prettierOptions, {
640
648
  embeddedLanguageFormatting: "off",
641
649
  parser: "markdown"
642
- } : {
650
+ }) : {
643
651
  ...dprintOptions,
644
652
  language: "markdown"
645
653
  }
@@ -657,13 +665,12 @@ async function formatters(options = {}, stylistic2 = {}) {
657
665
  rules: {
658
666
  "format/prettier": [
659
667
  "error",
660
- {
661
- ...prettierOptions,
668
+ mergePrettierOptions(prettierOptions, {
662
669
  parser: "astro",
663
670
  plugins: [
664
671
  "prettier-plugin-astro"
665
672
  ]
666
- }
673
+ })
667
674
  ]
668
675
  }
669
676
  });
@@ -678,10 +685,9 @@ async function formatters(options = {}, stylistic2 = {}) {
678
685
  rules: {
679
686
  "format/prettier": [
680
687
  "error",
681
- {
682
- ...prettierOptions,
688
+ mergePrettierOptions(prettierOptions, {
683
689
  parser: "graphql"
684
- }
690
+ })
685
691
  ]
686
692
  }
687
693
  });
@@ -780,6 +786,7 @@ async function javascript(options = {}) {
780
786
  "error",
781
787
  { enforceForClassMembers: true, setWithoutGet: true }
782
788
  ],
789
+ "antfu/no-top-level-await": "error",
783
790
  "array-callback-return": "error",
784
791
  "block-scoped-var": "error",
785
792
  "constructor-super": "error",
@@ -1176,6 +1183,7 @@ async function markdown(options = {}) {
1176
1183
  }
1177
1184
  },
1178
1185
  rules: {
1186
+ "antfu/no-top-level-await": "off",
1179
1187
  "import/newline-after-import": "off",
1180
1188
  "no-alert": "off",
1181
1189
  "no-console": "off",
@@ -1190,6 +1198,7 @@ async function markdown(options = {}) {
1190
1198
  "style/comma-dangle": "off",
1191
1199
  "style/eol-last": "off",
1192
1200
  "ts/consistent-type-imports": "off",
1201
+ "ts/explicit-function-return-type": "off",
1193
1202
  "ts/no-namespace": "off",
1194
1203
  "ts/no-redeclare": "off",
1195
1204
  "ts/no-require-imports": "off",
@@ -1274,34 +1283,41 @@ var RemixPackages = [
1274
1283
  "@remix-run/serve",
1275
1284
  "@remix-run/dev"
1276
1285
  ];
1286
+ var NextJsPackages = [
1287
+ "next"
1288
+ ];
1277
1289
  async function react(options = {}) {
1278
1290
  const {
1279
1291
  files = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
1280
- overrides = {}
1292
+ overrides = {},
1293
+ filesTypeAware = [GLOB_TS, GLOB_TSX],
1294
+ ignoresTypeAware = [
1295
+ `${GLOB_MARKDOWN}/**`,
1296
+ GLOB_ASTRO_TS
1297
+ ],
1298
+ tsconfigPath
1281
1299
  } = options;
1282
1300
  await ensure([
1283
1301
  "@eslint-react/eslint-plugin",
1284
1302
  "eslint-plugin-react-hooks",
1285
1303
  "eslint-plugin-react-refresh"
1286
1304
  ]);
1287
- const tsconfigPath = options?.tsconfigPath ? toArray(options.tsconfigPath) : void 0;
1288
1305
  const isTypeAware = !!tsconfigPath;
1306
+ const typeAwareRules = {
1307
+ "react/no-leaked-conditional-rendering": "warn"
1308
+ };
1289
1309
  const [
1290
1310
  pluginReact,
1291
1311
  pluginReactHooks,
1292
- pluginReactRefresh,
1293
- parserTs
1312
+ pluginReactRefresh
1294
1313
  ] = await Promise.all([
1295
1314
  interop(import("@eslint-react/eslint-plugin")),
1296
1315
  interop(import("eslint-plugin-react-hooks")),
1297
- interop(import("eslint-plugin-react-refresh")),
1298
- interop(import("@typescript-eslint/parser"))
1316
+ interop(import("eslint-plugin-react-refresh"))
1299
1317
  ]);
1300
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some(
1301
- (i) => (0, import_local_pkg2.isPackageExists)(i)
1302
- );
1318
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1303
1319
  const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1304
- const isUsingNext = (0, import_local_pkg2.isPackageExists)("next");
1320
+ const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
1305
1321
  const plugins = pluginReact.configs.all.plugins;
1306
1322
  return [
1307
1323
  {
@@ -1319,12 +1335,10 @@ async function react(options = {}) {
1319
1335
  name: "luxass/react/rules",
1320
1336
  files,
1321
1337
  languageOptions: {
1322
- parser: parserTs,
1323
1338
  parserOptions: {
1324
1339
  ecmaFeatures: {
1325
1340
  jsx: true
1326
- },
1327
- ...isTypeAware ? { project: tsconfigPath } : {}
1341
+ }
1328
1342
  },
1329
1343
  sourceType: "module"
1330
1344
  },
@@ -1351,6 +1365,13 @@ async function react(options = {}) {
1351
1365
  allowConstantExport: isAllowConstantExport,
1352
1366
  allowExportNames: [
1353
1367
  ...isUsingNext ? [
1368
+ "dynamic",
1369
+ "dynamicParams",
1370
+ "revalidate",
1371
+ "fetchCache",
1372
+ "runtime",
1373
+ "preferredRegion",
1374
+ "maxDuration",
1354
1375
  "config",
1355
1376
  "runtime",
1356
1377
  "generateStaticParams",
@@ -1406,13 +1427,18 @@ async function react(options = {}) {
1406
1427
  "react/prefer-destructuring-assignment": "warn",
1407
1428
  "react/prefer-shorthand-boolean": "warn",
1408
1429
  "react/prefer-shorthand-fragment": "warn",
1409
- ...isTypeAware ? {
1410
- "react/no-leaked-conditional-rendering": "warn"
1411
- } : {},
1412
1430
  // overrides
1413
1431
  ...overrides
1414
1432
  }
1415
- }
1433
+ },
1434
+ ...isTypeAware ? [{
1435
+ files: filesTypeAware,
1436
+ ignores: ignoresTypeAware,
1437
+ name: "antfu/react/type-aware-rules",
1438
+ rules: {
1439
+ ...typeAwareRules
1440
+ }
1441
+ }] : []
1416
1442
  ];
1417
1443
  }
1418
1444
 
@@ -1751,7 +1777,6 @@ async function test(options = {}) {
1751
1777
  name: "luxass/test/rules",
1752
1778
  files,
1753
1779
  rules: {
1754
- "node/prefer-global/process": "off",
1755
1780
  "test/consistent-test-it": [
1756
1781
  "error",
1757
1782
  { fn: "it", withinDescribe: "it" }
@@ -1761,7 +1786,13 @@ async function test(options = {}) {
1761
1786
  "test/no-focused-tests": isInEditor ? "off" : ["error", { fixable: true }],
1762
1787
  "test/prefer-hooks-in-order": "error",
1763
1788
  "test/prefer-lowercase-title": "error",
1764
- "ts/explicit-function-return-type": "off",
1789
+ // Disables
1790
+ ...{
1791
+ "antfu/no-top-level-await": "off",
1792
+ "no-unused-expressions": "off",
1793
+ "node/prefer-global/process": "off",
1794
+ "ts/explicit-function-return-type": "off"
1795
+ },
1765
1796
  ...overrides
1766
1797
  }
1767
1798
  }
@@ -1835,6 +1866,7 @@ async function typescript(options = {}) {
1835
1866
  exts = [],
1836
1867
  overrides = {},
1837
1868
  parserOptions = {},
1869
+ overridesTypeAware = {},
1838
1870
  type = "app"
1839
1871
  } = options ?? {};
1840
1872
  const files = options.files ?? [
@@ -1959,8 +1991,13 @@ async function typescript(options = {}) {
1959
1991
  "ts/no-invalid-this": "error",
1960
1992
  "ts/no-invalid-void-type": "off",
1961
1993
  "ts/no-non-null-assertion": "off",
1962
- "ts/no-redeclare": "error",
1994
+ "ts/no-redeclare": ["error", { builtinGlobals: false }],
1963
1995
  "ts/no-require-imports": "error",
1996
+ "ts/no-unused-expressions": ["error", {
1997
+ allowShortCircuit: true,
1998
+ allowTaggedTemplates: true,
1999
+ allowTernary: true
2000
+ }],
1964
2001
  "ts/no-unused-vars": "off",
1965
2002
  "ts/no-use-before-define": [
1966
2003
  "error",
@@ -1984,7 +2021,10 @@ async function typescript(options = {}) {
1984
2021
  files: filesTypeAware,
1985
2022
  ignores: ignoresTypeAware,
1986
2023
  name: "luxass/typescript/rules-type-aware",
1987
- rules: typeAwareRules
2024
+ rules: {
2025
+ ...typeAwareRules,
2026
+ ...overridesTypeAware
2027
+ }
1988
2028
  }] : []
1989
2029
  ];
1990
2030
  }
@@ -2168,7 +2208,9 @@ async function vue(options = {}) {
2168
2208
  ...pluginVue.configs["vue3-essential"].rules,
2169
2209
  ...pluginVue.configs["vue3-strongly-recommended"].rules,
2170
2210
  ...pluginVue.configs["vue3-recommended"].rules,
2211
+ "antfu/no-top-level-await": "off",
2171
2212
  "node/prefer-global/process": "off",
2213
+ "ts/explicit-function-return-type": "off",
2172
2214
  "vue/block-order": [
2173
2215
  "error",
2174
2216
  {
@@ -2329,10 +2371,7 @@ async function yaml(options = {}) {
2329
2371
  "yaml/indent": ["error", indent === "tab" ? 2 : indent],
2330
2372
  "yaml/key-spacing": "error",
2331
2373
  "yaml/no-tab-indent": "error",
2332
- "yaml/quotes": [
2333
- "error",
2334
- { avoidEscape: false, prefer: quotes }
2335
- ],
2374
+ "yaml/quotes": ["error", { avoidEscape: true, prefer: quotes === "backtick" ? "single" : quotes }],
2336
2375
  "yaml/spaced-comment": "error"
2337
2376
  } : {},
2338
2377
  ...overrides