@zayne-labs/eslint-config 0.10.2 → 0.10.4

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
@@ -300,24 +300,30 @@ const depend = async (options = {}) => {
300
300
  const { files = [GLOB_SRC], overrides } = options;
301
301
  await ensurePackages(["eslint-plugin-depend"]);
302
302
  const [eslintPluginDepend, jsoncParser] = await Promise.all([interopDefault(import("eslint-plugin-depend")), interopDefault(import("jsonc-eslint-parser"))]);
303
- return [{
304
- files,
305
- name: "zayne/depend/recommended",
306
- plugins: { depend: eslintPluginDepend },
307
- rules: {
308
- ...eslintPluginDepend.configs["flat/recommended"]?.rules,
309
- ...overrides
310
- }
311
- }, {
312
- files: ["package.json", "**/package.json"],
313
- languageOptions: { parser: jsoncParser },
314
- name: "zayne/depend/recommended/package-json",
315
- plugins: { depend: eslintPluginDepend },
316
- rules: {
317
- ...eslintPluginDepend.configs["flat/recommended"]?.rules,
318
- ...overrides
303
+ return [
304
+ {
305
+ name: "zayne/depend/setup",
306
+ plugins: { depend: eslintPluginDepend }
307
+ },
308
+ {
309
+ files,
310
+ name: "zayne/depend/recommended",
311
+ rules: {
312
+ ...eslintPluginDepend.configs["flat/recommended"]?.rules,
313
+ ...overrides
314
+ }
315
+ },
316
+ {
317
+ files: ["package.json", "**/package.json"],
318
+ languageOptions: { parser: jsoncParser },
319
+ name: "zayne/depend/recommended/package-json",
320
+ plugins: { depend: eslintPluginDepend },
321
+ rules: {
322
+ ...eslintPluginDepend.configs["flat/recommended"]?.rules,
323
+ ...overrides
324
+ }
319
325
  }
320
- }];
326
+ ];
321
327
  };
322
328
 
323
329
  //#endregion
@@ -941,28 +947,33 @@ async function pnpm(options = {}) {
941
947
  interopDefault(import("yaml-eslint-parser")),
942
948
  interopDefault(import("jsonc-eslint-parser"))
943
949
  ]);
944
- return [{
945
- files: ["package.json", "**/package.json"],
946
- languageOptions: { parser: jsoncParser },
947
- name: "zayne/pnpm/rules/package-json",
948
- plugins: { pnpm: eslintPluginPnpm },
949
- rules: {
950
- "pnpm/json-enforce-catalog": "error",
951
- "pnpm/json-prefer-workspace-settings": "error",
952
- "pnpm/json-valid-catalog": "error",
953
- ...overrides?.json
954
- }
955
- }, {
956
- files: ["pnpm-workspace.yaml"],
957
- languageOptions: { parser: yamlParser },
958
- name: "zayne/pnpm/rules/pnpm-workspace-yaml",
959
- plugins: { pnpm: eslintPluginPnpm },
960
- rules: {
961
- "pnpm/yaml-no-duplicate-catalog-item": "error",
962
- "pnpm/yaml-no-unused-catalog-item": "error",
963
- ...overrides?.yaml
950
+ return [
951
+ {
952
+ name: "zayne/pnpm/setup",
953
+ plugins: { pnpm: eslintPluginPnpm }
954
+ },
955
+ {
956
+ files: ["package.json", "**/package.json"],
957
+ languageOptions: { parser: jsoncParser },
958
+ name: "zayne/pnpm/rules/package-json",
959
+ rules: {
960
+ "pnpm/json-enforce-catalog": "error",
961
+ "pnpm/json-prefer-workspace-settings": "error",
962
+ "pnpm/json-valid-catalog": "error",
963
+ ...overrides?.json
964
+ }
965
+ },
966
+ {
967
+ files: ["pnpm-workspace.yaml"],
968
+ languageOptions: { parser: yamlParser },
969
+ name: "zayne/pnpm/rules/pnpm-workspace-yaml",
970
+ rules: {
971
+ "pnpm/yaml-no-duplicate-catalog-item": "error",
972
+ "pnpm/yaml-no-unused-catalog-item": "error",
973
+ ...overrides?.yaml
974
+ }
964
975
  }
965
- }];
976
+ ];
966
977
  }
967
978
 
968
979
  //#endregion
@@ -1036,13 +1047,12 @@ const react = async (options = {}) => {
1036
1047
  enableReact ? interopDefault(import("@eslint-react/eslint-plugin")) : void 0,
1037
1048
  enableReact ? interopDefault(import("eslint-plugin-react-hooks")) : void 0,
1038
1049
  refresh ? interopDefault(import("eslint-plugin-react-refresh")) : void 0,
1039
- youMightNotNeedAnEffect ? interopDefault(import("./src-DwSufEpw.js")) : void 0,
1050
+ youMightNotNeedAnEffect ? interopDefault(import("./src-tkLps0qA.js")) : void 0,
1040
1051
  nextjs ? interopDefault(import("@next/eslint-plugin-next")) : void 0
1041
1052
  ]);
1042
1053
  const recommendedReactConfig = eslintPluginReact?.configs[typescript$1 ? "recommended-type-checked" : "recommended"];
1043
1054
  const config = [];
1044
1055
  if (enableReact && recommendedReactConfig && eslintReactHooks) config.push({
1045
- files,
1046
1056
  languageOptions: { parserOptions: {
1047
1057
  ecmaFeatures: { jsx: true },
1048
1058
  sourceType: "module"
@@ -1054,17 +1064,37 @@ const react = async (options = {}) => {
1054
1064
  "react-you-might-not-need-an-effect": eslintPluginReactYouMightNotNeedAnEffect
1055
1065
  },
1056
1066
  settings: recommendedReactConfig.settings
1067
+ }, {
1068
+ files,
1069
+ name: "zayne/react/official/recommended",
1070
+ rules: {
1071
+ "react-hooks/exhaustive-deps": "warn",
1072
+ "react-hooks/rules-of-hooks": "error"
1073
+ }
1074
+ }, {
1075
+ files,
1076
+ name: "zayne/react/official/rules",
1077
+ rules: {
1078
+ "react-hooks/error-boundaries": "error",
1079
+ "react-hooks/globals": "error",
1080
+ "react-hooks/immutability": "error",
1081
+ "react-hooks/purity": "warn",
1082
+ "react-hooks/refs": "error",
1083
+ "react-hooks/set-state-in-effect": "warn",
1084
+ "react-hooks/set-state-in-render": "error",
1085
+ "react-hooks/static-components": "warn",
1086
+ "react-hooks/use-memo": "warn"
1087
+ }
1057
1088
  }, {
1058
1089
  files: typescript$1 ? filesTypeAware : files,
1059
1090
  ...typescript$1 && { ignores: ignoresTypeAware },
1060
- name: `zayne/react/${typescript$1 ? "recommended-type-checked" : "recommended"}`,
1091
+ name: `zayne/react/unofficial/${typescript$1 ? "recommended-type-checked" : "recommended"}`,
1061
1092
  rules: renameRules(recommendedReactConfig.rules, defaultPluginRenameMap)
1062
1093
  }, {
1063
1094
  files,
1064
- name: "zayne/react/rules",
1095
+ name: "zayne/react/unofficial/rules",
1065
1096
  rules: {
1066
- "react-hooks/exhaustive-deps": "warn",
1067
- "react-hooks/rules-of-hooks": "error",
1097
+ "react-hooks-extra/no-direct-set-state-in-use-effect": "off",
1068
1098
  "react-naming-convention/component-name": "warn",
1069
1099
  "react-naming-convention/use-state": "off",
1070
1100
  "react-x/jsx-shorthand-boolean": ["error", -1],
@@ -1084,6 +1114,17 @@ const react = async (options = {}) => {
1084
1114
  ...isObject$1(enableReact) && enableReact.overrides
1085
1115
  }
1086
1116
  });
1117
+ if (compiler && eslintPluginReact) config.push({
1118
+ files,
1119
+ name: "zayne/react/compiler/rules",
1120
+ rules: {
1121
+ "react-hooks/config": "error",
1122
+ "react-hooks/gating": "error",
1123
+ "react-hooks/incompatible-library": "warn",
1124
+ "react-hooks/preserve-manual-memoization": "warn",
1125
+ "react-hooks/unsupported-syntax": "error"
1126
+ }
1127
+ });
1087
1128
  if (refresh && eslintPluginReactRefresh) config.push({
1088
1129
  files,
1089
1130
  name: "zayne/react/refresh/rules",
@@ -1110,15 +1151,6 @@ const react = async (options = {}) => {
1110
1151
  ...isObject$1(youMightNotNeedAnEffect) && youMightNotNeedAnEffect.overrides
1111
1152
  }
1112
1153
  });
1113
- if (compiler) config.push({
1114
- files,
1115
- name: "zayne/react/compiler/rules",
1116
- rules: {
1117
- "react-hooks/react-compiler": "error",
1118
- ...overrides,
1119
- ...isObject$1(compiler) && compiler.overrides
1120
- }
1121
- });
1122
1154
  if (nextjs && eslintPluginNextjs) config.push({
1123
1155
  files,
1124
1156
  name: "zayne/react/nextjs/recommended",
@@ -1544,14 +1576,14 @@ const toml = async (options = {}) => {
1544
1576
  //#endregion
1545
1577
  //#region src/configs/typescript.ts
1546
1578
  const typescript = async (options = {}) => {
1547
- const { allowDefaultProject, componentExts = [], files = [
1579
+ const { allowDefaultProject, componentExts = [], componentExtsTypeAware = [], files = [
1548
1580
  GLOB_TS,
1549
1581
  GLOB_TSX,
1550
1582
  ...componentExts.map((ext) => `**/*.${ext}`)
1551
1583
  ], filesTypeAware = [
1552
1584
  GLOB_TS,
1553
1585
  GLOB_TSX,
1554
- ...componentExts.map((ext) => `**/*.${ext}`)
1586
+ ...componentExtsTypeAware.map((ext) => `**/*.${ext}`)
1555
1587
  ], ignoresTypeAware = [`${GLOB_MARKDOWN}/**`, GLOB_ASTRO_TS], tsconfigPath = true, isTypeAware = Boolean(tsconfigPath), overrides, parserOptions, stylistic: stylistic$1 = true } = options;
1556
1588
  const tsEslint = await interopDefault(import("typescript-eslint"));
1557
1589
  const projectServiceObject = isTypeAware && (allowDefaultProject ? {
@@ -1578,43 +1610,40 @@ const typescript = async (options = {}) => {
1578
1610
  }
1579
1611
  }
1580
1612
  });
1581
- const selectedBaseRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1582
- const selectedStylisticRuleSet = isTypeAware ? "stylisticTypeChecked" : "stylistic";
1583
- const typeAwareRules = {
1584
- "ts-eslint/no-unnecessary-type-parameters": "off",
1585
- "ts-eslint/non-nullable-type-assertion-style": "off",
1586
- "ts-eslint/prefer-nullish-coalescing": ["error", { ignoreConditionalTests: true }],
1587
- "ts-eslint/restrict-template-expressions": ["error", {
1588
- allowBoolean: true,
1589
- allowNullish: true,
1590
- allowNumber: true
1591
- }],
1592
- "ts-eslint/return-await": ["error", "in-try-catch"]
1593
- };
1613
+ const recommendedRules = tsEslint.configs[isTypeAware ? "strictTypeChecked" : "strict"].map((config) => config.rules).reduce((accumulator, rules) => ({
1614
+ ...accumulator,
1615
+ ...rules
1616
+ }), {});
1617
+ const recommendedStylisticRules = tsEslint.configs[isTypeAware ? "stylisticTypeChecked" : "stylistic"].map((config) => config.rules).reduce((accumulator, rules) => ({
1618
+ ...accumulator,
1619
+ ...rules
1620
+ }), {});
1594
1621
  return [
1595
1622
  {
1596
- name: `zayne/ts-eslint/${isTypeAware ? "setup-type-aware" : "setup"}`,
1597
- ...isTypeAware ? makeParser(filesTypeAware, ignoresTypeAware) : makeParser(files)
1623
+ name: "zayne/ts-eslint/setup",
1624
+ plugins: { "ts-eslint": tsEslint.plugin }
1598
1625
  },
1599
- ...renamePluginInConfigs({
1600
- configArray: tsEslint.configs[selectedBaseRuleSet],
1601
- overrides: {
1602
- files: isTypeAware ? filesTypeAware : files,
1603
- name: `zayne/ts-eslint/${selectedBaseRuleSet}`
1604
- },
1605
- renameMap: { "@typescript-eslint": "ts-eslint" }
1606
- }),
1607
- ...stylistic$1 ? renamePluginInConfigs({
1608
- configArray: tsEslint.configs[selectedStylisticRuleSet],
1609
- overrides: {
1610
- files: isTypeAware ? filesTypeAware : files,
1611
- name: `zayne/ts-eslint/${selectedStylisticRuleSet}`
1612
- },
1613
- renameMap: { "@typescript-eslint": "ts-eslint" }
1614
- }) : [],
1626
+ {
1627
+ name: "zayne/ts-eslint/setup/parser",
1628
+ ...makeParser(files)
1629
+ },
1630
+ ...isTypeAware ? [{
1631
+ name: "zayne/ts-eslint/setup/parser-type-aware",
1632
+ ...makeParser(filesTypeAware, ignoresTypeAware)
1633
+ }] : [],
1634
+ {
1635
+ files: isTypeAware ? filesTypeAware : files,
1636
+ name: `zayne/ts-eslint/recommended-${isTypeAware ? "strict-type-checked" : "strict"}`,
1637
+ rules: renameRules(recommendedRules, defaultPluginRenameMap)
1638
+ },
1639
+ ...stylistic$1 ? [{
1640
+ files: isTypeAware ? filesTypeAware : files,
1641
+ name: `zayne/ts-eslint/recommended-${isTypeAware ? "stylistic-type-checked" : "stylistic"}`,
1642
+ rules: renameRules(recommendedStylisticRules, defaultPluginRenameMap)
1643
+ }] : [],
1615
1644
  {
1616
1645
  files: isTypeAware ? filesTypeAware : files,
1617
- name: "zayne/ts-eslint/rules",
1646
+ name: `zayne/ts-eslint/${isTypeAware ? "rules-type-checked" : "rules"}`,
1618
1647
  rules: {
1619
1648
  "ts-eslint/array-type": ["error", { default: "array-simple" }],
1620
1649
  "ts-eslint/consistent-type-definitions": ["error", "type"],
@@ -1646,7 +1675,17 @@ const typescript = async (options = {}) => {
1646
1675
  "ts-eslint/no-use-before-define": "off",
1647
1676
  "ts-eslint/no-useless-constructor": "error",
1648
1677
  "ts-eslint/no-useless-empty-export": "error",
1649
- ...isTypeAware && typeAwareRules,
1678
+ ...isTypeAware && {
1679
+ "ts-eslint/no-unnecessary-type-parameters": "off",
1680
+ "ts-eslint/non-nullable-type-assertion-style": "off",
1681
+ "ts-eslint/prefer-nullish-coalescing": ["error", { ignoreConditionalTests: true }],
1682
+ "ts-eslint/restrict-template-expressions": ["error", {
1683
+ allowBoolean: true,
1684
+ allowNullish: true,
1685
+ allowNumber: true
1686
+ }],
1687
+ "ts-eslint/return-await": ["error", "in-try-catch"]
1688
+ },
1650
1689
  ...overrides
1651
1690
  }
1652
1691
  }
@@ -1729,7 +1768,7 @@ const vue = async (options = {}) => {
1729
1768
  ...typescript$1 && { parser: tsEslint?.parser }
1730
1769
  }
1731
1770
  },
1732
- name: "zayne/vue/setup/file-processor",
1771
+ name: "zayne/vue/setup/parser",
1733
1772
  processor: sfcBlocks === false ? pluginVue.processors[".vue"] : mergeProcessors([pluginVue.processors[".vue"], processorVueBlocks?.({
1734
1773
  ...resolveOptions(sfcBlocks),
1735
1774
  blocks: {
@@ -1854,9 +1893,13 @@ const vue = async (options = {}) => {
1854
1893
  "vue/space-in-parens": ["error", "never"],
1855
1894
  "vue/template-curly-spacing": "error"
1856
1895
  },
1857
- "ts-eslint/no-unused-vars": "off",
1858
1896
  ...overrides
1859
1897
  }
1898
+ },
1899
+ {
1900
+ files,
1901
+ name: "zayne/vue/disables",
1902
+ rules: { "ts-eslint/no-unused-vars": "off" }
1860
1903
  }
1861
1904
  ];
1862
1905
  };
@@ -1921,7 +1964,7 @@ const ReactPackages = ["react", "react-dom"];
1921
1964
  * The merged ESLint configurations.
1922
1965
  */
1923
1966
  const zayne = (options = {}, ...userConfigs) => {
1924
- const { autoRenamePlugins = true, componentExts = [], type = "app", withDefaults = true,...restOfOptions } = options;
1967
+ const { autoRenamePlugins = true, componentExts = [], componentExtsTypeAware = [], type = "app", withDefaults = true,...restOfOptions } = options;
1925
1968
  const enableGitignore = restOfOptions.gitignore ?? true;
1926
1969
  const enableJsx = restOfOptions.jsx ?? true;
1927
1970
  const enableComments = restOfOptions.comments ?? withDefaults;
@@ -1944,10 +1987,17 @@ const zayne = (options = {}, ...userConfigs) => {
1944
1987
  configs.push(ignores(restOfOptions.ignores), javascript(restOfOptions.javascript));
1945
1988
  if (enableGitignore) configs.push(gitIgnores(resolveOptions(enableGitignore)));
1946
1989
  if (enableJsx) configs.push(jsx());
1947
- if (restOfOptions.vue) componentExts.push("vue");
1948
- if (restOfOptions.astro) componentExts.push("astro");
1990
+ if (restOfOptions.vue) {
1991
+ componentExts.push("vue");
1992
+ (resolveOptions(restOfOptions.vue).typescript ?? isTypeAware) && componentExtsTypeAware.push("vue");
1993
+ }
1994
+ if (restOfOptions.astro) {
1995
+ componentExts.push("astro");
1996
+ (resolveOptions(restOfOptions.astro).typescript ?? isTypeAware) && componentExtsTypeAware.push("astro");
1997
+ }
1949
1998
  if (enableTypeScript) configs.push(typescript({
1950
1999
  componentExts,
2000
+ componentExtsTypeAware,
1951
2001
  isTypeAware,
1952
2002
  stylistic: isStylistic,
1953
2003
  ...resolveOptions(enableTypeScript),