acaleph-eslint 1.1.2 → 1.1.3
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 +62 -98
- package/dist/index.js +58 -94
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -12188,14 +12188,14 @@ __export(lib_exports, {
|
|
|
12188
12188
|
plugin: () => plugin,
|
|
12189
12189
|
rules: () => rules
|
|
12190
12190
|
});
|
|
12191
|
-
var
|
|
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
|
-
|
|
12196
|
+
import_node_module = __toESM(require("module"), 1);
|
|
12197
12197
|
init_rules();
|
|
12198
|
-
require2 =
|
|
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/
|
|
12351
|
-
|
|
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
|
|
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 (
|
|
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 (
|
|
12848
|
+
if (import_node_process2.default.env.CI)
|
|
12886
12849
|
return false;
|
|
12887
12850
|
if (isInGitHooksOrLintStaged())
|
|
12888
12851
|
return false;
|
|
12889
|
-
return !!(
|
|
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 !!(
|
|
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
|
|
@@ -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
|
];
|
|
@@ -13372,11 +13336,11 @@ var ReactCompilerPackages = [
|
|
|
13372
13336
|
async function react(options = {}) {
|
|
13373
13337
|
const {
|
|
13374
13338
|
files = [GLOB_SRC],
|
|
13375
|
-
ignoresTypeAware = [],
|
|
13376
13339
|
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
13340
|
+
ignoresTypeAware = [],
|
|
13377
13341
|
overrides = {},
|
|
13378
|
-
|
|
13379
|
-
|
|
13342
|
+
reactCompiler = ReactCompilerPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i)),
|
|
13343
|
+
tsconfigPath
|
|
13380
13344
|
} = options;
|
|
13381
13345
|
await ensurePackages([
|
|
13382
13346
|
"@eslint-react/eslint-plugin",
|
|
@@ -13385,8 +13349,8 @@ async function react(options = {}) {
|
|
|
13385
13349
|
]);
|
|
13386
13350
|
const isTypeAware = !!tsconfigPath;
|
|
13387
13351
|
const typeAwareRules = {
|
|
13388
|
-
"react/no-
|
|
13389
|
-
"react/no-
|
|
13352
|
+
"react/no-implicit-key": "error",
|
|
13353
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
13390
13354
|
};
|
|
13391
13355
|
const [
|
|
13392
13356
|
pluginReact,
|
|
@@ -13397,10 +13361,10 @@ async function react(options = {}) {
|
|
|
13397
13361
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
13398
13362
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
13399
13363
|
]);
|
|
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));
|
|
13364
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
13365
|
+
const isUsingRemix = RemixPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
13366
|
+
const isUsingReactRouter = ReactRouterPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
13367
|
+
const isUsingNext = NextJsPackages.some((i) => (0, import_local_pkg2.isPackageExists)(i));
|
|
13404
13368
|
const plugins = pluginReact.configs.all.plugins;
|
|
13405
13369
|
return [
|
|
13406
13370
|
{
|
|
@@ -13418,7 +13382,6 @@ async function react(options = {}) {
|
|
|
13418
13382
|
},
|
|
13419
13383
|
{
|
|
13420
13384
|
files,
|
|
13421
|
-
name: "acaleph/react/rules",
|
|
13422
13385
|
languageOptions: {
|
|
13423
13386
|
parserOptions: {
|
|
13424
13387
|
ecmaFeatures: {
|
|
@@ -13427,7 +13390,38 @@ async function react(options = {}) {
|
|
|
13427
13390
|
},
|
|
13428
13391
|
sourceType: "module"
|
|
13429
13392
|
},
|
|
13393
|
+
name: "acaleph/react/rules",
|
|
13430
13394
|
rules: {
|
|
13395
|
+
// recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
|
|
13396
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
13397
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
13398
|
+
"react-dom/no-find-dom-node": "error",
|
|
13399
|
+
"react-dom/no-flush-sync": "error",
|
|
13400
|
+
"react-dom/no-hydrate": "error",
|
|
13401
|
+
"react-dom/no-namespace": "error",
|
|
13402
|
+
"react-dom/no-render": "error",
|
|
13403
|
+
"react-dom/no-render-return-value": "error",
|
|
13404
|
+
"react-dom/no-script-url": "warn",
|
|
13405
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
13406
|
+
"react-dom/no-use-form-state": "error",
|
|
13407
|
+
"react-dom/no-void-elements-with-children": "error",
|
|
13408
|
+
// recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
|
|
13409
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
13410
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
13411
|
+
// recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
|
|
13412
|
+
// Core hooks rules
|
|
13413
|
+
"react-hooks/rules-of-hooks": "error",
|
|
13414
|
+
// recommended rules from eslint-plugin-react-naming-convention https://eslint-react.xyz/docs/rules/overview#naming-convention-rules
|
|
13415
|
+
"react-naming-convention/context-name": "warn",
|
|
13416
|
+
"react-naming-convention/ref-name": "warn",
|
|
13417
|
+
"react-naming-convention/use-state": "warn",
|
|
13418
|
+
// recommended rules from eslint-plugin-react-rsc https://eslint-react.xyz/docs/rules/overview#rsc-rules
|
|
13419
|
+
"react-rsc/function-definition": "error",
|
|
13420
|
+
// recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
|
|
13421
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
13422
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
13423
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
13424
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
13431
13425
|
// recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
|
|
13432
13426
|
"react/jsx-key-before-spread": "warn",
|
|
13433
13427
|
"react/jsx-no-comment-textnodes": "warn",
|
|
@@ -13466,46 +13460,17 @@ async function react(options = {}) {
|
|
|
13466
13460
|
"react/no-unused-class-component-members": "warn",
|
|
13467
13461
|
"react/no-use-context": "warn",
|
|
13468
13462
|
"react/no-useless-forward-ref": "warn",
|
|
13469
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
13470
13463
|
"react/prefer-namespace-import": "error",
|
|
13471
|
-
|
|
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",
|
|
13464
|
+
"react/prefer-use-state-lazy-initialization": "warn",
|
|
13501
13465
|
// React Compiler rules
|
|
13502
13466
|
...reactCompiler ? {
|
|
13467
|
+
"react-hooks/component-hook-factories": "error",
|
|
13503
13468
|
"react-hooks/config": "error",
|
|
13504
13469
|
"react-hooks/error-boundaries": "error",
|
|
13505
|
-
"react-hooks/component-hook-factories": "error",
|
|
13506
13470
|
"react-hooks/gating": "error",
|
|
13507
13471
|
"react-hooks/globals": "error",
|
|
13508
13472
|
"react-hooks/immutability": "error",
|
|
13473
|
+
"react-hooks/incompatible-library": "warn",
|
|
13509
13474
|
"react-hooks/preserve-manual-memoization": "error",
|
|
13510
13475
|
"react-hooks/purity": "error",
|
|
13511
13476
|
"react-hooks/refs": "error",
|
|
@@ -13513,8 +13478,7 @@ async function react(options = {}) {
|
|
|
13513
13478
|
"react-hooks/set-state-in-render": "error",
|
|
13514
13479
|
"react-hooks/static-components": "error",
|
|
13515
13480
|
"react-hooks/unsupported-syntax": "warn",
|
|
13516
|
-
"react-hooks/use-memo": "error"
|
|
13517
|
-
"react-hooks/incompatible-library": "warn"
|
|
13481
|
+
"react-hooks/use-memo": "error"
|
|
13518
13482
|
} : {},
|
|
13519
13483
|
// preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
|
|
13520
13484
|
"react-refresh/only-export-components": [
|
|
@@ -14031,7 +13995,7 @@ async function toml(options = {}) {
|
|
|
14031
13995
|
|
|
14032
13996
|
// src/configs/typescript.ts
|
|
14033
13997
|
init_cjs_shims();
|
|
14034
|
-
var
|
|
13998
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
14035
13999
|
async function typescript(options = {}) {
|
|
14036
14000
|
const {
|
|
14037
14001
|
componentExts = [],
|
|
@@ -14096,7 +14060,7 @@ async function typescript(options = {}) {
|
|
|
14096
14060
|
allowDefaultProject: ["./*.js"],
|
|
14097
14061
|
defaultProject: tsconfigPath
|
|
14098
14062
|
},
|
|
14099
|
-
tsconfigRootDir:
|
|
14063
|
+
tsconfigRootDir: import_node_process3.default.cwd()
|
|
14100
14064
|
} : {},
|
|
14101
14065
|
...parserOptions
|
|
14102
14066
|
}
|
|
@@ -14573,9 +14537,9 @@ function acaleph(options = {}, ...userConfigs) {
|
|
|
14573
14537
|
pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"),
|
|
14574
14538
|
react: enableReact = false,
|
|
14575
14539
|
regexp: enableRegexp = true,
|
|
14576
|
-
typescript: enableTypeScript = isPackageExists("typescript"),
|
|
14540
|
+
typescript: enableTypeScript = (0, import_local_pkg3.isPackageExists)("typescript"),
|
|
14577
14541
|
unocss: enableUnoCSS = false,
|
|
14578
|
-
vue: enableVue = VuePackages.some((i) => isPackageExists(i))
|
|
14542
|
+
vue: enableVue = VuePackages.some((i) => (0, import_local_pkg3.isPackageExists)(i))
|
|
14579
14543
|
} = options;
|
|
14580
14544
|
let isInEditor = options.isInEditor;
|
|
14581
14545
|
if (isInEditor == null) {
|
package/dist/index.js
CHANGED
|
@@ -11,14 +11,14 @@ import { FlatConfigComposer } from "eslint-flat-config-utils";
|
|
|
11
11
|
|
|
12
12
|
// node_modules/.pnpm/find-up-simple@1.0.1/node_modules/find-up-simple/index.js
|
|
13
13
|
init_esm_shims();
|
|
14
|
-
import
|
|
14
|
+
import process from "process";
|
|
15
15
|
import fsPromises from "fs/promises";
|
|
16
16
|
import { fileURLToPath } from "url";
|
|
17
17
|
import fs from "fs";
|
|
18
18
|
import path from "path";
|
|
19
19
|
var toPath = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
|
20
20
|
async function findUp(name, {
|
|
21
|
-
cwd =
|
|
21
|
+
cwd = process.cwd(),
|
|
22
22
|
type = "file",
|
|
23
23
|
stopAt
|
|
24
24
|
} = {}) {
|
|
@@ -42,7 +42,7 @@ async function findUp(name, {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function findUpSync(name, {
|
|
45
|
-
cwd =
|
|
45
|
+
cwd = process.cwd(),
|
|
46
46
|
type = "file",
|
|
47
47
|
stopAt
|
|
48
48
|
} = {}) {
|
|
@@ -66,47 +66,8 @@ function findUpSync(name, {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// src/
|
|
70
|
-
|
|
71
|
-
import { createRequire } from "module";
|
|
72
|
-
import { win32 } from "path";
|
|
73
|
-
import { resolvePathSync } from "mlly";
|
|
74
|
-
function isPackageExists(name, options = {}) {
|
|
75
|
-
return !!resolvePackage(name, options);
|
|
76
|
-
}
|
|
77
|
-
function resolvePackage(name, options = {}) {
|
|
78
|
-
try {
|
|
79
|
-
return _resolve(`${name}/package.json`, options);
|
|
80
|
-
} catch {
|
|
81
|
-
}
|
|
82
|
-
try {
|
|
83
|
-
return _resolve(name, options);
|
|
84
|
-
} catch (e) {
|
|
85
|
-
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND")
|
|
86
|
-
console.error(e);
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function _resolve(path2, options = {}) {
|
|
91
|
-
if (options.platform === "auto" || !options.platform)
|
|
92
|
-
options.platform = process.platform === "win32" ? "win32" : "posix";
|
|
93
|
-
if (process.versions.pnp) {
|
|
94
|
-
const paths = options.paths || [];
|
|
95
|
-
if (paths.length === 0)
|
|
96
|
-
paths.push(process.cwd());
|
|
97
|
-
const targetRequire = createRequire(import.meta.url);
|
|
98
|
-
try {
|
|
99
|
-
return targetRequire.resolve(path2, { paths });
|
|
100
|
-
} catch {
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const modulePath = resolvePathSync(path2, {
|
|
104
|
-
url: options.paths
|
|
105
|
-
});
|
|
106
|
-
if (options.platform === "win32")
|
|
107
|
-
return win32.normalize(modulePath);
|
|
108
|
-
return modulePath;
|
|
109
|
-
}
|
|
69
|
+
// src/factory.ts
|
|
70
|
+
import { isPackageExists as isPackageExists3 } from "local-pkg";
|
|
110
71
|
|
|
111
72
|
// src/configs/index.ts
|
|
112
73
|
init_esm_shims();
|
|
@@ -562,7 +523,9 @@ init_esm_shims();
|
|
|
562
523
|
|
|
563
524
|
// src/utils.ts
|
|
564
525
|
init_esm_shims();
|
|
526
|
+
import process2 from "process";
|
|
565
527
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
528
|
+
import { isPackageExists } from "local-pkg";
|
|
566
529
|
var isCwdInScope = isPackageExists("acaleph-eslint");
|
|
567
530
|
var scopeUrl = fileURLToPath2(new URL(".", import.meta.url));
|
|
568
531
|
async function interopDefault(m) {
|
|
@@ -585,7 +548,7 @@ function isPackageInScope(name) {
|
|
|
585
548
|
return isPackageExists(name, { paths: [scopeUrl] });
|
|
586
549
|
}
|
|
587
550
|
async function ensurePackages(packages) {
|
|
588
|
-
if (
|
|
551
|
+
if (process2.env.CI || process2.stdout.isTTY === false || isCwdInScope === false) {
|
|
589
552
|
return;
|
|
590
553
|
}
|
|
591
554
|
const nonExistingPackages = packages.filter((i) => i && !isPackageInScope(i));
|
|
@@ -601,14 +564,14 @@ async function ensurePackages(packages) {
|
|
|
601
564
|
}
|
|
602
565
|
}
|
|
603
566
|
function isInEditorEnv() {
|
|
604
|
-
if (
|
|
567
|
+
if (process2.env.CI)
|
|
605
568
|
return false;
|
|
606
569
|
if (isInGitHooksOrLintStaged())
|
|
607
570
|
return false;
|
|
608
|
-
return !!(
|
|
571
|
+
return !!(process2.env.VSCODE_PID || process2.env.VSCODE_CWD || process2.env.JETBRAINS_IDE || process2.env.VIM || process2.env.NVIM || process2.env.ZED_ENVIRONMENT);
|
|
609
572
|
}
|
|
610
573
|
function isInGitHooksOrLintStaged() {
|
|
611
|
-
return !!(
|
|
574
|
+
return !!(process2.env.GIT_PARAMS || process2.env.VSCODE_GIT_COMMAND || process2.env.npm_lifecycle_script?.startsWith("lint-staged"));
|
|
612
575
|
}
|
|
613
576
|
|
|
614
577
|
// src/configs/jsdoc.ts
|
|
@@ -1067,6 +1030,7 @@ async function pnpm(options) {
|
|
|
1067
1030
|
|
|
1068
1031
|
// src/configs/react.ts
|
|
1069
1032
|
init_esm_shims();
|
|
1033
|
+
import { isPackageExists as isPackageExists2 } from "local-pkg";
|
|
1070
1034
|
var ReactRefreshAllowConstantExportPackages = [
|
|
1071
1035
|
"vite"
|
|
1072
1036
|
];
|
|
@@ -1091,11 +1055,11 @@ var ReactCompilerPackages = [
|
|
|
1091
1055
|
async function react(options = {}) {
|
|
1092
1056
|
const {
|
|
1093
1057
|
files = [GLOB_SRC],
|
|
1094
|
-
ignoresTypeAware = [],
|
|
1095
1058
|
filesTypeAware = [GLOB_TS, GLOB_TSX],
|
|
1059
|
+
ignoresTypeAware = [],
|
|
1096
1060
|
overrides = {},
|
|
1097
|
-
|
|
1098
|
-
|
|
1061
|
+
reactCompiler = ReactCompilerPackages.some((i) => isPackageExists2(i)),
|
|
1062
|
+
tsconfigPath
|
|
1099
1063
|
} = options;
|
|
1100
1064
|
await ensurePackages([
|
|
1101
1065
|
"@eslint-react/eslint-plugin",
|
|
@@ -1104,8 +1068,8 @@ async function react(options = {}) {
|
|
|
1104
1068
|
]);
|
|
1105
1069
|
const isTypeAware = !!tsconfigPath;
|
|
1106
1070
|
const typeAwareRules = {
|
|
1107
|
-
"react/no-
|
|
1108
|
-
"react/no-
|
|
1071
|
+
"react/no-implicit-key": "error",
|
|
1072
|
+
"react/no-leaked-conditional-rendering": "warn"
|
|
1109
1073
|
};
|
|
1110
1074
|
const [
|
|
1111
1075
|
pluginReact,
|
|
@@ -1116,10 +1080,10 @@ async function react(options = {}) {
|
|
|
1116
1080
|
interopDefault(import("eslint-plugin-react-hooks")),
|
|
1117
1081
|
interopDefault(import("eslint-plugin-react-refresh"))
|
|
1118
1082
|
]);
|
|
1119
|
-
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) =>
|
|
1120
|
-
const isUsingRemix = RemixPackages.some((i) =>
|
|
1121
|
-
const isUsingReactRouter = ReactRouterPackages.some((i) =>
|
|
1122
|
-
const isUsingNext = NextJsPackages.some((i) =>
|
|
1083
|
+
const isAllowConstantExport = ReactRefreshAllowConstantExportPackages.some((i) => isPackageExists2(i));
|
|
1084
|
+
const isUsingRemix = RemixPackages.some((i) => isPackageExists2(i));
|
|
1085
|
+
const isUsingReactRouter = ReactRouterPackages.some((i) => isPackageExists2(i));
|
|
1086
|
+
const isUsingNext = NextJsPackages.some((i) => isPackageExists2(i));
|
|
1123
1087
|
const plugins = pluginReact.configs.all.plugins;
|
|
1124
1088
|
return [
|
|
1125
1089
|
{
|
|
@@ -1137,7 +1101,6 @@ async function react(options = {}) {
|
|
|
1137
1101
|
},
|
|
1138
1102
|
{
|
|
1139
1103
|
files,
|
|
1140
|
-
name: "acaleph/react/rules",
|
|
1141
1104
|
languageOptions: {
|
|
1142
1105
|
parserOptions: {
|
|
1143
1106
|
ecmaFeatures: {
|
|
@@ -1146,7 +1109,38 @@ async function react(options = {}) {
|
|
|
1146
1109
|
},
|
|
1147
1110
|
sourceType: "module"
|
|
1148
1111
|
},
|
|
1112
|
+
name: "acaleph/react/rules",
|
|
1149
1113
|
rules: {
|
|
1114
|
+
// recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
|
|
1115
|
+
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1116
|
+
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1117
|
+
"react-dom/no-find-dom-node": "error",
|
|
1118
|
+
"react-dom/no-flush-sync": "error",
|
|
1119
|
+
"react-dom/no-hydrate": "error",
|
|
1120
|
+
"react-dom/no-namespace": "error",
|
|
1121
|
+
"react-dom/no-render": "error",
|
|
1122
|
+
"react-dom/no-render-return-value": "error",
|
|
1123
|
+
"react-dom/no-script-url": "warn",
|
|
1124
|
+
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1125
|
+
"react-dom/no-use-form-state": "error",
|
|
1126
|
+
"react-dom/no-void-elements-with-children": "error",
|
|
1127
|
+
// recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
|
|
1128
|
+
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1129
|
+
"react-hooks/exhaustive-deps": "warn",
|
|
1130
|
+
// recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
|
|
1131
|
+
// Core hooks rules
|
|
1132
|
+
"react-hooks/rules-of-hooks": "error",
|
|
1133
|
+
// recommended rules from eslint-plugin-react-naming-convention https://eslint-react.xyz/docs/rules/overview#naming-convention-rules
|
|
1134
|
+
"react-naming-convention/context-name": "warn",
|
|
1135
|
+
"react-naming-convention/ref-name": "warn",
|
|
1136
|
+
"react-naming-convention/use-state": "warn",
|
|
1137
|
+
// recommended rules from eslint-plugin-react-rsc https://eslint-react.xyz/docs/rules/overview#rsc-rules
|
|
1138
|
+
"react-rsc/function-definition": "error",
|
|
1139
|
+
// recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
|
|
1140
|
+
"react-web-api/no-leaked-event-listener": "warn",
|
|
1141
|
+
"react-web-api/no-leaked-interval": "warn",
|
|
1142
|
+
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1143
|
+
"react-web-api/no-leaked-timeout": "warn",
|
|
1150
1144
|
// recommended rules from eslint-plugin-react-x https://eslint-react.xyz/docs/rules/overview#core-rules
|
|
1151
1145
|
"react/jsx-key-before-spread": "warn",
|
|
1152
1146
|
"react/jsx-no-comment-textnodes": "warn",
|
|
@@ -1185,46 +1179,17 @@ async function react(options = {}) {
|
|
|
1185
1179
|
"react/no-unused-class-component-members": "warn",
|
|
1186
1180
|
"react/no-use-context": "warn",
|
|
1187
1181
|
"react/no-useless-forward-ref": "warn",
|
|
1188
|
-
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1189
1182
|
"react/prefer-namespace-import": "error",
|
|
1190
|
-
|
|
1191
|
-
"react-rsc/function-definition": "error",
|
|
1192
|
-
// recommended rules from eslint-plugin-react-dom https://eslint-react.xyz/docs/rules/overview#dom-rules
|
|
1193
|
-
"react-dom/no-dangerously-set-innerhtml": "warn",
|
|
1194
|
-
"react-dom/no-dangerously-set-innerhtml-with-children": "error",
|
|
1195
|
-
"react-dom/no-find-dom-node": "error",
|
|
1196
|
-
"react-dom/no-flush-sync": "error",
|
|
1197
|
-
"react-dom/no-hydrate": "error",
|
|
1198
|
-
"react-dom/no-namespace": "error",
|
|
1199
|
-
"react-dom/no-render": "error",
|
|
1200
|
-
"react-dom/no-render-return-value": "error",
|
|
1201
|
-
"react-dom/no-script-url": "warn",
|
|
1202
|
-
"react-dom/no-unsafe-iframe-sandbox": "warn",
|
|
1203
|
-
"react-dom/no-use-form-state": "error",
|
|
1204
|
-
"react-dom/no-void-elements-with-children": "error",
|
|
1205
|
-
// recommended rules from eslint-plugin-react-hooks-extra https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules
|
|
1206
|
-
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
|
|
1207
|
-
// recommended rules from eslint-plugin-react-naming-convention https://eslint-react.xyz/docs/rules/overview#naming-convention-rules
|
|
1208
|
-
"react-naming-convention/context-name": "warn",
|
|
1209
|
-
"react-naming-convention/ref-name": "warn",
|
|
1210
|
-
"react-naming-convention/use-state": "warn",
|
|
1211
|
-
// recommended rules from eslint-plugin-react-web-api https://eslint-react.xyz/docs/rules/overview#web-api-rules
|
|
1212
|
-
"react-web-api/no-leaked-event-listener": "warn",
|
|
1213
|
-
"react-web-api/no-leaked-interval": "warn",
|
|
1214
|
-
"react-web-api/no-leaked-resize-observer": "warn",
|
|
1215
|
-
"react-web-api/no-leaked-timeout": "warn",
|
|
1216
|
-
// recommended rules eslint-plugin-react-hooks https://github.com/facebook/react/blob/main/packages/eslint-plugin-react-hooks/README.md
|
|
1217
|
-
// Core hooks rules
|
|
1218
|
-
"react-hooks/rules-of-hooks": "error",
|
|
1219
|
-
"react-hooks/exhaustive-deps": "warn",
|
|
1183
|
+
"react/prefer-use-state-lazy-initialization": "warn",
|
|
1220
1184
|
// React Compiler rules
|
|
1221
1185
|
...reactCompiler ? {
|
|
1186
|
+
"react-hooks/component-hook-factories": "error",
|
|
1222
1187
|
"react-hooks/config": "error",
|
|
1223
1188
|
"react-hooks/error-boundaries": "error",
|
|
1224
|
-
"react-hooks/component-hook-factories": "error",
|
|
1225
1189
|
"react-hooks/gating": "error",
|
|
1226
1190
|
"react-hooks/globals": "error",
|
|
1227
1191
|
"react-hooks/immutability": "error",
|
|
1192
|
+
"react-hooks/incompatible-library": "warn",
|
|
1228
1193
|
"react-hooks/preserve-manual-memoization": "error",
|
|
1229
1194
|
"react-hooks/purity": "error",
|
|
1230
1195
|
"react-hooks/refs": "error",
|
|
@@ -1232,8 +1197,7 @@ async function react(options = {}) {
|
|
|
1232
1197
|
"react-hooks/set-state-in-render": "error",
|
|
1233
1198
|
"react-hooks/static-components": "error",
|
|
1234
1199
|
"react-hooks/unsupported-syntax": "warn",
|
|
1235
|
-
"react-hooks/use-memo": "error"
|
|
1236
|
-
"react-hooks/incompatible-library": "warn"
|
|
1200
|
+
"react-hooks/use-memo": "error"
|
|
1237
1201
|
} : {},
|
|
1238
1202
|
// preconfigured rules from eslint-plugin-react-refresh https://github.com/ArnaudBarre/eslint-plugin-react-refresh/tree/main/src
|
|
1239
1203
|
"react-refresh/only-export-components": [
|
|
@@ -2292,9 +2256,9 @@ function acaleph(options = {}, ...userConfigs) {
|
|
|
2292
2256
|
pnpm: enableCatalogs = !!findUpSync("pnpm-workspace.yaml"),
|
|
2293
2257
|
react: enableReact = false,
|
|
2294
2258
|
regexp: enableRegexp = true,
|
|
2295
|
-
typescript: enableTypeScript =
|
|
2259
|
+
typescript: enableTypeScript = isPackageExists3("typescript"),
|
|
2296
2260
|
unocss: enableUnoCSS = false,
|
|
2297
|
-
vue: enableVue = VuePackages.some((i) =>
|
|
2261
|
+
vue: enableVue = VuePackages.some((i) => isPackageExists3(i))
|
|
2298
2262
|
} = options;
|
|
2299
2263
|
let isInEditor = options.isInEditor;
|
|
2300
2264
|
if (isInEditor == null) {
|