@zayne-labs/eslint-config 0.9.14 → 0.9.16

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.js CHANGED
@@ -3,7 +3,6 @@ import { fileURLToPath } from "node:url";
3
3
  import { isPackageExists } from "local-pkg";
4
4
  import { globalIgnores } from "eslint/config";
5
5
  import globals from "globals";
6
- import { fixupPluginRules } from "@eslint/compat";
7
6
  import { mergeProcessors } from "eslint-merge-processors";
8
7
  import { FlatConfigComposer } from "eslint-flat-config-utils";
9
8
 
@@ -97,8 +96,7 @@ const isObject = (value) => {
97
96
  * @description - Combine array and non-array configs into a single array.
98
97
  */
99
98
  const combine = async (...configs) => {
100
- const resolved = await Promise.all(configs);
101
- return resolved.flat();
99
+ return (await Promise.all(configs)).flat();
102
100
  };
103
101
  const interopDefault = async (module) => {
104
102
  const resolved = await module;
@@ -210,7 +208,7 @@ const overrideConfigs = (options) => {
210
208
  */
211
209
  const renamePluginInConfigs = (options) => {
212
210
  const { configArray, overrides, renameMap } = options;
213
- const renamedConfigs = overrideConfigs({
211
+ return overrideConfigs({
214
212
  configArray,
215
213
  overrides: (configItem) => ({
216
214
  ...getResolvedOverrides({
@@ -221,7 +219,6 @@ const renamePluginInConfigs = (options) => {
221
219
  ...isObject(configItem.rules) && { rules: renameRules(configItem.rules, renameMap) }
222
220
  })
223
221
  });
224
- return renamedConfigs;
225
222
  };
226
223
  const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
227
224
  const isCwdInScope = isPackageExists("@zayne-labs/eslint-config");
@@ -239,12 +236,7 @@ const ensurePackages = async (packages) => {
239
236
  if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
240
237
  const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
241
238
  if (nonExistingPackages.length === 0) return;
242
- const clackPrompt = await import("@clack/prompts");
243
- const result = await clackPrompt.confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` });
244
- if (result) {
245
- const antfuPkg = await import("@antfu/install-pkg");
246
- await antfuPkg.installPackage(nonExistingPackages, { dev: true });
247
- }
239
+ if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await (await import("@antfu/install-pkg")).installPackage(nonExistingPackages, { dev: true });
248
240
  };
249
241
  const resolveOptions = (option) => isObject(option) ? option : {};
250
242
 
@@ -349,13 +341,11 @@ const ignores = (userIgnores = []) => {
349
341
  return [globalIgnores([...GLOB_EXCLUDE, ...userIgnores], "zayne/defaults/ignores")];
350
342
  };
351
343
  const gitIgnores = async (options) => {
352
- const antfuGitIgnore = await interopDefault(import("eslint-config-flat-gitignore"));
353
- const config = antfuGitIgnore({
344
+ return [(await interopDefault(import("eslint-config-flat-gitignore")))({
354
345
  name: "zayne/gitignore/setup",
355
346
  strict: false,
356
347
  ...options
357
- });
358
- return [config];
348
+ })];
359
349
  };
360
350
 
361
351
  //#endregion
@@ -703,6 +693,7 @@ const javascript = async (options = {}) => {
703
693
  "prefer-rest-params": "error",
704
694
  "prefer-spread": "error",
705
695
  "prefer-template": "error",
696
+ "preserve-caught-error": ["error", { requireCatchParameter: true }],
706
697
  radix: "error",
707
698
  "symbol-description": "error",
708
699
  "unicode-bom": ["error", "never"],
@@ -723,10 +714,9 @@ const javascript = async (options = {}) => {
723
714
  //#region src/configs/jsdoc.ts
724
715
  const jsdoc = async (options = {}) => {
725
716
  const { overrides, stylistic: stylistic$1 = true } = options;
726
- const eslintPluginJsdoc = await interopDefault(import("eslint-plugin-jsdoc"));
727
717
  return [{
728
718
  name: "zayne/jsdoc/rules",
729
- plugins: { jsdoc: eslintPluginJsdoc },
719
+ plugins: { jsdoc: await interopDefault(import("eslint-plugin-jsdoc")) },
730
720
  rules: {
731
721
  "jsdoc/check-access": "warn",
732
722
  "jsdoc/check-param-names": "warn",
@@ -864,10 +854,9 @@ const node = async (options = {}) => {
864
854
  //#region src/configs/perfectionist.ts
865
855
  const perfectionist = async (options = {}) => {
866
856
  const { overrides } = options;
867
- const eslintPluginPerfectionist = await interopDefault(import("eslint-plugin-perfectionist"));
868
857
  return [{
869
858
  name: "zayne/perfectionist/rules",
870
- plugins: { perfectionist: eslintPluginPerfectionist },
859
+ plugins: { perfectionist: await interopDefault(import("eslint-plugin-perfectionist")) },
871
860
  rules: {
872
861
  "perfectionist/sort-array-includes": ["warn", {
873
862
  order: "asc",
@@ -1123,7 +1112,7 @@ const react = async (options = {}) => {
1123
1112
  if (nextjs && eslintPluginNextjs) config.push({
1124
1113
  files,
1125
1114
  name: "zayne/react/nextjs",
1126
- plugins: { nextjs: fixupPluginRules(eslintPluginNextjs) },
1115
+ plugins: { nextjs: eslintPluginNextjs },
1127
1116
  rules: renameRules({
1128
1117
  ...eslintPluginNextjs.configs?.recommended?.rules,
1129
1118
  ...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules,
@@ -1389,10 +1378,9 @@ const sortTsconfig = () => [{
1389
1378
  //#region src/configs/stylistic.ts
1390
1379
  const stylistic = async (options = {}) => {
1391
1380
  const { jsx: jsx$1 = true, overrides } = options;
1392
- const eslintPluginStylistic = await interopDefault(import("@stylistic/eslint-plugin"));
1393
1381
  return [{
1394
1382
  name: "zayne/stylistic/rules",
1395
- plugins: { stylistic: eslintPluginStylistic },
1383
+ plugins: { stylistic: await interopDefault(import("@stylistic/eslint-plugin")) },
1396
1384
  rules: {
1397
1385
  "stylistic/no-floating-decimal": "error",
1398
1386
  "stylistic/spaced-comment": [
@@ -1663,9 +1651,8 @@ const typescript = async (options = {}) => {
1663
1651
  //#region src/configs/unicorn.ts
1664
1652
  const unicorn = async (options = {}) => {
1665
1653
  const { overrides, type = "app" } = options;
1666
- const eslintPluginUnicorn = await interopDefault(import("eslint-plugin-unicorn"));
1667
1654
  return [{
1668
- ...eslintPluginUnicorn.configs.recommended,
1655
+ ...(await interopDefault(import("eslint-plugin-unicorn"))).configs.recommended,
1669
1656
  name: "zayne/unicorn/recommended"
1670
1657
  }, {
1671
1658
  name: "zayne/unicorn/rules",