@luxass/eslint-config 7.1.0 → 7.2.1

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.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { FlatConfigComposer } from "eslint-flat-config-utils";
2
2
  import process from "node:process";
3
- import fsPromises from "node:fs/promises";
3
+ import fs from "node:fs/promises";
4
4
  import { fileURLToPath } from "node:url";
5
- import fs from "node:fs";
5
+ import fs$1 from "node:fs";
6
6
  import path from "node:path";
7
7
  import { isPackageExists } from "local-pkg";
8
8
  import createCommand from "eslint-plugin-command/config";
@@ -27,7 +27,7 @@ async function findUp(name, { cwd = process.cwd(), type = "file", stopAt } = {})
27
27
  while (directory) {
28
28
  const filePath = isAbsoluteName ? name : path.join(directory, name);
29
29
  try {
30
- const stats = await fsPromises.stat(filePath);
30
+ const stats = await fs.stat(filePath);
31
31
  if (type === "file" && stats.isFile() || type === "directory" && stats.isDirectory()) return filePath;
32
32
  } catch {}
33
33
  if (directory === stopAt || directory === root) break;
@@ -42,7 +42,7 @@ function findUpSync(name, { cwd = process.cwd(), type = "file", stopAt } = {}) {
42
42
  while (directory) {
43
43
  const filePath = isAbsoluteName ? name : path.join(directory, name);
44
44
  try {
45
- const stats = fs.statSync(filePath, { throwIfNoEntry: false });
45
+ const stats = fs$1.statSync(filePath, { throwIfNoEntry: false });
46
46
  if (type === "file" && stats?.isFile() || type === "directory" && stats?.isDirectory()) return filePath;
47
47
  } catch {}
48
48
  if (directory === stopAt || directory === root) break;
@@ -947,9 +947,11 @@ async function javascript(options = {}) {
947
947
  async function jsdoc(options = {}) {
948
948
  const { overrides, stylistic = true } = options;
949
949
  return [{
950
+ name: "luxass/jsdoc/setup",
951
+ plugins: { jsdoc: await interop(import("eslint-plugin-jsdoc")) }
952
+ }, {
950
953
  files: [GLOB_SRC],
951
954
  name: "luxass/jsdoc/rules",
952
- plugins: { jsdoc: await interop(import("eslint-plugin-jsdoc")) },
953
955
  rules: {
954
956
  "jsdoc/check-access": "warn",
955
957
  "jsdoc/check-param-names": "warn",
@@ -984,13 +986,12 @@ async function jsonc(options = {}) {
984
986
  GLOB_JSONC
985
987
  ], overrides = {}, stylistic = true } = options;
986
988
  const { indent = 2 } = typeof stylistic === "boolean" ? {} : stylistic;
987
- const [pluginJsonc, parserJsonc] = await Promise.all([interop(import("eslint-plugin-jsonc")), interop(import("jsonc-eslint-parser"))]);
988
989
  return [{
989
990
  name: "luxass/jsonc/setup",
990
- plugins: { jsonc: pluginJsonc }
991
+ plugins: { jsonc: await interop(import("eslint-plugin-jsonc")) }
991
992
  }, {
992
993
  files,
993
- languageOptions: { parser: parserJsonc },
994
+ language: "jsonc/x",
994
995
  name: "luxass/jsonc/rules",
995
996
  rules: {
996
997
  "jsonc/no-bigint-literals": "error",
@@ -1055,7 +1056,7 @@ async function jsx() {
1055
1056
  //#endregion
1056
1057
  //#region src/configs/markdown.ts
1057
1058
  async function markdown(options = {}) {
1058
- const { exts = [], files = [GLOB_MARKDOWN], overrides = {} } = options;
1059
+ const { exts = [], files = [GLOB_MARKDOWN], gfm = true, overrides = {}, overridesMarkdown = {} } = options;
1059
1060
  const markdown = await interop(import("@eslint/markdown"));
1060
1061
  return [
1061
1062
  {
@@ -1070,13 +1071,37 @@ async function markdown(options = {}) {
1070
1071
  },
1071
1072
  {
1072
1073
  files,
1073
- languageOptions: { parser: parserPlain },
1074
+ language: gfm ? "markdown/gfm" : "markdown/commonmark",
1074
1075
  name: "luxass/markdown/parser"
1075
1076
  },
1077
+ {
1078
+ files,
1079
+ name: "luxass/markdown/rules",
1080
+ rules: {
1081
+ ...markdown.configs.recommended.at(0)?.rules,
1082
+ "markdown/no-missing-label-refs": "off",
1083
+ ...overridesMarkdown
1084
+ }
1085
+ },
1086
+ {
1087
+ files,
1088
+ name: "luxass/markdown/disables/markdown",
1089
+ rules: {
1090
+ "command/command": "off",
1091
+ "no-irregular-whitespace": "off",
1092
+ "perfectionist/sort-exports": "off",
1093
+ "perfectionist/sort-imports": "off",
1094
+ "regexp/no-legacy-features": "off",
1095
+ "regexp/no-missing-g-flag": "off",
1096
+ "regexp/no-useless-dollar-replacements": "off",
1097
+ "regexp/no-useless-flag": "off",
1098
+ "style/indent": "off"
1099
+ }
1100
+ },
1076
1101
  {
1077
1102
  files: [GLOB_MARKDOWN_CODE, ...exts.map((ext) => `${GLOB_MARKDOWN}/**/*.${ext}`)],
1078
1103
  languageOptions: { parserOptions: { ecmaFeatures: { impliedStrict: true } } },
1079
- name: "luxass/markdown/disables",
1104
+ name: "luxass/markdown/disables/code",
1080
1105
  rules: {
1081
1106
  "antfu/no-top-level-await": "off",
1082
1107
  "no-alert": "off",
@@ -1100,7 +1125,6 @@ async function markdown(options = {}) {
1100
1125
  "ts/no-unused-expressions": "off",
1101
1126
  "ts/no-unused-vars": "off",
1102
1127
  "ts/no-use-before-define": "off",
1103
- "ts/no-var-requires": "off",
1104
1128
  "unicode-bom": "off",
1105
1129
  "unused-imports/no-unused-imports": "off",
1106
1130
  "unused-imports/no-unused-vars": "off",
@@ -1114,9 +1138,11 @@ async function markdown(options = {}) {
1114
1138
  //#region src/configs/node.ts
1115
1139
  function node() {
1116
1140
  return [{
1141
+ name: "luxass/node/setup",
1142
+ plugins: { node: pluginNode }
1143
+ }, {
1117
1144
  files: [GLOB_SRC],
1118
- name: "luxass/node",
1119
- plugins: { node: pluginNode },
1145
+ name: "luxass/node/rules",
1120
1146
  rules: {
1121
1147
  "node/handle-callback-err": ["error", "^(err|error)$"],
1122
1148
  "node/no-deprecated-api": "error",
@@ -1189,21 +1215,20 @@ async function perfectionist() {
1189
1215
  async function detectCatalogUsage() {
1190
1216
  const workspaceFile = await findUp("pnpm-workspace.yaml");
1191
1217
  if (!workspaceFile) return false;
1192
- const yaml = await fsPromises.readFile(workspaceFile, "utf-8");
1218
+ const yaml = await fs.readFile(workspaceFile, "utf-8");
1193
1219
  return yaml.includes("catalog:") || yaml.includes("catalogs:");
1194
1220
  }
1195
1221
  async function pnpm(options) {
1196
- const [pluginPnpm, pluginYaml, yamlParser, jsoncParser] = await Promise.all([
1222
+ const [pluginPnpm, pluginYaml, yamlParser] = await Promise.all([
1197
1223
  interop(import("eslint-plugin-pnpm")),
1198
1224
  interop(import("eslint-plugin-yml")),
1199
- interop(import("yaml-eslint-parser")),
1200
- interop(import("jsonc-eslint-parser"))
1225
+ interop(import("yaml-eslint-parser"))
1201
1226
  ]);
1202
1227
  const { catalogs = await detectCatalogUsage(), isInEditor = false, json = true, sort = true, yaml = true } = options;
1203
1228
  const configs = [];
1204
1229
  if (json) configs.push({
1205
1230
  files: ["package.json", "**/package.json"],
1206
- languageOptions: { parser: jsoncParser },
1231
+ language: "jsonc/x",
1207
1232
  name: "luxass/pnpm/package-json",
1208
1233
  plugins: { pnpm: pluginPnpm },
1209
1234
  rules: {
@@ -1327,6 +1352,7 @@ const ReactRouterPackages = [
1327
1352
  "@react-router/serve",
1328
1353
  "@react-router/dev"
1329
1354
  ];
1355
+ const TanstackRouterPackages = ["@tanstack/react-router"];
1330
1356
  const NextJsPackages = ["next"];
1331
1357
  const ReactCompilerPackages = ["babel-plugin-react-compiler"];
1332
1358
  async function react(options = {}) {
@@ -1352,6 +1378,7 @@ async function react(options = {}) {
1352
1378
  const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
1353
1379
  const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
1354
1380
  const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
1381
+ const isUsingTanstackRouter = TanstackRouterPackages.some((i) => isPackageExists(i));
1355
1382
  const plugins = pluginReact.configs.all.plugins;
1356
1383
  return [
1357
1384
  {
@@ -1481,6 +1508,15 @@ async function react(options = {}) {
1481
1508
  "clientAction",
1482
1509
  "handle",
1483
1510
  "shouldRevalidate"
1511
+ ] : []],
1512
+ extraHOCs: [...isUsingTanstackRouter ? [
1513
+ "createFileRoute",
1514
+ "createLazyFileRoute",
1515
+ "createRootRoute",
1516
+ "createRootRouteWithContext",
1517
+ "createLink",
1518
+ "createRoute",
1519
+ "createLazyRoute"
1484
1520
  ] : []]
1485
1521
  }],
1486
1522
  ...overrides
@@ -1987,7 +2023,7 @@ async function typescript(options = {}) {
1987
2023
  }] : [],
1988
2024
  ...erasableOnly ? [{
1989
2025
  name: "luxas/typescript/erasable-syntax-only",
1990
- plugins: { "erasable-syntax-only": await interop(import("./lib-BgGy3QDX.mjs")) },
2026
+ plugins: { "erasable-syntax-only": await interop(import("./lib-DRpFEws2.mjs")) },
1991
2027
  rules: {
1992
2028
  "erasable-syntax-only/enums": "error",
1993
2029
  "erasable-syntax-only/import-aliases": "error",