acaleph-eslint 1.1.2 → 1.1.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.cjs CHANGED
@@ -12188,14 +12188,14 @@ __export(lib_exports, {
12188
12188
  plugin: () => plugin,
12189
12189
  rules: () => rules
12190
12190
  });
12191
- var import_node_module2, require2, name, version, plugin, recommended, index_default;
12191
+ var import_node_module, require2, name, version, plugin, recommended, index_default;
12192
12192
  var init_lib2 = __esm({
12193
12193
  "node_modules/.pnpm/eslint-plugin-erasable-syntax-only@0.4.0_@typescript-eslint+parser@8.56.1_eslint@9.17.0_21d34576dc676b960edc2b110206cb06/node_modules/eslint-plugin-erasable-syntax-only/lib/index.js"() {
12194
12194
  "use strict";
12195
12195
  init_cjs_shims();
12196
- import_node_module2 = __toESM(require("module"), 1);
12196
+ import_node_module = __toESM(require("module"), 1);
12197
12197
  init_rules();
12198
- require2 = import_node_module2.default.createRequire(importMetaUrl);
12198
+ require2 = import_node_module.default.createRequire(importMetaUrl);
12199
12199
  ({ name, version } = // `import`ing here would bypass the TSConfig's `"rootDir": "src"`
12200
12200
  require2("../package.json"));
12201
12201
  plugin = {
@@ -12347,47 +12347,8 @@ function findUpSync(name2, {
12347
12347
  }
12348
12348
  }
12349
12349
 
12350
- // src/class/local-pkg.ts
12351
- init_cjs_shims();
12352
- var import_node_module = require("module");
12353
- var import_node_path2 = require("path");
12354
- var import_mlly = require("mlly");
12355
- function isPackageExists(name2, options = {}) {
12356
- return !!resolvePackage(name2, options);
12357
- }
12358
- function resolvePackage(name2, options = {}) {
12359
- try {
12360
- return _resolve(`${name2}/package.json`, options);
12361
- } catch {
12362
- }
12363
- try {
12364
- return _resolve(name2, options);
12365
- } catch (e) {
12366
- if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND")
12367
- console.error(e);
12368
- return false;
12369
- }
12370
- }
12371
- function _resolve(path2, options = {}) {
12372
- if (options.platform === "auto" || !options.platform)
12373
- options.platform = process.platform === "win32" ? "win32" : "posix";
12374
- if (process.versions.pnp) {
12375
- const paths = options.paths || [];
12376
- if (paths.length === 0)
12377
- paths.push(process.cwd());
12378
- const targetRequire = (0, import_node_module.createRequire)(importMetaUrl);
12379
- try {
12380
- return targetRequire.resolve(path2, { paths });
12381
- } catch {
12382
- }
12383
- }
12384
- const modulePath = (0, import_mlly.resolvePathSync)(path2, {
12385
- url: options.paths
12386
- });
12387
- if (options.platform === "win32")
12388
- return import_node_path2.win32.normalize(modulePath);
12389
- return modulePath;
12390
- }
12350
+ // src/factory.ts
12351
+ var import_local_pkg3 = require("local-pkg");
12391
12352
 
12392
12353
  // src/configs/index.ts
12393
12354
  init_cjs_shims();
@@ -12843,8 +12804,10 @@ init_cjs_shims();
12843
12804
 
12844
12805
  // src/utils.ts
12845
12806
  init_cjs_shims();
12807
+ var import_node_process2 = __toESM(require("process"), 1);
12846
12808
  var import_node_url2 = require("url");
12847
- var isCwdInScope = isPackageExists("acaleph-eslint");
12809
+ var import_local_pkg = require("local-pkg");
12810
+ var isCwdInScope = (0, import_local_pkg.isPackageExists)("acaleph-eslint");
12848
12811
  var scopeUrl = (0, import_node_url2.fileURLToPath)(new URL(".", importMetaUrl));
12849
12812
  async function interopDefault(m) {
12850
12813
  const resolved = await m;
@@ -12863,10 +12826,10 @@ function renameRules(rules2, map) {
12863
12826
  );
12864
12827
  }
12865
12828
  function isPackageInScope(name2) {
12866
- return isPackageExists(name2, { paths: [scopeUrl] });
12829
+ return (0, import_local_pkg.isPackageExists)(name2, { paths: [scopeUrl] });
12867
12830
  }
12868
12831
  async function ensurePackages(packages) {
12869
- if (process.env.CI || process.stdout.isTTY === false || isCwdInScope === false) {
12832
+ if (import_node_process2.default.env.CI || import_node_process2.default.stdout.isTTY === false || isCwdInScope === false) {
12870
12833
  return;
12871
12834
  }
12872
12835
  const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
@@ -12882,14 +12845,14 @@ async function ensurePackages(packages) {
12882
12845
  }
12883
12846
  }
12884
12847
  function isInEditorEnv() {
12885
- if (process.env.CI)
12848
+ if (import_node_process2.default.env.CI)
12886
12849
  return false;
12887
12850
  if (isInGitHooksOrLintStaged())
12888
12851
  return false;
12889
- return !!(process.env.VSCODE_PID || process.env.VSCODE_CWD || process.env.JETBRAINS_IDE || process.env.VIM || process.env.NVIM || process.env.ZED_ENVIRONMENT);
12852
+ return !!(import_node_process2.default.env.VSCODE_PID || import_node_process2.default.env.VSCODE_CWD || import_node_process2.default.env.JETBRAINS_IDE || import_node_process2.default.env.VIM || import_node_process2.default.env.NVIM || import_node_process2.default.env.ZED_ENVIRONMENT);
12890
12853
  }
12891
12854
  function isInGitHooksOrLintStaged() {
12892
- return !!(process.env.GIT_PARAMS || process.env.VSCODE_GIT_COMMAND || process.env.npm_lifecycle_script?.startsWith("lint-staged"));
12855
+ return !!(import_node_process2.default.env.GIT_PARAMS || import_node_process2.default.env.VSCODE_GIT_COMMAND || import_node_process2.default.env.npm_lifecycle_script?.startsWith("lint-staged"));
12893
12856
  }
12894
12857
 
12895
12858
  // src/configs/jsdoc.ts
@@ -12946,7 +12909,7 @@ async function jsonc(options = {}) {
12946
12909
  const pluginJsonc = await interopDefault(import("eslint-plugin-jsonc"));
12947
12910
  return [
12948
12911
  {
12949
- name: "antfu/jsonc/setup",
12912
+ name: "acaleph/jsonc/setup",
12950
12913
  plugins: {
12951
12914
  jsonc: pluginJsonc
12952
12915
  }
@@ -13013,7 +12976,7 @@ async function jsx(options = {}) {
13013
12976
  }
13014
12977
  }
13015
12978
  },
13016
- name: "antfu/jsx/setup",
12979
+ name: "acaleph/jsx/setup",
13017
12980
  plugins: {},
13018
12981
  rules: {}
13019
12982
  };
@@ -13348,6 +13311,7 @@ async function pnpm(options) {
13348
13311
 
13349
13312
  // src/configs/react.ts
13350
13313
  init_cjs_shims();
13314
+ var import_local_pkg2 = require("local-pkg");
13351
13315
  var ReactRefreshAllowConstantExportPackages = [
13352
13316
  "vite"
13353
13317
  ];
@@ -13366,41 +13330,34 @@ var ReactRouterPackages = [
13366
13330
  var NextJsPackages = [
13367
13331
  "next"
13368
13332
  ];
13369
- var ReactCompilerPackages = [
13370
- "babel-plugin-react-compiler"
13371
- ];
13372
13333
  async function react(options = {}) {
13373
13334
  const {
13374
13335
  files = [GLOB_SRC],
13375
- ignoresTypeAware = [],
13376
13336
  filesTypeAware = [GLOB_TS, GLOB_TSX],
13337
+ ignoresTypeAware = [],
13377
13338
  overrides = {},
13378
- tsconfigPath,
13379
- reactCompiler = ReactCompilerPackages.some((i) => isPackageExists(i))
13339
+ tsconfigPath
13380
13340
  } = options;
13381
13341
  await ensurePackages([
13382
13342
  "@eslint-react/eslint-plugin",
13383
- "eslint-plugin-react-hooks",
13384
13343
  "eslint-plugin-react-refresh"
13385
13344
  ]);
13386
13345
  const isTypeAware = !!tsconfigPath;
13387
13346
  const typeAwareRules = {
13388
- "react/no-leaked-conditional-rendering": "warn",
13389
- "react/no-implicit-key": "error"
13347
+ "react/no-implicit-key": "error",
13348
+ "react/no-leaked-conditional-rendering": "warn"
13390
13349
  };
13391
13350
  const [
13392
13351
  pluginReact,
13393
- pluginReactHooks,
13394
13352
  pluginReactRefresh
13395
13353
  ] = await Promise.all([
13396
13354
  interopDefault(import("@eslint-react/eslint-plugin")),
13397
- interopDefault(import("eslint-plugin-react-hooks")),
13398
13355
  interopDefault(import("eslint-plugin-react-refresh"))
13399
13356
  ]);
13400
- const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists(i));
13401
- const isUsingRemix = RemixPackages.some((i) => isPackageExists(i));
13402
- const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists(i));
13403
- const isUsingNext = NextJsPackages.some((i) => isPackageExists(i));
13357
+ const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
13358
+ const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
13359
+ const isUsingReactRouter = ReactRouterPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
13360
+ const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
13404
13361
  const plugins = pluginReact.configs.all.plugins;
13405
13362
  return [
13406
13363
  {
@@ -13408,8 +13365,6 @@ async function react(options = {}) {
13408
13365
  plugins: {
13409
13366
  "react": plugins["@eslint-react"],
13410
13367
  "react-dom": plugins["@eslint-react/dom"],
13411
- "react-hooks": pluginReactHooks,
13412
- "react-hooks-extra": plugins["@eslint-react/hooks-extra"],
13413
13368
  "react-naming-convention": plugins["@eslint-react/naming-convention"],
13414
13369
  "react-refresh": pluginReactRefresh,
13415
13370
  "react-rsc": plugins["@eslint-react/rsc"],
@@ -13418,7 +13373,6 @@ async function react(options = {}) {
13418
13373
  },
13419
13374
  {
13420
13375
  files,
13421
- name: "acaleph/react/rules",
13422
13376
  languageOptions: {
13423
13377
  parserOptions: {
13424
13378
  ecmaFeatures: {
@@ -13427,96 +13381,9 @@ async function react(options = {}) {
13427
13381
  },
13428
13382
  sourceType: "module"
13429
13383
  },
13384
+ name: "acaleph/react/rules",
13430
13385
  rules: {
13431
- // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
13432
- "react/jsx-key-before-spread": "warn",
13433
- "react/jsx-no-comment-textnodes": "warn",
13434
- "react/jsx-no-duplicate-props": "warn",
13435
- "react/jsx-uses-react": "warn",
13436
- "react/jsx-uses-vars": "warn",
13437
- "react/no-access-state-in-setstate": "error",
13438
- "react/no-array-index-key": "warn",
13439
- "react/no-children-count": "warn",
13440
- "react/no-children-for-each": "warn",
13441
- "react/no-children-map": "warn",
13442
- "react/no-children-only": "warn",
13443
- "react/no-children-to-array": "warn",
13444
- "react/no-clone-element": "warn",
13445
- "react/no-component-will-mount": "error",
13446
- "react/no-component-will-receive-props": "error",
13447
- "react/no-component-will-update": "error",
13448
- "react/no-context-provider": "warn",
13449
- "react/no-create-ref": "error",
13450
- "react/no-default-props": "error",
13451
- "react/no-direct-mutation-state": "error",
13452
- "react/no-forward-ref": "warn",
13453
- "react/no-missing-key": "error",
13454
- "react/no-nested-component-definitions": "error",
13455
- "react/no-nested-lazy-component-declarations": "error",
13456
- "react/no-prop-types": "error",
13457
- "react/no-redundant-should-component-update": "error",
13458
- "react/no-set-state-in-component-did-mount": "warn",
13459
- "react/no-set-state-in-component-did-update": "warn",
13460
- "react/no-set-state-in-component-will-update": "warn",
13461
- "react/no-string-refs": "error",
13462
- "react/no-unnecessary-use-prefix": "warn",
13463
- "react/no-unsafe-component-will-mount": "warn",
13464
- "react/no-unsafe-component-will-receive-props": "warn",
13465
- "react/no-unsafe-component-will-update": "warn",
13466
- "react/no-unused-class-component-members": "warn",
13467
- "react/no-use-context": "warn",
13468
- "react/no-useless-forward-ref": "warn",
13469
- "react/prefer-use-state-lazy-initialization": "warn",
13470
- "react/prefer-namespace-import": "error",
13471
- // recommended rules from eslint-plugin-react-rsc https://eslint-react.xyz/docs/rules/overview#rsc-rules
13472
- "react-rsc/function-definition": "error",
13473
- // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
13474
- "react-dom/no-dangerously-set-innerhtml": "warn",
13475
- "react-dom/no-dangerously-set-innerhtml-with-children": "error",
13476
- "react-dom/no-find-dom-node": "error",
13477
- "react-dom/no-flush-sync": "error",
13478
- "react-dom/no-hydrate": "error",
13479
- "react-dom/no-namespace": "error",
13480
- "react-dom/no-render": "error",
13481
- "react-dom/no-render-return-value": "error",
13482
- "react-dom/no-script-url": "warn",
13483
- "react-dom/no-unsafe-iframe-sandbox": "warn",
13484
- "react-dom/no-use-form-state": "error",
13485
- "react-dom/no-void-elements-with-children": "error",
13486
- // recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
13487
- "react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
13488
- // recommended rules from eslint-plugin-react-naming-convention https://eslint-react.xyz/docs/rules/overview#naming-convention-rules
13489
- "react-naming-convention/context-name": "warn",
13490
- "react-naming-convention/ref-name": "warn",
13491
- "react-naming-convention/use-state": "warn",
13492
- // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
13493
- "react-web-api/no-leaked-event-listener": "warn",
13494
- "react-web-api/no-leaked-interval": "warn",
13495
- "react-web-api/no-leaked-resize-observer": "warn",
13496
- "react-web-api/no-leaked-timeout": "warn",
13497
- // recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
13498
- // Core hooks rules
13499
- "react-hooks/rules-of-hooks": "error",
13500
- "react-hooks/exhaustive-deps": "warn",
13501
- // React Compiler rules
13502
- ...reactCompiler ? {
13503
- "react-hooks/config": "error",
13504
- "react-hooks/error-boundaries": "error",
13505
- "react-hooks/component-hook-factories": "error",
13506
- "react-hooks/gating": "error",
13507
- "react-hooks/globals": "error",
13508
- "react-hooks/immutability": "error",
13509
- "react-hooks/preserve-manual-memoization": "error",
13510
- "react-hooks/purity": "error",
13511
- "react-hooks/refs": "error",
13512
- "react-hooks/set-state-in-effect": "error",
13513
- "react-hooks/set-state-in-render": "error",
13514
- "react-hooks/static-components": "error",
13515
- "react-hooks/unsupported-syntax": "warn",
13516
- "react-hooks/use-memo": "error",
13517
- "react-hooks/incompatible-library": "warn"
13518
- } : {},
13519
- // preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
13386
+ ...pluginReact.configs.recommended.rules,
13520
13387
  "react-refresh/only-export-components": [
13521
13388
  "error",
13522
13389
  {
@@ -13558,6 +13425,70 @@ async function react(options = {}) {
13558
13425
  ]
13559
13426
  }
13560
13427
  ],
13428
+ // recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
13429
+ "react-dom/no-dangerously-set-innerhtml": "warn",
13430
+ "react-dom/no-dangerously-set-innerhtml-with-children": "error",
13431
+ "react-dom/no-find-dom-node": "error",
13432
+ "react-dom/no-flush-sync": "error",
13433
+ "react-dom/no-hydrate": "error",
13434
+ "react-dom/no-namespace": "error",
13435
+ "react-dom/no-render": "error",
13436
+ "react-dom/no-render-return-value": "error",
13437
+ "react-dom/no-script-url": "warn",
13438
+ "react-dom/no-unsafe-iframe-sandbox": "warn",
13439
+ "react-dom/no-use-form-state": "error",
13440
+ "react-dom/no-void-elements-with-children": "error",
13441
+ // recommended rules from eslint-plugin-react-naming-convention https://eslint-react.xyz/docs/rules/overview#naming-convention-rules
13442
+ "react-naming-convention/context-name": "warn",
13443
+ "react-naming-convention/ref-name": "warn",
13444
+ "react-naming-convention/use-state": "warn",
13445
+ // recommended rules from eslint-plugin-react-rsc https://eslint-react.xyz/docs/rules/overview#rsc-rules
13446
+ "react-rsc/function-definition": "error",
13447
+ // recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
13448
+ "react-web-api/no-leaked-event-listener": "warn",
13449
+ "react-web-api/no-leaked-interval": "warn",
13450
+ "react-web-api/no-leaked-resize-observer": "warn",
13451
+ "react-web-api/no-leaked-timeout": "warn",
13452
+ // recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
13453
+ "react/jsx-key-before-spread": "warn",
13454
+ "react/jsx-no-comment-textnodes": "warn",
13455
+ "react/jsx-no-duplicate-props": "warn",
13456
+ "react/jsx-uses-react": "warn",
13457
+ "react/jsx-uses-vars": "warn",
13458
+ "react/no-access-state-in-setstate": "error",
13459
+ "react/no-array-index-key": "warn",
13460
+ "react/no-children-count": "warn",
13461
+ "react/no-children-for-each": "warn",
13462
+ "react/no-children-map": "warn",
13463
+ "react/no-children-only": "warn",
13464
+ "react/no-children-to-array": "warn",
13465
+ "react/no-clone-element": "warn",
13466
+ "react/no-component-will-mount": "error",
13467
+ "react/no-component-will-receive-props": "error",
13468
+ "react/no-component-will-update": "error",
13469
+ "react/no-context-provider": "warn",
13470
+ "react/no-create-ref": "error",
13471
+ "react/no-default-props": "error",
13472
+ "react/no-direct-mutation-state": "error",
13473
+ "react/no-forward-ref": "warn",
13474
+ "react/no-missing-key": "error",
13475
+ "react/no-nested-component-definitions": "error",
13476
+ "react/no-nested-lazy-component-declarations": "error",
13477
+ "react/no-prop-types": "error",
13478
+ "react/no-redundant-should-component-update": "error",
13479
+ "react/no-set-state-in-component-did-mount": "warn",
13480
+ "react/no-set-state-in-component-did-update": "warn",
13481
+ "react/no-set-state-in-component-will-update": "warn",
13482
+ "react/no-string-refs": "error",
13483
+ "react/no-unnecessary-use-prefix": "warn",
13484
+ "react/no-unsafe-component-will-mount": "warn",
13485
+ "react/no-unsafe-component-will-receive-props": "warn",
13486
+ "react/no-unsafe-component-will-update": "warn",
13487
+ "react/no-unused-class-component-members": "warn",
13488
+ "react/no-use-context": "warn",
13489
+ "react/no-useless-forward-ref": "warn",
13490
+ "react/prefer-namespace-import": "error",
13491
+ "react/prefer-use-state-lazy-initialization": "warn",
13561
13492
  ...overrides
13562
13493
  }
13563
13494
  },
@@ -13577,7 +13508,7 @@ async function react(options = {}) {
13577
13508
  ...isTypeAware ? [{
13578
13509
  files: filesTypeAware,
13579
13510
  ignores: ignoresTypeAware,
13580
- name: "antfu/react/type-aware-rules",
13511
+ name: "acaleph/react/type-aware-rules",
13581
13512
  rules: {
13582
13513
  ...typeAwareRules
13583
13514
  }
@@ -14031,7 +13962,7 @@ async function toml(options = {}) {
14031
13962
 
14032
13963
  // src/configs/typescript.ts
14033
13964
  init_cjs_shims();
14034
- var import_node_process2 = __toESM(require("process"), 1);
13965
+ var import_node_process3 = __toESM(require("process"), 1);
14035
13966
  async function typescript(options = {}) {
14036
13967
  const {
14037
13968
  componentExts = [],
@@ -14096,7 +14027,7 @@ async function typescript(options = {}) {
14096
14027
  allowDefaultProject: ["./*.js"],
14097
14028
  defaultProject: tsconfigPath
14098
14029
  },
14099
- tsconfigRootDir: import_node_process2.default.cwd()
14030
+ tsconfigRootDir: import_node_process3.default.cwd()
14100
14031
  } : {},
14101
14032
  ...parserOptions
14102
14033
  }
@@ -14573,9 +14504,9 @@ function acaleph(options = {}, ...userConfigs) {
14573
14504
  pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"),
14574
14505
  react: enableReact = false,
14575
14506
  regexp: enableRegexp = true,
14576
- typescript: enableTypeScript = isPackageExists("typescript"),
14507
+ typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
14577
14508
  unocss: enableUnoCSS = false,
14578
- vue: enableVue = VuePackages.some((i) => isPackageExists(i))
14509
+ vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
14579
14510
  } = options;
14580
14511
  let isInEditor = options.isInEditor;
14581
14512
  if (isInEditor == null) {
@@ -14593,14 +14524,14 @@ function acaleph(options = {}, ...userConfigs) {
14593
14524
  if (typeof enableGitignore !== "boolean") {
14594
14525
  configs2.push(
14595
14526
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
14596
- name: "antfu/gitignore",
14527
+ name: "acaleph/gitignore",
14597
14528
  ...enableGitignore
14598
14529
  })])
14599
14530
  );
14600
14531
  } else {
14601
14532
  configs2.push(
14602
14533
  interopDefault(import("eslint-config-flat-gitignore")).then((r) => [r({
14603
- name: "antfu/gitignore",
14534
+ name: "acaleph/gitignore",
14604
14535
  strict: false
14605
14536
  })])
14606
14537
  );
@@ -14755,7 +14686,7 @@ function acaleph(options = {}, ...userConfigs) {
14755
14686
  disables()
14756
14687
  );
14757
14688
  if ("files" in options) {
14758
- throw new Error('[@antfu/eslint-config] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
14689
+ throw new Error('[acaleph-eslint] The first argument should not contain the "files" property as the options are supposed to be global. Place it in the second or later config instead.');
14759
14690
  }
14760
14691
  const fusedConfig = flatConfigProps.reduce((acc, key) => {
14761
14692
  if (key in options) {