@vinicunca/eslint-config 2.4.4 → 2.6.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
@@ -68,16 +68,19 @@ __export(src_exports, {
68
68
  node: () => node,
69
69
  parserPlain: () => parserPlain,
70
70
  perfectionist: () => perfectionist,
71
+ pluginAntfu: () => import_eslint_plugin_antfu.default,
71
72
  pluginComments: () => import_eslint_plugin_eslint_comments.default,
72
73
  pluginImport: () => pluginImport,
73
74
  pluginNode: () => import_eslint_plugin_n.default,
74
75
  pluginPerfectionist: () => import_eslint_plugin_perfectionist.default,
76
+ pluginSonar: () => import_eslint_plugin_sonarjs.default,
75
77
  pluginUnicorn: () => import_eslint_plugin_unicorn.default,
76
78
  pluginUnusedImports: () => import_eslint_plugin_unused_imports.default,
77
- pluginVinicunca: () => import_eslint_plugin_vinicunca.default,
78
79
  react: () => react,
80
+ regexp: () => regexp,
79
81
  renamePluginInConfigs: () => renamePluginInConfigs,
80
82
  renameRules: () => renameRules,
83
+ sonar: () => sonar,
81
84
  sortPackageJson: () => sortPackageJson,
82
85
  sortTsconfig: () => sortTsconfig,
83
86
  stylistic: () => stylistic,
@@ -865,11 +868,12 @@ var NEVER = "never";
865
868
  var ALWAYS = "always";
866
869
 
867
870
  // src/plugins.ts
868
- var import_eslint_plugin_vinicunca = __toESM(require("@vinicunca/eslint-plugin-vinicunca"), 1);
871
+ var import_eslint_plugin_antfu = __toESM(require("eslint-plugin-antfu"), 1);
869
872
  var import_eslint_plugin_eslint_comments = __toESM(require("eslint-plugin-eslint-comments"), 1);
870
873
  var pluginImport = __toESM(require("eslint-plugin-import-x"), 1);
871
874
  var import_eslint_plugin_n = __toESM(require("eslint-plugin-n"), 1);
872
875
  var import_eslint_plugin_perfectionist = __toESM(require("eslint-plugin-perfectionist"), 1);
876
+ var import_eslint_plugin_sonarjs = __toESM(require("eslint-plugin-sonarjs"), 1);
873
877
  var import_eslint_plugin_unicorn = __toESM(require("eslint-plugin-unicorn"), 1);
874
878
  var import_eslint_plugin_unused_imports = __toESM(require("eslint-plugin-unused-imports"), 1);
875
879
 
@@ -961,8 +965,8 @@ var GLOB_EXCLUDE = [
961
965
  ];
962
966
 
963
967
  // src/utils.ts
964
- async function combineConfigs(...configs) {
965
- const resolved = await Promise.all(configs);
968
+ async function combineConfigs(...configs2) {
969
+ const resolved = await Promise.all(configs2);
966
970
  return resolved.flat();
967
971
  }
968
972
  function renameRules(rules, map2) {
@@ -977,8 +981,8 @@ function renameRules(rules, map2) {
977
981
  })
978
982
  );
979
983
  }
980
- function renamePluginInConfigs(configs, map2) {
981
- return configs.map((i) => {
984
+ function renamePluginInConfigs(configs2, map2) {
985
+ return configs2.map((i) => {
982
986
  const clone = { ...i };
983
987
  if (clone.rules) {
984
988
  clone.rules = renameRules(clone.rules, map2);
@@ -1056,8 +1060,8 @@ async function stylistic(options = {}) {
1056
1060
  {
1057
1061
  name: "vinicunca/stylistic/rules",
1058
1062
  plugins: {
1059
- style: pluginStylistic,
1060
- vinicunca: import_eslint_plugin_vinicunca.default
1063
+ antfu: import_eslint_plugin_antfu.default,
1064
+ style: pluginStylistic
1061
1065
  },
1062
1066
  rules: {
1063
1067
  ...config.rules,
@@ -1119,17 +1123,8 @@ async function stylistic(options = {}) {
1119
1123
  "style/rest-spread-spacing": [ERROR, NEVER],
1120
1124
  "style/semi": [ERROR, semi ? ALWAYS : NEVER],
1121
1125
  "style/semi-spacing": [ERROR, { after: true, before: false }],
1122
- "vinicunca/consistent-list-newline": ERROR,
1123
- "vinicunca/if-newline": ERROR,
1124
- "vinicunca/top-level-function": ERROR,
1125
1126
  ...overrides
1126
1127
  }
1127
- },
1128
- {
1129
- files: [GLOB_JSX, GLOB_TSX],
1130
- rules: {
1131
- "vinicunca/consistent-list-newline": OFF
1132
- }
1133
1128
  }
1134
1129
  ];
1135
1130
  }
@@ -1172,7 +1167,7 @@ async function formatters(options = {}, stylistic2 = {}) {
1172
1167
  options.dprintOptions || {}
1173
1168
  );
1174
1169
  const pluginFormat = await interopDefault(import("eslint-plugin-format"));
1175
- const configs = [
1170
+ const configs2 = [
1176
1171
  {
1177
1172
  name: "vinicunca/formatter/setup",
1178
1173
  plugins: {
@@ -1181,7 +1176,7 @@ async function formatters(options = {}, stylistic2 = {}) {
1181
1176
  }
1182
1177
  ];
1183
1178
  if (options.css) {
1184
- configs.push(
1179
+ configs2.push(
1185
1180
  {
1186
1181
  files: [GLOB_CSS, GLOB_POSTCSS],
1187
1182
  languageOptions: {
@@ -1233,7 +1228,7 @@ async function formatters(options = {}, stylistic2 = {}) {
1233
1228
  );
1234
1229
  }
1235
1230
  if (options.html) {
1236
- configs.push({
1231
+ configs2.push({
1237
1232
  files: ["**/*.html"],
1238
1233
  languageOptions: {
1239
1234
  parser: parserPlain
@@ -1252,7 +1247,7 @@ async function formatters(options = {}, stylistic2 = {}) {
1252
1247
  }
1253
1248
  if (options.markdown) {
1254
1249
  const formater = options.markdown === true ? "prettier" : options.markdown;
1255
- configs.push({
1250
+ configs2.push({
1256
1251
  files: [GLOB_MARKDOWN],
1257
1252
  languageOptions: {
1258
1253
  parser: parserPlain
@@ -1275,7 +1270,7 @@ async function formatters(options = {}, stylistic2 = {}) {
1275
1270
  });
1276
1271
  }
1277
1272
  if (options.graphql) {
1278
- configs.push({
1273
+ configs2.push({
1279
1274
  files: ["**/*.graphql"],
1280
1275
  languageOptions: {
1281
1276
  parser: parserPlain
@@ -1292,7 +1287,7 @@ async function formatters(options = {}, stylistic2 = {}) {
1292
1287
  }
1293
1288
  });
1294
1289
  }
1295
- return configs;
1290
+ return configs2;
1296
1291
  }
1297
1292
 
1298
1293
  // src/configs/ignores.ts
@@ -1310,8 +1305,8 @@ async function imports() {
1310
1305
  {
1311
1306
  name: "vinicunca/imports/rules",
1312
1307
  plugins: {
1313
- import: pluginImport,
1314
- vinicunca: import_eslint_plugin_vinicunca.default
1308
+ antfu: import_eslint_plugin_antfu.default,
1309
+ import: pluginImport
1315
1310
  },
1316
1311
  rules: {
1317
1312
  "import/export": ERROR,
@@ -1326,9 +1321,7 @@ async function imports() {
1326
1321
  "import/no-self-import": ERROR,
1327
1322
  "import/no-webpack-loader-syntax": ERROR,
1328
1323
  // Turned off to avoid conflicts with Perfectionist. https://eslint-plugin-perfectionist.azat.io/rules/sort-imports
1329
- "import/order": OFF,
1330
- "vinicunca/import-dedupe": ERROR,
1331
- "vinicunca/no-import-node-modules-by-path": ERROR
1324
+ "import/order": OFF
1332
1325
  }
1333
1326
  }
1334
1327
  ];
@@ -1367,8 +1360,8 @@ async function javascript(options = {}) {
1367
1360
  },
1368
1361
  name: "vinicunca/javascript/rules",
1369
1362
  plugins: {
1370
- "unused-imports": import_eslint_plugin_unused_imports.default,
1371
- "vinicunca": import_eslint_plugin_vinicunca.default
1363
+ "antfu": import_eslint_plugin_antfu.default,
1364
+ "unused-imports": import_eslint_plugin_unused_imports.default
1372
1365
  },
1373
1366
  rules: {
1374
1367
  "accessor-pairs": [ERROR, {
@@ -1588,7 +1581,6 @@ async function javascript(options = {}) {
1588
1581
  }],
1589
1582
  "vars-on-top": ERROR,
1590
1583
  "yoda": [ERROR, NEVER],
1591
- ...import_eslint_plugin_vinicunca.default.configs.recommended.rules,
1592
1584
  ...overrides
1593
1585
  }
1594
1586
  },
@@ -1806,7 +1798,6 @@ async function markdown(options = {}) {
1806
1798
  "ts/restrict-template-expressions": OFF,
1807
1799
  "ts/unbound-method": OFF
1808
1800
  },
1809
- "vinicunca/no-ts-export-equal": OFF,
1810
1801
  ...overrides
1811
1802
  }
1812
1803
  }
@@ -1877,7 +1868,7 @@ async function perfectionist() {
1877
1868
  // src/configs/react.ts
1878
1869
  async function react(options = {}) {
1879
1870
  const {
1880
- files = [GLOB_JSX, GLOB_TSX],
1871
+ files = [GLOB_JS, GLOB_JSX, GLOB_TS, GLOB_TSX],
1881
1872
  overrides = {}
1882
1873
  } = options;
1883
1874
  const [
@@ -1945,6 +1936,47 @@ async function react(options = {}) {
1945
1936
  ];
1946
1937
  }
1947
1938
 
1939
+ // src/configs/regexp.ts
1940
+ var import_eslint_plugin_regexp = require("eslint-plugin-regexp");
1941
+ async function regexp(options = {}) {
1942
+ const config = import_eslint_plugin_regexp.configs["flat/recommended"];
1943
+ const rules = {
1944
+ ...config.rules
1945
+ };
1946
+ if (options.level === WARN) {
1947
+ for (const key in rules) {
1948
+ if (rules[key] === ERROR) {
1949
+ rules[key] = WARN;
1950
+ }
1951
+ }
1952
+ }
1953
+ return [
1954
+ {
1955
+ ...config,
1956
+ name: "vinicunca/regexp/rules",
1957
+ rules: {
1958
+ ...rules,
1959
+ ...options.overrides
1960
+ }
1961
+ }
1962
+ ];
1963
+ }
1964
+
1965
+ // src/configs/sonar.ts
1966
+ async function sonar() {
1967
+ return [
1968
+ {
1969
+ name: "vinicunca/sonar/rules",
1970
+ plugins: {
1971
+ sonar: import_eslint_plugin_sonarjs.default
1972
+ },
1973
+ rules: {
1974
+ ...import_eslint_plugin_sonarjs.default.configs.recommended.rules
1975
+ }
1976
+ }
1977
+ ];
1978
+ }
1979
+
1948
1980
  // src/configs/sort-package-json.ts
1949
1981
  async function sortPackageJson() {
1950
1982
  return [
@@ -2252,7 +2284,8 @@ async function typescript(options = {}) {
2252
2284
  "ts/no-misused-promises": OFF,
2253
2285
  "ts/no-throw-literal": ERROR,
2254
2286
  "ts/restrict-plus-operands": ERROR,
2255
- "ts/restrict-template-expressions": ERROR
2287
+ "ts/restrict-template-expressions": ERROR,
2288
+ "ts/strict-boolean-expressions": "error"
2256
2289
  };
2257
2290
  const [
2258
2291
  pluginTs,
@@ -2285,8 +2318,8 @@ async function typescript(options = {}) {
2285
2318
  // Install the plugins without globs, so they can be configured separately.
2286
2319
  name: "vinicunca/typescript/setup",
2287
2320
  plugins: {
2288
- ts: pluginTs,
2289
- vinicunca: import_eslint_plugin_vinicunca.default
2321
+ antfu: import_eslint_plugin_antfu.default,
2322
+ ts: pluginTs
2290
2323
  }
2291
2324
  },
2292
2325
  // assign type-aware parser for type-aware files and type-unaware parser for the rest
@@ -2675,6 +2708,7 @@ var defaultPluginRenaming = {
2675
2708
  "@typescript-eslint": "ts",
2676
2709
  "import-x": "import",
2677
2710
  "n": "node",
2711
+ "sonarjs": "sonar",
2678
2712
  "vitest": "test",
2679
2713
  "yml": "yaml"
2680
2714
  };
@@ -2685,6 +2719,7 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2685
2719
  gitignore: enableGitignore = true,
2686
2720
  isInEditor = !!((import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM) && !import_node_process2.default.env.CI),
2687
2721
  react: enableReact = false,
2722
+ regexp: enableRegexp = true,
2688
2723
  typescript: enableTypeScript = (0, import_local_pkg.isPackageExists)("typescript"),
2689
2724
  unocss: enableUnoCSS = false,
2690
2725
  vue: enableVue = VuePackages.some((i) => (0, import_local_pkg.isPackageExists)(i))
@@ -2698,17 +2733,19 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2698
2733
  jsx: options.jsx ?? true
2699
2734
  };
2700
2735
  }
2701
- const configs = [];
2736
+ const configs2 = [];
2702
2737
  if (enableGitignore) {
2703
2738
  if (typeof enableGitignore !== "boolean") {
2704
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2739
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r(enableGitignore)]));
2705
2740
  } else {
2706
2741
  if (import_node_fs.default.existsSync(".gitignore")) {
2707
- configs.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
2742
+ configs2.push(interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r()]));
2708
2743
  }
2709
2744
  }
2710
2745
  }
2711
- configs.push(
2746
+ const typescriptOptions = resolveSubOptions(options, "typescript");
2747
+ const tsconfigPath = "tsconfigPath" in typescriptOptions ? typescriptOptions.tsconfigPath : void 0;
2748
+ configs2.push(
2712
2749
  ignores(),
2713
2750
  javascript({
2714
2751
  isInEditor,
@@ -2721,32 +2758,36 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2721
2758
  }),
2722
2759
  imports(),
2723
2760
  unicorn(),
2724
- perfectionist()
2761
+ perfectionist(),
2762
+ sonar()
2725
2763
  );
2726
2764
  if (enableVue) {
2727
2765
  componentExts.push("vue");
2728
2766
  }
2729
2767
  if (enableTypeScript) {
2730
- configs.push(typescript({
2731
- ...resolveSubOptions(options, "typescript"),
2768
+ configs2.push(typescript({
2769
+ ...typescriptOptions,
2732
2770
  componentExts,
2733
2771
  overrides: getOverrides(options, "typescript")
2734
2772
  }));
2735
2773
  }
2736
2774
  if (stylisticOptions) {
2737
- configs.push(stylistic({
2775
+ configs2.push(stylistic({
2738
2776
  ...stylisticOptions,
2739
2777
  overrides: getOverrides(options, "stylistic")
2740
2778
  }));
2741
2779
  }
2780
+ if (enableRegexp) {
2781
+ configs2.push(regexp(typeof enableRegexp === "boolean" ? {} : enableRegexp));
2782
+ }
2742
2783
  if (options.test ?? true) {
2743
- configs.push(test({
2784
+ configs2.push(test({
2744
2785
  isInEditor,
2745
2786
  overrides: getOverrides(options, "test")
2746
2787
  }));
2747
2788
  }
2748
2789
  if (enableVue) {
2749
- configs.push(vue({
2790
+ configs2.push(vue({
2750
2791
  ...resolveSubOptions(options, "vue"),
2751
2792
  overrides: getOverrides(options, "vue"),
2752
2793
  stylistic: stylisticOptions,
@@ -2754,19 +2795,19 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2754
2795
  }));
2755
2796
  }
2756
2797
  if (enableReact) {
2757
- configs.push(react({
2798
+ configs2.push(react({
2758
2799
  overrides: getOverrides(options, "react"),
2759
- typescript: !!enableTypeScript
2800
+ tsconfigPath
2760
2801
  }));
2761
2802
  }
2762
2803
  if (enableUnoCSS) {
2763
- configs.push(unocss({
2804
+ configs2.push(unocss({
2764
2805
  ...resolveSubOptions(options, "unocss"),
2765
2806
  overrides: getOverrides(options, "unocss")
2766
2807
  }));
2767
2808
  }
2768
2809
  if (options.jsonc ?? true) {
2769
- configs.push(
2810
+ configs2.push(
2770
2811
  jsonc({
2771
2812
  overrides: getOverrides(options, "jsonc"),
2772
2813
  stylistic: stylisticOptions
@@ -2776,13 +2817,13 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2776
2817
  );
2777
2818
  }
2778
2819
  if (options.yaml ?? true) {
2779
- configs.push(yaml({
2820
+ configs2.push(yaml({
2780
2821
  overrides: getOverrides(options, "yaml"),
2781
2822
  stylistic: stylisticOptions
2782
2823
  }));
2783
2824
  }
2784
2825
  if (options.markdown ?? true) {
2785
- configs.push(
2826
+ configs2.push(
2786
2827
  markdown(
2787
2828
  {
2788
2829
  componentExts,
@@ -2792,7 +2833,7 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2792
2833
  );
2793
2834
  }
2794
2835
  if (options.formatters) {
2795
- configs.push(formatters(
2836
+ configs2.push(formatters(
2796
2837
  options.formatters,
2797
2838
  typeof stylisticOptions === "boolean" ? {} : stylisticOptions
2798
2839
  ));
@@ -2805,18 +2846,18 @@ function vinicuncaESLint(options = {}, ...userConfigs) {
2805
2846
  return acc;
2806
2847
  }, {});
2807
2848
  if (Object.keys(fusedConfig).length) {
2808
- configs.push([fusedConfig]);
2849
+ configs2.push([fusedConfig]);
2809
2850
  }
2810
2851
  ;
2811
- let pipeline = new import_eslint_flat_config_utils.FlatConfigComposer();
2812
- pipeline = pipeline.append(
2813
- ...configs,
2852
+ let composer = new import_eslint_flat_config_utils.FlatConfigComposer();
2853
+ composer = composer.append(
2854
+ ...configs2,
2814
2855
  ...userConfigs
2815
2856
  );
2816
2857
  if (autoRenamePlugins) {
2817
- pipeline = pipeline.renamePlugins(defaultPluginRenaming);
2858
+ composer = composer.renamePlugins(defaultPluginRenaming);
2818
2859
  }
2819
- return pipeline;
2860
+ return composer;
2820
2861
  }
2821
2862
  function getOverrides(options, key) {
2822
2863
  const sub = resolveSubOptions(options, key);
@@ -2867,16 +2908,19 @@ function resolveSubOptions(options, key) {
2867
2908
  node,
2868
2909
  parserPlain,
2869
2910
  perfectionist,
2911
+ pluginAntfu,
2870
2912
  pluginComments,
2871
2913
  pluginImport,
2872
2914
  pluginNode,
2873
2915
  pluginPerfectionist,
2916
+ pluginSonar,
2874
2917
  pluginUnicorn,
2875
2918
  pluginUnusedImports,
2876
- pluginVinicunca,
2877
2919
  react,
2920
+ regexp,
2878
2921
  renamePluginInConfigs,
2879
2922
  renameRules,
2923
+ sonar,
2880
2924
  sortPackageJson,
2881
2925
  sortTsconfig,
2882
2926
  stylistic,