@luxass/eslint-config 4.4.2 → 4.5.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/README.md CHANGED
@@ -131,7 +131,10 @@ Install [ESLint extension](https://marketplace.visualstudio.com/items?itemName=d
131
131
  "yaml",
132
132
  "toml",
133
133
  "gql",
134
- "graphql"
134
+ "graphql",
135
+ "astro",
136
+ "css",
137
+ "postcss"
135
138
  ]
136
139
  }
137
140
  ```
@@ -269,7 +272,6 @@ Since flat config requires us to explicitly provide the plugin names (instead of
269
272
  | `react-dom/*` | `@eslint-react/dom/*` | [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) |
270
273
  | `react-hooks-extra/*` | `@eslint-react/hooks-extra/*` | [eslint-plugin-react-hooks-extra](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-hooks-extra) |
271
274
  | `react-naming-convention/*` | `@eslint-react/naming-convention/*` | [eslint-plugin-react-naming-convention](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-naming-convention) |
272
- | `nextjs` | `@next/next` | [eslint-plugin-react-refresh](https://github.com/vercel/next.js/tree/canary/packages/eslint-plugin-next) |
273
275
 
274
276
  When you want to override rules, or disable them inline, you need to update to the new prefix:
275
277
 
@@ -432,27 +434,6 @@ Running `npx eslint` should prompt you to install the required dependencies, oth
432
434
  npm i -D @eslint-react/eslint-plugin eslint-plugin-react-hooks eslint-plugin-react-refresh
433
435
  ```
434
436
 
435
- #### Next.JS
436
-
437
- To enable Next.JS support, need to explicitly turn it on:
438
-
439
- Next.JS also enables React support.
440
-
441
- ```js
442
- // eslint.config.js
443
- import luxass from '@luxass/eslint-config'
444
-
445
- export default luxass({
446
- nextjs: true,
447
- })
448
- ```
449
-
450
- Running `npx eslint` should prompt you to install the required dependencies, otherwise, you can install them manually:
451
-
452
- ```bash
453
- npm i -D eslint-plugin-react eslint-plugin-react-hooks @next/eslint-plugin-next
454
- ```
455
-
456
437
  #### Astro
457
438
 
458
439
  To enable Astro support, you need to explicitly turn it on:
package/dist/index.cjs CHANGED
@@ -73,10 +73,10 @@ __export(src_exports, {
73
73
  jsonc: () => jsonc,
74
74
  luxass: () => luxass,
75
75
  markdown: () => markdown,
76
- nextjs: () => nextjs,
77
76
  node: () => node,
78
77
  parserPlain: () => parserPlain,
79
78
  react: () => react,
79
+ regexp: () => regexp,
80
80
  renameRules: () => renameRules,
81
81
  resolveSubOptions: () => resolveSubOptions,
82
82
  solid: () => solid,
@@ -545,8 +545,8 @@ var parserPlain = {
545
545
  }
546
546
  })
547
547
  };
548
- async function combine(...configs) {
549
- const resolved = await Promise.all(configs);
548
+ async function combine(...configs2) {
549
+ const resolved = await Promise.all(configs2);
550
550
  return resolved.flat();
551
551
  }
552
552
  function renameRules(rules, from, to) {
@@ -1736,11 +1736,13 @@ async function test(options = {}) {
1736
1736
  name: "luxass/test/rules",
1737
1737
  files,
1738
1738
  rules: {
1739
+ "node/prefer-global/process": "off",
1739
1740
  "test/consistent-test-it": [
1740
1741
  "error",
1741
1742
  { fn: "it", withinDescribe: "it" }
1742
1743
  ],
1743
1744
  "test/no-identical-title": "error",
1745
+ "test/no-import-node-test": "error",
1744
1746
  "test/no-focused-tests": editor ? "off" : "error",
1745
1747
  "test/prefer-hooks-in-order": "error",
1746
1748
  "test/prefer-lowercase-title": "error",
@@ -1790,88 +1792,6 @@ async function unocss(options = {}) {
1790
1792
  ];
1791
1793
  }
1792
1794
 
1793
- // src/configs/nextjs.ts
1794
- async function nextjs(options = {}) {
1795
- const {
1796
- files = [GLOB_SRC],
1797
- overrides,
1798
- rootDir
1799
- } = options;
1800
- await ensure([
1801
- "@next/eslint-plugin-next"
1802
- ]);
1803
- const pluginNextjs = await interop(import("@next/eslint-plugin-next"));
1804
- return [
1805
- {
1806
- name: "luxass/nextjs/setup",
1807
- plugins: {
1808
- nextjs: pluginNextjs
1809
- }
1810
- },
1811
- {
1812
- name: "luxass/nextjs/rules",
1813
- files,
1814
- rules: {
1815
- ...renameRules(
1816
- pluginNextjs.configs.recommended.rules,
1817
- "@next/next/",
1818
- "nextjs/"
1819
- ),
1820
- ...renameRules(
1821
- pluginNextjs.configs["core-web-vitals"].rules,
1822
- "@next/next/",
1823
- "nextjs/"
1824
- ),
1825
- "nextjs/google-font-display": ["error"],
1826
- "nextjs/google-font-preconnect": ["error"],
1827
- "nextjs/inline-script-id": ["error"],
1828
- "nextjs/next-script-for-ga": ["warn"],
1829
- "nextjs/no-assign-module-variable": ["error"],
1830
- "nextjs/no-css-tags": ["warn"],
1831
- "nextjs/no-document-import-in-page": ["error"],
1832
- "nextjs/no-duplicate-head": ["error"],
1833
- "nextjs/no-head-element": ["warn"],
1834
- "nextjs/no-head-import-in-document": ["error"],
1835
- "nextjs/no-html-link-for-pages": ["off"],
1836
- "nextjs/no-img-element": ["warn"],
1837
- "nextjs/no-page-custom-font": ["warn"],
1838
- "nextjs/no-script-component-in-head": ["error"],
1839
- "nextjs/no-styled-jsx-in-document": ["warn"],
1840
- "nextjs/no-sync-scripts": ["warn"],
1841
- "nextjs/no-title-in-document-head": ["warn"],
1842
- "nextjs/no-typos": ["warn"],
1843
- "nextjs/no-unwanted-polyfillio": ["warn"],
1844
- // This rule creates errors with webpack parsing on edge runtime
1845
- "unicorn/prefer-node-protocol": ["off"],
1846
- ...overrides
1847
- },
1848
- settings: {
1849
- next: {
1850
- rootDir: rootDir ?? true
1851
- },
1852
- react: {
1853
- pragma: "React",
1854
- version: "detect"
1855
- }
1856
- }
1857
- },
1858
- {
1859
- name: "luxass/nextjs/default-export-override",
1860
- files: GLOB_NEXTJS_ROUTES,
1861
- rules: {
1862
- "import/prefer-default-export": "error"
1863
- }
1864
- },
1865
- {
1866
- name: "luxass/nextjs/og-override",
1867
- files: GLOB_NEXTJS_OG,
1868
- rules: {
1869
- "nextjs/no-img-element": "off"
1870
- }
1871
- }
1872
- ];
1873
- }
1874
-
1875
1795
  // src/configs/react.ts
1876
1796
  var import_local_pkg2 = require("local-pkg");
1877
1797
  var ReactRefreshAllowConstantExportPackages = [
@@ -1885,7 +1805,7 @@ var RemixPackages = [
1885
1805
  ];
1886
1806
  async function react(options = {}) {
1887
1807
  const {
1888
- files = [GLOB_TS, GLOB_TSX],
1808
+ files = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
1889
1809
  overrides = {}
1890
1810
  } = options;
1891
1811
  await ensure([
@@ -1961,6 +1881,7 @@ async function react(options = {}) {
1961
1881
  allowExportNames: [
1962
1882
  ...isUsingNext ? [
1963
1883
  "config",
1884
+ "runtime",
1964
1885
  "generateStaticParams",
1965
1886
  "metadata",
1966
1887
  "generateMetadata",
@@ -2213,7 +2134,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2213
2134
  options.dprintOptions || {}
2214
2135
  );
2215
2136
  const pluginFormat = await interop(import("eslint-plugin-format"));
2216
- const configs = [
2137
+ const configs2 = [
2217
2138
  {
2218
2139
  name: "luxass/formatter/setup",
2219
2140
  plugins: {
@@ -2222,7 +2143,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2222
2143
  }
2223
2144
  ];
2224
2145
  if (options.css) {
2225
- configs.push(
2146
+ configs2.push(
2226
2147
  {
2227
2148
  name: "luxass/formatter/css",
2228
2149
  files: [GLOB_CSS, GLOB_POSTCSS],
@@ -2274,7 +2195,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2274
2195
  );
2275
2196
  }
2276
2197
  if (options.html) {
2277
- configs.push({
2198
+ configs2.push({
2278
2199
  name: "luxass/formatter/html",
2279
2200
  files: [GLOB_HTML],
2280
2201
  languageOptions: {
@@ -2293,7 +2214,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2293
2214
  }
2294
2215
  if (options.markdown) {
2295
2216
  const formater = options.markdown === true ? "prettier" : options.markdown;
2296
- configs.push({
2217
+ configs2.push({
2297
2218
  name: "luxass/formatter/markdown",
2298
2219
  files: [GLOB_MARKDOWN],
2299
2220
  languageOptions: {
@@ -2316,7 +2237,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2316
2237
  });
2317
2238
  }
2318
2239
  if (options.astro) {
2319
- configs.push({
2240
+ configs2.push({
2320
2241
  name: "luxass/formatter/astro",
2321
2242
  files: [GLOB_ASTRO],
2322
2243
  languageOptions: {
@@ -2337,7 +2258,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2337
2258
  });
2338
2259
  }
2339
2260
  if (options.graphql) {
2340
- configs.push({
2261
+ configs2.push({
2341
2262
  name: "luxass/formatter/graphql",
2342
2263
  files: [GLOB_GRAPHQL],
2343
2264
  languageOptions: {
@@ -2354,7 +2275,7 @@ async function formatters(options = {}, stylistic2 = {}) {
2354
2275
  }
2355
2276
  });
2356
2277
  }
2357
- return configs;
2278
+ return configs2;
2358
2279
  }
2359
2280
 
2360
2281
  // src/configs/toml.ts
@@ -2493,6 +2414,32 @@ async function solid(options = {}) {
2493
2414
  ];
2494
2415
  }
2495
2416
 
2417
+ // src/configs/regexp.ts
2418
+ var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
2419
+ async function regexp(options = {}) {
2420
+ const config = import_eslint_plugin_regexp.configs["flat/recommended"];
2421
+ const rules = {
2422
+ ...config.rules
2423
+ };
2424
+ if (options.level === "warn") {
2425
+ for (const key in rules) {
2426
+ if (rules[key] === "error") {
2427
+ rules[key] = "warn";
2428
+ }
2429
+ }
2430
+ }
2431
+ return [
2432
+ {
2433
+ ...config,
2434
+ name: "luxass/regexp/rules",
2435
+ rules: {
2436
+ ...rules,
2437
+ ...options.overrides
2438
+ }
2439
+ }
2440
+ ];
2441
+ }
2442
+
2496
2443
  // src/factory.ts
2497
2444
  var FLAT_CONFIG_PROPS = [
2498
2445
  "name",
@@ -2521,8 +2468,7 @@ var defaultPluginRenaming = {
2521
2468
  "@eslint-react": "react",
2522
2469
  "@eslint-react/dom": "react-dom",
2523
2470
  "@eslint-react/hooks-extra": "react-hooks-extra",
2524
- "@eslint-react/naming-convention": "react-naming-convention",
2525
- "@next/next": "nextjs"
2471
+ "@eslint-react/naming-convention": "react-naming-convention"
2526
2472
  };
2527
2473
  function luxass(options = {}, ...userConfigs) {
2528
2474
  const {
@@ -2531,30 +2477,30 @@ function luxass(options = {}, ...userConfigs) {
2531
2477
  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),
2532
2478
  exts = [],
2533
2479
  gitignore: enableGitignore = true,
2534
- nextjs: enableNextJS = false,
2535
2480
  react: enableReact = false,
2536
2481
  tailwindcss: enableTailwindCSS = false,
2537
2482
  svelte: enableSvelte = false,
2538
2483
  solid: enableSolid = false,
2539
2484
  typescript: enableTypeScript = (0, import_local_pkg4.isPackageExists)("typescript"),
2540
2485
  unocss: enableUnoCSS = false,
2486
+ regexp: enableRegexp = true,
2541
2487
  vue: enableVue = VuePackages.some((i) => (0, import_local_pkg4.isPackageExists)(i))
2542
2488
  } = options;
2543
2489
  const stylisticOptions = options.stylistic === false ? false : typeof options.stylistic === "object" ? options.stylistic : {};
2544
2490
  if (stylisticOptions && !("jsx" in stylisticOptions)) {
2545
2491
  stylisticOptions.jsx = options.jsx ?? true;
2546
2492
  }
2547
- const configs = [];
2493
+ const configs2 = [];
2548
2494
  if (enableGitignore) {
2549
2495
  if (typeof enableGitignore !== "boolean") {
2550
- configs.push(interop(import("eslint-config-flat-gitignore")).then((plugin) => [plugin(enableGitignore)]));
2496
+ configs2.push(interop(import("eslint-config-flat-gitignore")).then((plugin) => [plugin(enableGitignore)]));
2551
2497
  } else {
2552
2498
  if ((0, import_node_fs.existsSync)(".gitignore")) {
2553
- configs.push(interop(import("eslint-config-flat-gitignore")).then((plugin) => [plugin()]));
2499
+ configs2.push(interop(import("eslint-config-flat-gitignore")).then((plugin) => [plugin()]));
2554
2500
  }
2555
2501
  }
2556
2502
  }
2557
- configs.push(
2503
+ configs2.push(
2558
2504
  ignores(),
2559
2505
  javascript({
2560
2506
  editor,
@@ -2574,41 +2520,39 @@ function luxass(options = {}, ...userConfigs) {
2574
2520
  exts.push("vue");
2575
2521
  }
2576
2522
  if (enableTypeScript) {
2577
- configs.push(typescript({
2523
+ configs2.push(typescript({
2578
2524
  ...resolveSubOptions(options, "typescript"),
2579
2525
  exts,
2580
2526
  overrides: getOverrides(options, "typescript")
2581
2527
  }));
2582
2528
  }
2583
2529
  if (stylisticOptions) {
2584
- configs.push(stylistic({
2530
+ configs2.push(stylistic({
2585
2531
  ...stylisticOptions,
2586
2532
  overrides: getOverrides(options, "stylistic")
2587
2533
  }));
2588
2534
  }
2535
+ if (enableRegexp) {
2536
+ configs2.push(regexp({
2537
+ ...resolveSubOptions(options, "regexp"),
2538
+ overrides: getOverrides(options, "regexp")
2539
+ }));
2540
+ }
2589
2541
  if (options.test ?? true) {
2590
- configs.push(test({
2542
+ configs2.push(test({
2591
2543
  editor,
2592
2544
  overrides: getOverrides(options, "test")
2593
2545
  }));
2594
2546
  }
2595
- if (enableReact || enableNextJS) {
2596
- configs.push(react({
2547
+ if (enableReact) {
2548
+ configs2.push(react({
2597
2549
  ...resolveSubOptions(options, "react"),
2598
2550
  overrides: getOverrides(options, "react"),
2599
2551
  tsconfigPath: getOverrides(options, "typescript").tsconfigPath
2600
2552
  }));
2601
2553
  }
2602
- if (enableNextJS) {
2603
- configs.push(
2604
- nextjs({
2605
- ...resolveSubOptions(options, "nextjs"),
2606
- overrides: getOverrides(options, "nextjs")
2607
- })
2608
- );
2609
- }
2610
2554
  if (enableSolid) {
2611
- configs.push(
2555
+ configs2.push(
2612
2556
  solid({
2613
2557
  ...resolveSubOptions(options, "solid"),
2614
2558
  overrides: getOverrides(options, "solid"),
@@ -2617,7 +2561,7 @@ function luxass(options = {}, ...userConfigs) {
2617
2561
  );
2618
2562
  }
2619
2563
  if (enableSvelte) {
2620
- configs.push(
2564
+ configs2.push(
2621
2565
  svelte({
2622
2566
  ...resolveSubOptions(options, "svelte"),
2623
2567
  overrides: getOverrides(options, "svelte"),
@@ -2627,7 +2571,7 @@ function luxass(options = {}, ...userConfigs) {
2627
2571
  );
2628
2572
  }
2629
2573
  if (enableVue) {
2630
- configs.push(
2574
+ configs2.push(
2631
2575
  vue({
2632
2576
  ...resolveSubOptions(options, "vue"),
2633
2577
  overrides: getOverrides(options, "vue"),
@@ -2637,7 +2581,7 @@ function luxass(options = {}, ...userConfigs) {
2637
2581
  );
2638
2582
  }
2639
2583
  if (enableAstro) {
2640
- configs.push(
2584
+ configs2.push(
2641
2585
  astro({
2642
2586
  ...resolveSubOptions(options, "astro"),
2643
2587
  overrides: getOverrides(options, "astro"),
@@ -2646,19 +2590,19 @@ function luxass(options = {}, ...userConfigs) {
2646
2590
  );
2647
2591
  }
2648
2592
  if (enableUnoCSS) {
2649
- configs.push(unocss({
2593
+ configs2.push(unocss({
2650
2594
  ...resolveSubOptions(options, "unocss"),
2651
2595
  overrides: getOverrides(options, "unocss")
2652
2596
  }));
2653
2597
  }
2654
2598
  if (enableTailwindCSS) {
2655
- configs.push(tailwindcss({
2599
+ configs2.push(tailwindcss({
2656
2600
  ...resolveSubOptions(options, "tailwindcss"),
2657
2601
  overrides: getOverrides(options, "tailwindcss")
2658
2602
  }));
2659
2603
  }
2660
2604
  if (options.jsonc ?? true) {
2661
- configs.push(
2605
+ configs2.push(
2662
2606
  jsonc({
2663
2607
  overrides: getOverrides(options, "jsonc"),
2664
2608
  stylistic: stylisticOptions
@@ -2668,19 +2612,19 @@ function luxass(options = {}, ...userConfigs) {
2668
2612
  );
2669
2613
  }
2670
2614
  if (options.yaml ?? true) {
2671
- configs.push(yaml({
2615
+ configs2.push(yaml({
2672
2616
  overrides: getOverrides(options, "yaml"),
2673
2617
  stylistic: stylisticOptions
2674
2618
  }));
2675
2619
  }
2676
2620
  if (options.toml ?? true) {
2677
- configs.push(toml({
2621
+ configs2.push(toml({
2678
2622
  overrides: getOverrides(options, "toml"),
2679
2623
  stylistic: stylisticOptions
2680
2624
  }));
2681
2625
  }
2682
2626
  if (options.markdown ?? true) {
2683
- configs.push(
2627
+ configs2.push(
2684
2628
  markdown({
2685
2629
  exts,
2686
2630
  overrides: getOverrides(options, "markdown")
@@ -2688,7 +2632,7 @@ function luxass(options = {}, ...userConfigs) {
2688
2632
  );
2689
2633
  }
2690
2634
  if (options.formatters) {
2691
- configs.push(formatters(
2635
+ configs2.push(formatters(
2692
2636
  options.formatters,
2693
2637
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2694
2638
  ));
@@ -2700,11 +2644,11 @@ function luxass(options = {}, ...userConfigs) {
2700
2644
  return acc;
2701
2645
  }, {});
2702
2646
  if (Object.keys(fusedConfig).length) {
2703
- configs.push([fusedConfig]);
2647
+ configs2.push([fusedConfig]);
2704
2648
  }
2705
2649
  let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2706
2650
  composer = composer.append(
2707
- ...configs,
2651
+ ...configs2,
2708
2652
  ...userConfigs
2709
2653
  );
2710
2654
  if (autoRenamePlugins) {
@@ -2759,10 +2703,10 @@ var src_default = luxass;
2759
2703
  jsonc,
2760
2704
  luxass,
2761
2705
  markdown,
2762
- nextjs,
2763
2706
  node,
2764
2707
  parserPlain,
2765
2708
  react,
2709
+ regexp,
2766
2710
  renameRules,
2767
2711
  resolveSubOptions,
2768
2712
  solid,