@zayne-labs/eslint-config 0.9.1 → 0.9.2

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
@@ -191,6 +191,7 @@ const resolveOptions = (option) => isObject(option) ? option : {};
191
191
  //#region src/configs/astro.ts
192
192
  const astro = async (options = {}) => {
193
193
  const { files = [GLOB_ASTRO], overrides, typescript: typescript$1 = true } = options;
194
+ await ensurePackages(["eslint-plugin-astro", "astro-eslint-parser"]);
194
195
  const [pluginAstro, parserAstro] = await Promise.all([interopDefault(import("eslint-plugin-astro")), interopDefault(import("astro-eslint-parser"))]);
195
196
  return [
196
197
  {
@@ -747,7 +748,7 @@ const jsonc = async (options = {}) => {
747
748
  //#region src/configs/node.ts
748
749
  const node = async (options = {}) => {
749
750
  const { overrides, security = false, type = "app" } = options;
750
- const [eslintPluginNode, eslintPluginSecurity] = await Promise.all([interopDefault(import("eslint-plugin-n")), ...security ? [interopDefault(import("eslint-plugin-security"))] : []]);
751
+ const [eslintPluginNode, eslintPluginSecurity] = await Promise.all([interopDefault(import("eslint-plugin-n")), security ? interopDefault(import("eslint-plugin-security")) : void 0]);
751
752
  const config = [{
752
753
  name: "zayne/node/recommended",
753
754
  plugins: { node: eslintPluginNode },
@@ -908,7 +909,9 @@ const defaultPluginRenameMap = defineEnum({
908
909
  "@next/next": "nextjs-next",
909
910
  "@stylistic": "stylistic",
910
911
  "@tanstack/query": "tanstack-query",
912
+ "@tanstack/router": "tanstack-router",
911
913
  "@typescript-eslint": "ts-eslint",
914
+ "better-tailwindcss": "tailwindcss-better",
912
915
  "import-x": "import",
913
916
  n: "node"
914
917
  });
@@ -931,15 +934,15 @@ const react = async (options = {}) => {
931
934
  await ensurePackages([
932
935
  "@eslint-react/eslint-plugin",
933
936
  "eslint-plugin-react-hooks",
934
- ...refresh ? ["eslint-plugin-react-refresh"] : [],
935
- ...nextjs ? ["@next/eslint-plugin-next"] : []
937
+ refresh ? "eslint-plugin-react-refresh" : void 0,
938
+ nextjs ? "@next/eslint-plugin-next" : void 0
936
939
  ]);
937
- const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh] = await Promise.all([
940
+ const [eslintPluginReact, eslintReactHooks, eslintPluginReactRefresh, eslintPluginNextjs] = await Promise.all([
938
941
  interopDefault(import("@eslint-react/eslint-plugin")),
939
942
  interopDefault(import("eslint-plugin-react-hooks")),
940
- ...refresh ? [interopDefault(import("eslint-plugin-react-refresh"))] : []
943
+ refresh ? interopDefault(import("eslint-plugin-react-refresh")) : void 0,
944
+ nextjs ? interopDefault(import("@next/eslint-plugin-next")) : void 0
941
945
  ]);
942
- const eslintPluginNextjs = nextjs && await interopDefault(import("@next/eslint-plugin-next"));
943
946
  const recommendedReactConfig = eslintPluginReact.configs[typescript$1 ? "recommended-type-checked" : "recommended"];
944
947
  const config = [
945
948
  {
@@ -968,9 +971,9 @@ const react = async (options = {}) => {
968
971
  files,
969
972
  name: "zayne/react/rules",
970
973
  rules: {
971
- "react-hooks-extra/ensure-custom-hooks-using-other-hooks": "error",
972
974
  "react-hooks-extra/no-unnecessary-use-callback": "warn",
973
975
  "react-hooks-extra/no-unnecessary-use-memo": "warn",
976
+ "react-hooks-extra/no-unnecessary-use-prefix": "error",
974
977
  "react-hooks-extra/prefer-use-state-lazy-initialization": "error",
975
978
  "react-hooks/exhaustive-deps": "warn",
976
979
  "react-hooks/rules-of-hooks": "error",
@@ -1031,14 +1034,10 @@ const react = async (options = {}) => {
1031
1034
  files,
1032
1035
  name: "zayne/react/nextjs",
1033
1036
  plugins: { "nextjs-next": fixupPluginRules(eslintPluginNextjs) },
1034
- rules: renameRules(
1035
- // eslint-disable-next-line ts-eslint/no-unsafe-argument -- missing types
1036
- {
1037
- ...eslintPluginNextjs.configs?.recommended?.rules,
1038
- ...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules
1039
- },
1040
- defaultPluginRenameMap
1041
- )
1037
+ rules: renameRules({
1038
+ ...eslintPluginNextjs.configs?.recommended?.rules,
1039
+ ...eslintPluginNextjs.configs?.["core-web-vitals"]?.rules
1040
+ }, defaultPluginRenameMap)
1042
1041
  });
1043
1042
  return config;
1044
1043
  };
@@ -1327,55 +1326,61 @@ const stylistic = async (options = {}) => {
1327
1326
 
1328
1327
  //#endregion
1329
1328
  //#region src/configs/tailwindcss.ts
1330
- const tailwindcss = async (options = {}) => {
1331
- const { overrides, settings: tailwindCssSettings } = options;
1332
- await ensurePackages(["eslint-plugin-tailwindcss"]);
1333
- const eslintPluginTailwindCss = await interopDefault(import("eslint-plugin-tailwindcss"));
1329
+ const tailwindcssBetter = async (options = {}) => {
1330
+ const { overrides, settings: tailwindCssBetterSettings } = options;
1331
+ await ensurePackages(["eslint-plugin-better-tailwindcss"]);
1332
+ const [eslintPluginBetterTailwindCss, defaults] = await Promise.all([interopDefault(import("eslint-plugin-better-tailwindcss")), interopDefault(import("eslint-plugin-better-tailwindcss/api/defaults"))]);
1334
1333
  return [
1335
1334
  {
1336
- name: "zayne/tailwindcss/setup",
1337
- plugins: { tailwindcss: eslintPluginTailwindCss },
1338
- settings: { tailwindcss: {
1335
+ name: "zayne/tailwindcss-better/setup",
1336
+ plugins: { "tailwindcss-better": eslintPluginBetterTailwindCss },
1337
+ settings: { "better-tailwindcss": {
1338
+ ...tailwindCssBetterSettings,
1339
+ attributes: [
1340
+ ...defaults.getDefaultAttributes(),
1341
+ "^class(Name|Names)?$",
1342
+ tailwindCssBetterSettings?.attributes
1343
+ ],
1339
1344
  callees: [
1340
- "tv",
1345
+ ...defaults.getDefaultCallees(),
1341
1346
  "cnMerge",
1342
- "cn",
1343
1347
  "cnJoin",
1344
- "twMerge",
1345
- "twJoin"
1348
+ tailwindCssBetterSettings?.callees
1346
1349
  ],
1347
- classRegex: "^class(Name|Names)?$",
1348
- cssFiles: [],
1349
- removeDuplicates: false,
1350
- ...tailwindCssSettings
1350
+ entryPoint: tailwindCssBetterSettings?.entryPoint ?? `${process.cwd()}/tailwind.css`
1351
1351
  } }
1352
1352
  },
1353
1353
  {
1354
- name: "zayne/tailwindcss/recommended",
1355
- rules: eslintPluginTailwindCss.configs["flat/recommended"][1]?.rules
1354
+ name: "zayne/tailwindcss-better/recommended",
1355
+ rules: renameRules(eslintPluginBetterTailwindCss.configs.recommended?.rules, defaultPluginRenameMap)
1356
1356
  },
1357
1357
  {
1358
- name: "zayne/tailwindcss/rules",
1358
+ name: "zayne/tailwindcss-better/rules",
1359
1359
  rules: {
1360
- "tailwindcss/no-contradicting-classname": "off",
1361
- "tailwindcss/no-custom-classname": ["warn", { ignoredKeys: [
1362
- "compoundVariants",
1363
- "defaultVariants",
1364
- "responsiveVariants"
1365
- ] }],
1360
+ "tailwindcss-better/enforce-consistent-variable-syntax": ["warn", { syntax: "parentheses" }],
1361
+ "tailwindcss-better/multiline": ["off", {
1362
+ indent: 3,
1363
+ printWidth: 107
1364
+ }],
1365
+ "tailwindcss-better/no-conflicting-classes": "warn",
1366
+ "tailwindcss-better/no-unregistered-classes": "warn",
1366
1367
  ...overrides
1367
1368
  }
1368
1369
  }
1369
1370
  ];
1370
1371
  };
1372
+ /**
1373
+ * @description tailwindcss v4 is not supported yet
1374
+ * @deprecated until eslint-plugin-tailwindcss supports tailwindcss v4
1375
+ */
1371
1376
 
1372
1377
  //#endregion
1373
1378
  //#region src/configs/tanstack.ts
1374
1379
  const tanstack = async (options = {}) => {
1375
- const { overrides, query = true } = options;
1380
+ const { overrides, query = true, router } = options;
1376
1381
  const config = [];
1377
- await ensurePackages([...query ? ["@tanstack/eslint-plugin-query"] : []]);
1378
- const [eslintPluginTanstackQuery] = await Promise.all(query ? [interopDefault(import("@tanstack/eslint-plugin-query"))] : []);
1382
+ await ensurePackages([query ? "@tanstack/eslint-plugin-query" : void 0, router ? "@tanstack/eslint-plugin-router" : void 0]);
1383
+ const [eslintPluginTanstackQuery, eslintPluginTanstackRouter] = await Promise.all([query ? interopDefault(import("@tanstack/eslint-plugin-query")) : void 0, router ? interopDefault(import("@tanstack/eslint-plugin-router")) : void 0]);
1379
1384
  if (query && eslintPluginTanstackQuery) config.push({
1380
1385
  name: "zayne/tanstack-query/recommended",
1381
1386
  plugins: { "tanstack-query": eslintPluginTanstackQuery },
@@ -1384,6 +1389,14 @@ const tanstack = async (options = {}) => {
1384
1389
  name: "zayne/tanstack-query/rules",
1385
1390
  rules: { ...overrides }
1386
1391
  });
1392
+ if (router && eslintPluginTanstackRouter) config.push({
1393
+ name: "zayne/tanstack-router/recommended",
1394
+ plugins: { "tanstack-router": eslintPluginTanstackRouter },
1395
+ rules: renameRules(eslintPluginTanstackRouter.configs["flat/recommended"][0]?.rules, defaultPluginRenameMap)
1396
+ }, {
1397
+ name: "zayne/tanstack-router/rules",
1398
+ rules: { ...overrides }
1399
+ });
1387
1400
  return config;
1388
1401
  };
1389
1402
 
@@ -1465,7 +1478,7 @@ const typescript = async (options = {}) => {
1465
1478
  }
1466
1479
  });
1467
1480
  const selectedBaseRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1468
- const selectedStylisticRuleSet = isTypeAware ? "strictTypeChecked" : "strict";
1481
+ const selectedStylisticRuleSet = isTypeAware ? "stylisticTypeChecked" : "stylistic";
1469
1482
  const typeAwareRules = {
1470
1483
  "ts-eslint/no-unnecessary-type-parameters": "off",
1471
1484
  "ts-eslint/non-nullable-type-assertion-style": "off",
@@ -1516,6 +1529,7 @@ const typescript = async (options = {}) => {
1516
1529
  ] }],
1517
1530
  "ts-eslint/no-import-type-side-effects": "error",
1518
1531
  "ts-eslint/no-shadow": "error",
1532
+ "ts-eslint/no-unnecessary-type-conversion": "error",
1519
1533
  "ts-eslint/no-unused-expressions": ["error", {
1520
1534
  allowShortCircuit: true,
1521
1535
  allowTernary: true
@@ -1531,6 +1545,7 @@ const typescript = async (options = {}) => {
1531
1545
  }],
1532
1546
  "ts-eslint/no-use-before-define": "off",
1533
1547
  "ts-eslint/no-useless-constructor": "error",
1548
+ "ts-eslint/no-useless-empty-export": "error",
1534
1549
  ...overrides
1535
1550
  }
1536
1551
  },
@@ -1583,12 +1598,12 @@ const vue = async (options = {}) => {
1583
1598
  await ensurePackages([
1584
1599
  "eslint-plugin-vue",
1585
1600
  "vue-eslint-parser",
1586
- ...sfcBlocks ? ["eslint-processor-vue-blocks"] : []
1601
+ sfcBlocks ? "eslint-processor-vue-blocks" : void 0
1587
1602
  ]);
1588
1603
  const [pluginVue, parserVue, processorVueBlocks] = await Promise.all([
1589
1604
  interopDefault(import("eslint-plugin-vue")),
1590
1605
  interopDefault(import("vue-eslint-parser")),
1591
- ...sfcBlocks ? [interopDefault(import("eslint-processor-vue-blocks"))] : []
1606
+ sfcBlocks ? interopDefault(import("eslint-processor-vue-blocks")) : void 0
1592
1607
  ]);
1593
1608
  return [
1594
1609
  {
@@ -1900,7 +1915,7 @@ const zayne = (options = {}, ...userConfigs) => {
1900
1915
  typescript: isTypeAware,
1901
1916
  ...resolveOptions(restOfOptions.astro)
1902
1917
  }));
1903
- if (restOfOptions.tailwindcss) configs.push(tailwindcss(resolveOptions(restOfOptions.tailwindcss)));
1918
+ if (restOfOptions.tailwindcssBetter) configs.push(tailwindcssBetter(resolveOptions(restOfOptions.tailwindcssBetter)));
1904
1919
  if (restOfOptions.tanstack) configs.push(tanstack(resolveOptions(restOfOptions.tanstack)));
1905
1920
  if (restOfOptions.depend) configs.push(depend(resolveOptions(restOfOptions.depend)));
1906
1921
  assert(!("files" in restOfOptions), `[@zayne-labs/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second config array instead.`);
@@ -1911,5 +1926,5 @@ const zayne = (options = {}, ...userConfigs) => {
1911
1926
  };
1912
1927
 
1913
1928
  //#endregion
1914
- export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, astro, combine, comments, depend, ensurePackages, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, node, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcss, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
1929
+ export { GLOB_ALL_SRC, GLOB_ASTRO, GLOB_ASTRO_TS, GLOB_CSS, GLOB_EXCLUDE, GLOB_GRAPHQL, GLOB_HTML, GLOB_JS, GLOB_JSON, GLOB_JSON5, GLOB_JSONC, GLOB_JSX, GLOB_LESS, GLOB_MARKDOWN, GLOB_MARKDOWN_CODE, GLOB_MARKDOWN_IN_MARKDOWN, GLOB_POSTCSS, GLOB_SCSS, GLOB_SRC, GLOB_SRC_EXT, GLOB_STYLES, GLOB_SVELTE, GLOB_SVG, GLOB_TESTS, GLOB_TOML, GLOB_TS, GLOB_TSX, GLOB_VUE, GLOB_XML, GLOB_YAML, astro, combine, comments, depend, ensurePackages, gitIgnores, ignores, imports, interopDefault, isObject, isPackageInScope, javascript, jsdoc, jsonc, node, perfectionist, pnpm, react, renamePluginInConfigs, renamePlugins, renameRules, resolveOptions, solid, sortPackageJson, sortTsconfig, stylistic, tailwindcssBetter, tanstack, toml, typescript, unicorn, vue, yaml, zayne };
1915
1930
  //# sourceMappingURL=index.js.map