@pobammer-ts/eslint-cease-nonsense-rules 1.5.2 → 1.6.0
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/README.md +30 -0
- package/dist/build-metadata.json +3 -3
- package/dist/configure-utilities.d.ts +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +746 -257
- package/dist/index.js.map +21 -20
- package/dist/rules/no-god-components.d.ts +13 -0
- package/package.json +13 -13
package/dist/index.js
CHANGED
|
@@ -7700,7 +7700,8 @@ function EveryAll(value, offset, callback) {
|
|
|
7700
7700
|
return result;
|
|
7701
7701
|
}
|
|
7702
7702
|
function HasPropertyKey(value, key) {
|
|
7703
|
-
|
|
7703
|
+
const isProtoField = IsEqual(key, "__proto__") || IsEqual(key, "constructor");
|
|
7704
|
+
return isProtoField ? Object.prototype.hasOwnProperty.call(value, key) : (key in value);
|
|
7704
7705
|
}
|
|
7705
7706
|
function EntriesRegExp(value) {
|
|
7706
7707
|
return Keys(value).map((key) => [new RegExp(`^${key}$`), value[key]]);
|
|
@@ -7817,7 +7818,7 @@ function Keys2(value) {
|
|
|
7817
7818
|
return `Object.getOwnPropertyNames(${value})`;
|
|
7818
7819
|
}
|
|
7819
7820
|
function HasPropertyKey2(value, key) {
|
|
7820
|
-
const isProtoField = IsEqual(key, '"__proto__"') || IsEqual(key, '"
|
|
7821
|
+
const isProtoField = IsEqual(key, '"__proto__"') || IsEqual(key, '"constructor"');
|
|
7821
7822
|
return isProtoField ? `Object.prototype.hasOwnProperty.call(${value}, ${key})` : `${key} in ${value}`;
|
|
7822
7823
|
}
|
|
7823
7824
|
function IsDeepEqual2(left, right) {
|
|
@@ -14762,7 +14763,7 @@ function FromObject13(context, type3, value) {
|
|
|
14762
14763
|
continue;
|
|
14763
14764
|
value[key] = FromType16(context, type3.properties[key], value[key]);
|
|
14764
14765
|
}
|
|
14765
|
-
if (!IsAdditionalProperties(type3))
|
|
14766
|
+
if (!IsAdditionalProperties(type3) || exports_guard.IsBoolean(type3.additionalProperties))
|
|
14766
14767
|
return value;
|
|
14767
14768
|
for (const key of exports_guard.Keys(value)) {
|
|
14768
14769
|
if (knownPropertyKeys.includes(key))
|
|
@@ -15637,7 +15638,7 @@ function calculateIanitorComplexity(node) {
|
|
|
15637
15638
|
case "interface":
|
|
15638
15639
|
case "strictInterface": {
|
|
15639
15640
|
const properties4 = node.arguments?.[0];
|
|
15640
|
-
return properties4?.type === TSESTree3.AST_NODE_TYPES.ObjectExpression ? 10 + (properties4.properties?.length
|
|
15641
|
+
return properties4?.type === TSESTree3.AST_NODE_TYPES.ObjectExpression ? 10 + (properties4.properties?.length ?? 0) * 3 : 0;
|
|
15641
15642
|
}
|
|
15642
15643
|
case "optional":
|
|
15643
15644
|
case "array":
|
|
@@ -15649,7 +15650,7 @@ function calculateIanitorComplexity(node) {
|
|
|
15649
15650
|
return 3;
|
|
15650
15651
|
case "union":
|
|
15651
15652
|
case "intersection":
|
|
15652
|
-
return (node.arguments?.length
|
|
15653
|
+
return (node.arguments?.length ?? 0) * 2;
|
|
15653
15654
|
case "string":
|
|
15654
15655
|
case "number":
|
|
15655
15656
|
case "boolean":
|
|
@@ -15826,7 +15827,7 @@ var enforceIanitorCheckType = createRule({
|
|
|
15826
15827
|
const name = getTypeName(node);
|
|
15827
15828
|
if (complexity >= config.interfacePenalty) {
|
|
15828
15829
|
context.report({
|
|
15829
|
-
data: { name: name
|
|
15830
|
+
data: { name: name ?? "unknown" },
|
|
15830
15831
|
messageId: "complexInterfaceNeedsCheck",
|
|
15831
15832
|
node
|
|
15832
15833
|
});
|
|
@@ -15990,9 +15991,8 @@ function isNonIIFEFunction(node, parent) {
|
|
|
15990
15991
|
if (node.type !== AST_NODE_TYPES.ArrowFunctionExpression && node.type !== AST_NODE_TYPES.FunctionExpression) {
|
|
15991
15992
|
return false;
|
|
15992
15993
|
}
|
|
15993
|
-
if (parent?.type === AST_NODE_TYPES.CallExpression && parent.callee === node)
|
|
15994
|
+
if (parent?.type === AST_NODE_TYPES.CallExpression && parent.callee === node)
|
|
15994
15995
|
return false;
|
|
15995
|
-
}
|
|
15996
15996
|
return true;
|
|
15997
15997
|
}
|
|
15998
15998
|
function findConstructorViolations(constructorBody, asyncMethods) {
|
|
@@ -16249,8 +16249,8 @@ function requireNative() {
|
|
|
16249
16249
|
try {
|
|
16250
16250
|
const binding = require2("@oxc-parser/binding-android-arm64");
|
|
16251
16251
|
const bindingPackageVersion = require2("@oxc-parser/binding-android-arm64/package.json").version;
|
|
16252
|
-
if (bindingPackageVersion !== "0.
|
|
16253
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16252
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16253
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16254
16254
|
}
|
|
16255
16255
|
return binding;
|
|
16256
16256
|
} catch (e) {
|
|
@@ -16265,8 +16265,8 @@ function requireNative() {
|
|
|
16265
16265
|
try {
|
|
16266
16266
|
const binding = require2("@oxc-parser/binding-android-arm-eabi");
|
|
16267
16267
|
const bindingPackageVersion = require2("@oxc-parser/binding-android-arm-eabi/package.json").version;
|
|
16268
|
-
if (bindingPackageVersion !== "0.
|
|
16269
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16268
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16269
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16270
16270
|
}
|
|
16271
16271
|
return binding;
|
|
16272
16272
|
} catch (e) {
|
|
@@ -16286,8 +16286,8 @@ function requireNative() {
|
|
|
16286
16286
|
try {
|
|
16287
16287
|
const binding = require2("@oxc-parser/binding-win32-x64-gnu");
|
|
16288
16288
|
const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-gnu/package.json").version;
|
|
16289
|
-
if (bindingPackageVersion !== "0.
|
|
16290
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16289
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16290
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16291
16291
|
}
|
|
16292
16292
|
return binding;
|
|
16293
16293
|
} catch (e) {
|
|
@@ -16302,8 +16302,8 @@ function requireNative() {
|
|
|
16302
16302
|
try {
|
|
16303
16303
|
const binding = require2("@oxc-parser/binding-win32-x64-msvc");
|
|
16304
16304
|
const bindingPackageVersion = require2("@oxc-parser/binding-win32-x64-msvc/package.json").version;
|
|
16305
|
-
if (bindingPackageVersion !== "0.
|
|
16306
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16305
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16306
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16307
16307
|
}
|
|
16308
16308
|
return binding;
|
|
16309
16309
|
} catch (e) {
|
|
@@ -16319,8 +16319,8 @@ function requireNative() {
|
|
|
16319
16319
|
try {
|
|
16320
16320
|
const binding = require2("@oxc-parser/binding-win32-ia32-msvc");
|
|
16321
16321
|
const bindingPackageVersion = require2("@oxc-parser/binding-win32-ia32-msvc/package.json").version;
|
|
16322
|
-
if (bindingPackageVersion !== "0.
|
|
16323
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16322
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16323
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16324
16324
|
}
|
|
16325
16325
|
return binding;
|
|
16326
16326
|
} catch (e) {
|
|
@@ -16335,8 +16335,8 @@ function requireNative() {
|
|
|
16335
16335
|
try {
|
|
16336
16336
|
const binding = require2("@oxc-parser/binding-win32-arm64-msvc");
|
|
16337
16337
|
const bindingPackageVersion = require2("@oxc-parser/binding-win32-arm64-msvc/package.json").version;
|
|
16338
|
-
if (bindingPackageVersion !== "0.
|
|
16339
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16338
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16339
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16340
16340
|
}
|
|
16341
16341
|
return binding;
|
|
16342
16342
|
} catch (e) {
|
|
@@ -16354,8 +16354,8 @@ function requireNative() {
|
|
|
16354
16354
|
try {
|
|
16355
16355
|
const binding = require2("@oxc-parser/binding-darwin-universal");
|
|
16356
16356
|
const bindingPackageVersion = require2("@oxc-parser/binding-darwin-universal/package.json").version;
|
|
16357
|
-
if (bindingPackageVersion !== "0.
|
|
16358
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16357
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16358
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16359
16359
|
}
|
|
16360
16360
|
return binding;
|
|
16361
16361
|
} catch (e) {
|
|
@@ -16370,8 +16370,8 @@ function requireNative() {
|
|
|
16370
16370
|
try {
|
|
16371
16371
|
const binding = require2("@oxc-parser/binding-darwin-x64");
|
|
16372
16372
|
const bindingPackageVersion = require2("@oxc-parser/binding-darwin-x64/package.json").version;
|
|
16373
|
-
if (bindingPackageVersion !== "0.
|
|
16374
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16373
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16374
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16375
16375
|
}
|
|
16376
16376
|
return binding;
|
|
16377
16377
|
} catch (e) {
|
|
@@ -16386,8 +16386,8 @@ function requireNative() {
|
|
|
16386
16386
|
try {
|
|
16387
16387
|
const binding = require2("@oxc-parser/binding-darwin-arm64");
|
|
16388
16388
|
const bindingPackageVersion = require2("@oxc-parser/binding-darwin-arm64/package.json").version;
|
|
16389
|
-
if (bindingPackageVersion !== "0.
|
|
16390
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16389
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16390
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16391
16391
|
}
|
|
16392
16392
|
return binding;
|
|
16393
16393
|
} catch (e) {
|
|
@@ -16406,8 +16406,8 @@ function requireNative() {
|
|
|
16406
16406
|
try {
|
|
16407
16407
|
const binding = require2("@oxc-parser/binding-freebsd-x64");
|
|
16408
16408
|
const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-x64/package.json").version;
|
|
16409
|
-
if (bindingPackageVersion !== "0.
|
|
16410
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16409
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16410
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16411
16411
|
}
|
|
16412
16412
|
return binding;
|
|
16413
16413
|
} catch (e) {
|
|
@@ -16422,8 +16422,8 @@ function requireNative() {
|
|
|
16422
16422
|
try {
|
|
16423
16423
|
const binding = require2("@oxc-parser/binding-freebsd-arm64");
|
|
16424
16424
|
const bindingPackageVersion = require2("@oxc-parser/binding-freebsd-arm64/package.json").version;
|
|
16425
|
-
if (bindingPackageVersion !== "0.
|
|
16426
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16425
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16426
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16427
16427
|
}
|
|
16428
16428
|
return binding;
|
|
16429
16429
|
} catch (e) {
|
|
@@ -16443,8 +16443,8 @@ function requireNative() {
|
|
|
16443
16443
|
try {
|
|
16444
16444
|
const binding = require2("@oxc-parser/binding-linux-x64-musl");
|
|
16445
16445
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-musl/package.json").version;
|
|
16446
|
-
if (bindingPackageVersion !== "0.
|
|
16447
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16446
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16447
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16448
16448
|
}
|
|
16449
16449
|
return binding;
|
|
16450
16450
|
} catch (e) {
|
|
@@ -16459,8 +16459,8 @@ function requireNative() {
|
|
|
16459
16459
|
try {
|
|
16460
16460
|
const binding = require2("@oxc-parser/binding-linux-x64-gnu");
|
|
16461
16461
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-x64-gnu/package.json").version;
|
|
16462
|
-
if (bindingPackageVersion !== "0.
|
|
16463
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16462
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16463
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16464
16464
|
}
|
|
16465
16465
|
return binding;
|
|
16466
16466
|
} catch (e) {
|
|
@@ -16477,8 +16477,8 @@ function requireNative() {
|
|
|
16477
16477
|
try {
|
|
16478
16478
|
const binding = require2("@oxc-parser/binding-linux-arm64-musl");
|
|
16479
16479
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-musl/package.json").version;
|
|
16480
|
-
if (bindingPackageVersion !== "0.
|
|
16481
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16480
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16481
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16482
16482
|
}
|
|
16483
16483
|
return binding;
|
|
16484
16484
|
} catch (e) {
|
|
@@ -16493,8 +16493,8 @@ function requireNative() {
|
|
|
16493
16493
|
try {
|
|
16494
16494
|
const binding = require2("@oxc-parser/binding-linux-arm64-gnu");
|
|
16495
16495
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm64-gnu/package.json").version;
|
|
16496
|
-
if (bindingPackageVersion !== "0.
|
|
16497
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16496
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16497
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16498
16498
|
}
|
|
16499
16499
|
return binding;
|
|
16500
16500
|
} catch (e) {
|
|
@@ -16511,8 +16511,8 @@ function requireNative() {
|
|
|
16511
16511
|
try {
|
|
16512
16512
|
const binding = require2("@oxc-parser/binding-linux-arm-musleabihf");
|
|
16513
16513
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-musleabihf/package.json").version;
|
|
16514
|
-
if (bindingPackageVersion !== "0.
|
|
16515
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16514
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16515
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16516
16516
|
}
|
|
16517
16517
|
return binding;
|
|
16518
16518
|
} catch (e) {
|
|
@@ -16527,8 +16527,8 @@ function requireNative() {
|
|
|
16527
16527
|
try {
|
|
16528
16528
|
const binding = require2("@oxc-parser/binding-linux-arm-gnueabihf");
|
|
16529
16529
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-arm-gnueabihf/package.json").version;
|
|
16530
|
-
if (bindingPackageVersion !== "0.
|
|
16531
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16530
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16531
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16532
16532
|
}
|
|
16533
16533
|
return binding;
|
|
16534
16534
|
} catch (e) {
|
|
@@ -16545,8 +16545,8 @@ function requireNative() {
|
|
|
16545
16545
|
try {
|
|
16546
16546
|
const binding = require2("@oxc-parser/binding-linux-loong64-musl");
|
|
16547
16547
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-musl/package.json").version;
|
|
16548
|
-
if (bindingPackageVersion !== "0.
|
|
16549
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16548
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16549
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16550
16550
|
}
|
|
16551
16551
|
return binding;
|
|
16552
16552
|
} catch (e) {
|
|
@@ -16561,8 +16561,8 @@ function requireNative() {
|
|
|
16561
16561
|
try {
|
|
16562
16562
|
const binding = require2("@oxc-parser/binding-linux-loong64-gnu");
|
|
16563
16563
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-loong64-gnu/package.json").version;
|
|
16564
|
-
if (bindingPackageVersion !== "0.
|
|
16565
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16564
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16565
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16566
16566
|
}
|
|
16567
16567
|
return binding;
|
|
16568
16568
|
} catch (e) {
|
|
@@ -16579,8 +16579,8 @@ function requireNative() {
|
|
|
16579
16579
|
try {
|
|
16580
16580
|
const binding = require2("@oxc-parser/binding-linux-riscv64-musl");
|
|
16581
16581
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-musl/package.json").version;
|
|
16582
|
-
if (bindingPackageVersion !== "0.
|
|
16583
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16582
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16583
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16584
16584
|
}
|
|
16585
16585
|
return binding;
|
|
16586
16586
|
} catch (e) {
|
|
@@ -16595,8 +16595,8 @@ function requireNative() {
|
|
|
16595
16595
|
try {
|
|
16596
16596
|
const binding = require2("@oxc-parser/binding-linux-riscv64-gnu");
|
|
16597
16597
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-riscv64-gnu/package.json").version;
|
|
16598
|
-
if (bindingPackageVersion !== "0.
|
|
16599
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16598
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16599
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16600
16600
|
}
|
|
16601
16601
|
return binding;
|
|
16602
16602
|
} catch (e) {
|
|
@@ -16612,8 +16612,8 @@ function requireNative() {
|
|
|
16612
16612
|
try {
|
|
16613
16613
|
const binding = require2("@oxc-parser/binding-linux-ppc64-gnu");
|
|
16614
16614
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-ppc64-gnu/package.json").version;
|
|
16615
|
-
if (bindingPackageVersion !== "0.
|
|
16616
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16615
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16616
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16617
16617
|
}
|
|
16618
16618
|
return binding;
|
|
16619
16619
|
} catch (e) {
|
|
@@ -16628,8 +16628,8 @@ function requireNative() {
|
|
|
16628
16628
|
try {
|
|
16629
16629
|
const binding = require2("@oxc-parser/binding-linux-s390x-gnu");
|
|
16630
16630
|
const bindingPackageVersion = require2("@oxc-parser/binding-linux-s390x-gnu/package.json").version;
|
|
16631
|
-
if (bindingPackageVersion !== "0.
|
|
16632
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16631
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16632
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16633
16633
|
}
|
|
16634
16634
|
return binding;
|
|
16635
16635
|
} catch (e) {
|
|
@@ -16648,8 +16648,8 @@ function requireNative() {
|
|
|
16648
16648
|
try {
|
|
16649
16649
|
const binding = require2("@oxc-parser/binding-openharmony-arm64");
|
|
16650
16650
|
const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm64/package.json").version;
|
|
16651
|
-
if (bindingPackageVersion !== "0.
|
|
16652
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16651
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16652
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16653
16653
|
}
|
|
16654
16654
|
return binding;
|
|
16655
16655
|
} catch (e) {
|
|
@@ -16664,8 +16664,8 @@ function requireNative() {
|
|
|
16664
16664
|
try {
|
|
16665
16665
|
const binding = require2("@oxc-parser/binding-openharmony-x64");
|
|
16666
16666
|
const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-x64/package.json").version;
|
|
16667
|
-
if (bindingPackageVersion !== "0.
|
|
16668
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16667
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16668
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16669
16669
|
}
|
|
16670
16670
|
return binding;
|
|
16671
16671
|
} catch (e) {
|
|
@@ -16680,8 +16680,8 @@ function requireNative() {
|
|
|
16680
16680
|
try {
|
|
16681
16681
|
const binding = require2("@oxc-parser/binding-openharmony-arm");
|
|
16682
16682
|
const bindingPackageVersion = require2("@oxc-parser/binding-openharmony-arm/package.json").version;
|
|
16683
|
-
if (bindingPackageVersion !== "0.
|
|
16684
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
16683
|
+
if (bindingPackageVersion !== "0.104.0" && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== "0") {
|
|
16684
|
+
throw new Error(`Native binding package version mismatch, expected 0.104.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`);
|
|
16685
16685
|
}
|
|
16686
16686
|
return binding;
|
|
16687
16687
|
} catch (e) {
|
|
@@ -16790,7 +16790,7 @@ function applyFix(program, fixPath) {
|
|
|
16790
16790
|
}
|
|
16791
16791
|
}
|
|
16792
16792
|
|
|
16793
|
-
// node_modules/oxc-parser/generated/visit/keys.js
|
|
16793
|
+
// node_modules/oxc-parser/src-js/generated/visit/keys.js
|
|
16794
16794
|
var { freeze } = Object;
|
|
16795
16795
|
var $EMPTY = freeze([]);
|
|
16796
16796
|
var DECORATORS__KEY__TYPE_ANNOTATION__VALUE = freeze([
|
|
@@ -16961,7 +16961,7 @@ var keys_default = freeze({
|
|
|
16961
16961
|
TSExternalModuleReference: EXPRESSION,
|
|
16962
16962
|
TSFunctionType: TYPE_PARAMETERS__PARAMS__RETURN_TYPE,
|
|
16963
16963
|
TSImportEqualsDeclaration: freeze(["id", "moduleReference"]),
|
|
16964
|
-
TSImportType: freeze(["
|
|
16964
|
+
TSImportType: freeze(["source", "options", "qualifier", "typeArguments"]),
|
|
16965
16965
|
TSIndexSignature: freeze(["parameters", "typeAnnotation"]),
|
|
16966
16966
|
TSIndexedAccessType: freeze(["objectType", "indexType"]),
|
|
16967
16967
|
TSInferType: freeze(["typeParameter"]),
|
|
@@ -17014,7 +17014,7 @@ class Visitor {
|
|
|
17014
17014
|
constructor(visitor) {
|
|
17015
17015
|
if (walkProgram === null) {
|
|
17016
17016
|
const require3 = createRequire3(import.meta.url);
|
|
17017
|
-
({ walkProgram } = require3("
|
|
17017
|
+
({ walkProgram } = require3("../generated/visit/walk.js"));
|
|
17018
17018
|
({
|
|
17019
17019
|
addVisitorToCompiled,
|
|
17020
17020
|
createCompiledVisitor,
|
|
@@ -17609,7 +17609,9 @@ var isRuleOptions = Compile(build_default.Object({
|
|
|
17609
17609
|
allowPropertyAccess: build_default.Optional(build_default.Array(build_default.String())),
|
|
17610
17610
|
shorthands: build_default.Optional(build_default.Record(build_default.String(), build_default.String()))
|
|
17611
17611
|
}));
|
|
17612
|
-
|
|
17612
|
+
function isRecord2(value) {
|
|
17613
|
+
return value !== null && typeof value === "object";
|
|
17614
|
+
}
|
|
17613
17615
|
var DEFAULT_OPTIONS2 = {
|
|
17614
17616
|
allowPropertyAccess: ["char"],
|
|
17615
17617
|
shorthands: {
|
|
@@ -17619,52 +17621,137 @@ var DEFAULT_OPTIONS2 = {
|
|
|
17619
17621
|
plr: "player"
|
|
17620
17622
|
}
|
|
17621
17623
|
};
|
|
17622
|
-
var
|
|
17623
|
-
var
|
|
17624
|
+
var REGEX_PATTERN_MATCHER = /^\/(.+)\/([gimsuy]*)$/;
|
|
17625
|
+
var WORD_BOUNDARY_REGEX = /(?<=[a-z])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-zA-Z])(?=\d)|(?<=\d)(?=[a-zA-Z])/;
|
|
17626
|
+
function splitIdentifierIntoWords(identifier3) {
|
|
17627
|
+
return identifier3.split(WORD_BOUNDARY_REGEX);
|
|
17628
|
+
}
|
|
17629
|
+
function createMatcher(key, replacement) {
|
|
17630
|
+
if (key.startsWith("/")) {
|
|
17631
|
+
const match = key.match(REGEX_PATTERN_MATCHER);
|
|
17632
|
+
if (match) {
|
|
17633
|
+
return {
|
|
17634
|
+
matcher: {
|
|
17635
|
+
original: key,
|
|
17636
|
+
pattern: new RegExp(`^${match[1]}$`, match[2]),
|
|
17637
|
+
replacement
|
|
17638
|
+
},
|
|
17639
|
+
type: "pattern"
|
|
17640
|
+
};
|
|
17641
|
+
}
|
|
17642
|
+
}
|
|
17643
|
+
if (key.includes("*") || key.includes("?")) {
|
|
17644
|
+
const regexPattern = key.replaceAll(/[.+^${}()|[\]\\]/g, String.raw`\$&`).replaceAll("*", "(.*)").replaceAll("?", "(.)");
|
|
17645
|
+
let captureIndex = 0;
|
|
17646
|
+
const regexReplacement = replacement.replaceAll("*", () => `$${++captureIndex}`);
|
|
17647
|
+
return {
|
|
17648
|
+
matcher: {
|
|
17649
|
+
original: key,
|
|
17650
|
+
pattern: new RegExp(`^${regexPattern}$`),
|
|
17651
|
+
replacement: regexReplacement
|
|
17652
|
+
},
|
|
17653
|
+
type: "pattern"
|
|
17654
|
+
};
|
|
17655
|
+
}
|
|
17656
|
+
return {
|
|
17657
|
+
original: key,
|
|
17658
|
+
replacement,
|
|
17659
|
+
type: "exact"
|
|
17660
|
+
};
|
|
17661
|
+
}
|
|
17662
|
+
function matchWord(word, matchers, exactMatchers) {
|
|
17663
|
+
const exactReplacement = exactMatchers.get(word);
|
|
17664
|
+
if (exactReplacement !== undefined) {
|
|
17665
|
+
return {
|
|
17666
|
+
replacement: exactReplacement,
|
|
17667
|
+
shorthand: word
|
|
17668
|
+
};
|
|
17669
|
+
}
|
|
17670
|
+
for (const matcher of matchers) {
|
|
17671
|
+
const match = word.match(matcher.pattern);
|
|
17672
|
+
if (match) {
|
|
17673
|
+
let replaced = matcher.replacement;
|
|
17674
|
+
for (let i = 1;i < match.length; i++) {
|
|
17675
|
+
replaced = replaced.replaceAll(new RegExp(`\\$${i}`, "g"), match[i] ?? "");
|
|
17676
|
+
}
|
|
17677
|
+
return {
|
|
17678
|
+
replacement: replaced,
|
|
17679
|
+
shorthand: matcher.original
|
|
17680
|
+
};
|
|
17681
|
+
}
|
|
17682
|
+
}
|
|
17683
|
+
return;
|
|
17684
|
+
}
|
|
17685
|
+
function buildReplacementIdentifier(identifier3, options3) {
|
|
17686
|
+
const words = splitIdentifierIntoWords(identifier3);
|
|
17687
|
+
const matches = [];
|
|
17688
|
+
let hasMatch = false;
|
|
17689
|
+
const newWords = words.map((word) => {
|
|
17690
|
+
const match = matchWord(word, options3.matchers, options3.exactMatchers);
|
|
17691
|
+
if (match) {
|
|
17692
|
+
hasMatch = true;
|
|
17693
|
+
matches.push(match);
|
|
17694
|
+
return match.replacement;
|
|
17695
|
+
}
|
|
17696
|
+
return word;
|
|
17697
|
+
});
|
|
17698
|
+
if (!hasMatch)
|
|
17699
|
+
return;
|
|
17700
|
+
return { matches, replaced: newWords.join("") };
|
|
17701
|
+
}
|
|
17624
17702
|
function normalizeOptions2(rawOptions) {
|
|
17625
17703
|
const mergedShorthands = { ...DEFAULT_OPTIONS2.shorthands };
|
|
17626
17704
|
if (rawOptions?.shorthands)
|
|
17627
17705
|
for (const [key, value] of Object.entries(rawOptions.shorthands))
|
|
17628
17706
|
mergedShorthands[key] = value;
|
|
17629
|
-
const
|
|
17707
|
+
const matchers = [];
|
|
17708
|
+
const exactMatchers = new Map;
|
|
17709
|
+
for (const [key, value] of Object.entries(mergedShorthands)) {
|
|
17710
|
+
const result = createMatcher(key, value);
|
|
17711
|
+
if (result.type === "exact") {
|
|
17712
|
+
exactMatchers.set(result.original, result.replacement);
|
|
17713
|
+
} else {
|
|
17714
|
+
matchers.push(result.matcher);
|
|
17715
|
+
}
|
|
17716
|
+
}
|
|
17630
17717
|
const allowPropertyAccessSource = rawOptions?.allowPropertyAccess ?? DEFAULT_OPTIONS2.allowPropertyAccess;
|
|
17631
|
-
const escapedKeys = new Array;
|
|
17632
|
-
let length = 0;
|
|
17633
|
-
for (const key of shorthandsMap.keys())
|
|
17634
|
-
escapedKeys[length++] = key.replaceAll(ESCAPE_REGEXP, ESCAPE_WITH);
|
|
17635
|
-
const selector = `Identifier[name=/^(${escapedKeys.join("|")})$/]`;
|
|
17636
17718
|
return {
|
|
17637
17719
|
allowPropertyAccess: new Set(allowPropertyAccessSource),
|
|
17638
|
-
|
|
17639
|
-
|
|
17720
|
+
exactMatchers,
|
|
17721
|
+
matchers,
|
|
17722
|
+
selector: "Identifier"
|
|
17640
17723
|
};
|
|
17641
17724
|
}
|
|
17642
17725
|
var noShorthandNames = {
|
|
17643
17726
|
create(context) {
|
|
17644
17727
|
const validatedOptions = isRuleOptions.Check(context.options[0]) ? context.options[0] : undefined;
|
|
17645
|
-
const
|
|
17728
|
+
const normalized = normalizeOptions2(validatedOptions);
|
|
17729
|
+
const { allowPropertyAccess, selector } = normalized;
|
|
17646
17730
|
return {
|
|
17647
17731
|
[selector](node) {
|
|
17648
|
-
const
|
|
17649
|
-
const
|
|
17650
|
-
if (
|
|
17732
|
+
const identifierName = node.name;
|
|
17733
|
+
const result = buildReplacementIdentifier(identifierName, normalized);
|
|
17734
|
+
if (result === undefined)
|
|
17651
17735
|
return;
|
|
17736
|
+
const { replaced, matches } = result;
|
|
17652
17737
|
const { parent } = node;
|
|
17653
|
-
|
|
17738
|
+
const [match] = matches;
|
|
17739
|
+
if (matches.length === 1 && match !== undefined && allowPropertyAccess.has(match.shorthand) && parent !== undefined && isRecord2(parent) && parent.type === TSESTree5.AST_NODE_TYPES.MemberExpression && parent.property === node)
|
|
17654
17740
|
return;
|
|
17655
|
-
if (
|
|
17741
|
+
if (identifierName === "plr" && parent?.type === TSESTree5.AST_NODE_TYPES.VariableDeclarator && parent.id === node) {
|
|
17656
17742
|
const { init } = parent;
|
|
17657
|
-
if (init &&
|
|
17743
|
+
if (init && isRecord2(init) && init.type === TSESTree5.AST_NODE_TYPES.MemberExpression && init.object !== undefined && isRecord2(init.object) && init.object.type === TSESTree5.AST_NODE_TYPES.Identifier && init.object.name === "Players" && init.property !== undefined && isRecord2(init.property) && init.property.type === TSESTree5.AST_NODE_TYPES.Identifier && init.property.name === "LocalPlayer") {
|
|
17658
17744
|
context.report({
|
|
17659
|
-
data: { replacement: "localPlayer", shorthand:
|
|
17745
|
+
data: { replacement: "localPlayer", shorthand: "plr" },
|
|
17660
17746
|
messageId: "useReplacement",
|
|
17661
17747
|
node
|
|
17662
17748
|
});
|
|
17663
17749
|
return;
|
|
17664
17750
|
}
|
|
17665
17751
|
}
|
|
17752
|
+
const shorthandList = matches.map((m) => m.shorthand).join(", ");
|
|
17666
17753
|
context.report({
|
|
17667
|
-
data: { replacement, shorthand:
|
|
17754
|
+
data: { replacement: replaced, shorthand: shorthandList },
|
|
17668
17755
|
messageId: "useReplacement",
|
|
17669
17756
|
node
|
|
17670
17757
|
});
|
|
@@ -17858,6 +17945,50 @@ function isNonPatternExpression(value) {
|
|
|
17858
17945
|
function isNonPrivateExpression(value) {
|
|
17859
17946
|
return value.type !== AST_NODE_TYPES3.PrivateIdentifier;
|
|
17860
17947
|
}
|
|
17948
|
+
function objectHasFromAndTo(objectExpr) {
|
|
17949
|
+
let hasFrom = false;
|
|
17950
|
+
let hasTo = false;
|
|
17951
|
+
for (const property of objectExpr.properties) {
|
|
17952
|
+
if (property.type !== AST_NODE_TYPES3.Property)
|
|
17953
|
+
continue;
|
|
17954
|
+
if (property.computed)
|
|
17955
|
+
continue;
|
|
17956
|
+
if (property.key.type !== AST_NODE_TYPES3.Identifier)
|
|
17957
|
+
continue;
|
|
17958
|
+
if (property.key.name === "from")
|
|
17959
|
+
hasFrom = true;
|
|
17960
|
+
if (property.key.name === "to")
|
|
17961
|
+
hasTo = true;
|
|
17962
|
+
if (hasFrom && hasTo)
|
|
17963
|
+
return true;
|
|
17964
|
+
}
|
|
17965
|
+
return false;
|
|
17966
|
+
}
|
|
17967
|
+
function hasFromAndToProperties(context, expression) {
|
|
17968
|
+
const unwrapped = unwrapExpression(expression);
|
|
17969
|
+
if (unwrapped.type === AST_NODE_TYPES3.ObjectExpression)
|
|
17970
|
+
return objectHasFromAndTo(unwrapped);
|
|
17971
|
+
if (unwrapped.type === AST_NODE_TYPES3.Identifier) {
|
|
17972
|
+
const variable = findVariable(context, unwrapped);
|
|
17973
|
+
if (variable === undefined)
|
|
17974
|
+
return false;
|
|
17975
|
+
if (!isModuleLevelScope(variable.scope))
|
|
17976
|
+
return false;
|
|
17977
|
+
if (isImport(variable))
|
|
17978
|
+
return false;
|
|
17979
|
+
for (const def of variable.defs) {
|
|
17980
|
+
const initializer = getConstInitializer(def);
|
|
17981
|
+
if (initializer === undefined)
|
|
17982
|
+
continue;
|
|
17983
|
+
const normalizedInitializer = unwrapExpression(initializer);
|
|
17984
|
+
if (normalizedInitializer.type !== AST_NODE_TYPES3.ObjectExpression)
|
|
17985
|
+
continue;
|
|
17986
|
+
if (objectHasFromAndTo(normalizedInitializer))
|
|
17987
|
+
return true;
|
|
17988
|
+
}
|
|
17989
|
+
}
|
|
17990
|
+
return false;
|
|
17991
|
+
}
|
|
17861
17992
|
function isStaticObjectLikeConfig(context, expression, seen, options3) {
|
|
17862
17993
|
const unwrapped = unwrapExpression(expression);
|
|
17863
17994
|
if (unwrapped.type === AST_NODE_TYPES3.ObjectExpression)
|
|
@@ -17993,6 +18124,8 @@ var noUselessUseSpring = {
|
|
|
17993
18124
|
const seen = new Set;
|
|
17994
18125
|
if (!isStaticObjectLikeConfig(context, configArgument, seen, normalized))
|
|
17995
18126
|
return;
|
|
18127
|
+
if (hasFromAndToProperties(context, configArgument))
|
|
18128
|
+
return;
|
|
17996
18129
|
const depsKind = classifyDependencies(context, node.arguments[1], seen, normalized);
|
|
17997
18130
|
if (!depsAreNonUpdating(depsKind, normalized))
|
|
17998
18131
|
return;
|
|
@@ -18066,6 +18199,347 @@ var noWarn = {
|
|
|
18066
18199
|
};
|
|
18067
18200
|
var no_warn_default = noWarn;
|
|
18068
18201
|
|
|
18202
|
+
// src/rules/no-god-components.ts
|
|
18203
|
+
import { TSESTree as TSESTree6 } from "@typescript-eslint/types";
|
|
18204
|
+
var COMPONENT_NAME_PATTERN = /^[A-Z]/;
|
|
18205
|
+
var FUNCTION_BOUNDARIES = new Set([
|
|
18206
|
+
TSESTree6.AST_NODE_TYPES.FunctionDeclaration,
|
|
18207
|
+
TSESTree6.AST_NODE_TYPES.FunctionExpression,
|
|
18208
|
+
TSESTree6.AST_NODE_TYPES.ArrowFunctionExpression
|
|
18209
|
+
]);
|
|
18210
|
+
var RUNTIME_TS_WRAPPERS = new Set([
|
|
18211
|
+
"ParenthesizedExpression",
|
|
18212
|
+
"TSAsExpression",
|
|
18213
|
+
"TSSatisfiesExpression",
|
|
18214
|
+
"TSTypeAssertion",
|
|
18215
|
+
"TSNonNullExpression",
|
|
18216
|
+
"TSInstantiationExpression",
|
|
18217
|
+
"ChainExpression"
|
|
18218
|
+
]);
|
|
18219
|
+
function isComponentName(name) {
|
|
18220
|
+
return COMPONENT_NAME_PATTERN.test(name);
|
|
18221
|
+
}
|
|
18222
|
+
function isReactComponentHOC(callExpr) {
|
|
18223
|
+
const { callee } = callExpr;
|
|
18224
|
+
if (callee.type === TSESTree6.AST_NODE_TYPES.Identifier)
|
|
18225
|
+
return callee.name === "forwardRef" || callee.name === "memo";
|
|
18226
|
+
if (callee.type === TSESTree6.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree6.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === TSESTree6.AST_NODE_TYPES.Identifier)
|
|
18227
|
+
return callee.property.name === "forwardRef" || callee.property.name === "memo";
|
|
18228
|
+
return false;
|
|
18229
|
+
}
|
|
18230
|
+
function getComponentNameFromFunction(node) {
|
|
18231
|
+
if (node.type === TSESTree6.AST_NODE_TYPES.FunctionDeclaration && node.id && isComponentName(node.id.name))
|
|
18232
|
+
return node.id.name;
|
|
18233
|
+
if (node.type === TSESTree6.AST_NODE_TYPES.FunctionExpression || node.type === TSESTree6.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
18234
|
+
const { parent } = node;
|
|
18235
|
+
if (parent === null || parent === undefined)
|
|
18236
|
+
return;
|
|
18237
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree6.AST_NODE_TYPES.Identifier && isComponentName(parent.id.name))
|
|
18238
|
+
return parent.id.name;
|
|
18239
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.Property && parent.key.type === TSESTree6.AST_NODE_TYPES.Identifier && isComponentName(parent.key.name))
|
|
18240
|
+
return parent.key.name;
|
|
18241
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.MethodDefinition && parent.key.type === TSESTree6.AST_NODE_TYPES.Identifier && isComponentName(parent.key.name))
|
|
18242
|
+
return parent.key.name;
|
|
18243
|
+
}
|
|
18244
|
+
return;
|
|
18245
|
+
}
|
|
18246
|
+
function getComponentNameFromCallParent(callExpr) {
|
|
18247
|
+
const { parent } = callExpr;
|
|
18248
|
+
if (parent === null || parent === undefined)
|
|
18249
|
+
return;
|
|
18250
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree6.AST_NODE_TYPES.Identifier && isComponentName(parent.id.name))
|
|
18251
|
+
return parent.id.name;
|
|
18252
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.AssignmentExpression && parent.left.type === TSESTree6.AST_NODE_TYPES.Identifier && isComponentName(parent.left.name))
|
|
18253
|
+
return parent.left.name;
|
|
18254
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.ExportDefaultDeclaration && callExpr.arguments.length > 0) {
|
|
18255
|
+
const firstArg = callExpr.arguments[0];
|
|
18256
|
+
if (firstArg && firstArg.type === TSESTree6.AST_NODE_TYPES.FunctionExpression && firstArg.id && isComponentName(firstArg.id.name))
|
|
18257
|
+
return firstArg.id.name;
|
|
18258
|
+
}
|
|
18259
|
+
return;
|
|
18260
|
+
}
|
|
18261
|
+
function getHookName(callExpression) {
|
|
18262
|
+
const { callee } = callExpression;
|
|
18263
|
+
if (callee.type === TSESTree6.AST_NODE_TYPES.Identifier)
|
|
18264
|
+
return callee.name;
|
|
18265
|
+
if (callee.type === TSESTree6.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree6.AST_NODE_TYPES.Identifier)
|
|
18266
|
+
return callee.property.name;
|
|
18267
|
+
return;
|
|
18268
|
+
}
|
|
18269
|
+
function countDestructuredProps(node) {
|
|
18270
|
+
const firstParam = node.params[0];
|
|
18271
|
+
if (!firstParam)
|
|
18272
|
+
return;
|
|
18273
|
+
let pattern4;
|
|
18274
|
+
if (firstParam.type === TSESTree6.AST_NODE_TYPES.ObjectPattern)
|
|
18275
|
+
pattern4 = firstParam;
|
|
18276
|
+
if (firstParam.type === TSESTree6.AST_NODE_TYPES.AssignmentPattern && firstParam.left.type === TSESTree6.AST_NODE_TYPES.ObjectPattern)
|
|
18277
|
+
pattern4 = firstParam.left;
|
|
18278
|
+
if (!pattern4)
|
|
18279
|
+
return;
|
|
18280
|
+
let count = 0;
|
|
18281
|
+
for (const prop of pattern4.properties) {
|
|
18282
|
+
if (prop.type === TSESTree6.AST_NODE_TYPES.Property)
|
|
18283
|
+
count += 1;
|
|
18284
|
+
}
|
|
18285
|
+
return count;
|
|
18286
|
+
}
|
|
18287
|
+
function isTypeOnlyNullLiteral(node) {
|
|
18288
|
+
const parent = node.parent;
|
|
18289
|
+
if (parent === null || parent === undefined)
|
|
18290
|
+
return false;
|
|
18291
|
+
if (typeof parent.type === "string" && parent.type.startsWith("TS") && !RUNTIME_TS_WRAPPERS.has(parent.type))
|
|
18292
|
+
return true;
|
|
18293
|
+
if (parent.type === TSESTree6.AST_NODE_TYPES.TSLiteralType)
|
|
18294
|
+
return true;
|
|
18295
|
+
return false;
|
|
18296
|
+
}
|
|
18297
|
+
function analyzeComponentBody(functionNode, sourceCode, stateHooks) {
|
|
18298
|
+
let maxJsxDepth = 0;
|
|
18299
|
+
let stateHookCount = 0;
|
|
18300
|
+
const nullLiterals = new Array;
|
|
18301
|
+
function visit(current, jsxDepth) {
|
|
18302
|
+
if (FUNCTION_BOUNDARIES.has(current.type) && current !== functionNode)
|
|
18303
|
+
return;
|
|
18304
|
+
let nextDepth = jsxDepth;
|
|
18305
|
+
if (current.type === TSESTree6.AST_NODE_TYPES.JSXElement || current.type === TSESTree6.AST_NODE_TYPES.JSXFragment) {
|
|
18306
|
+
nextDepth = jsxDepth + 1;
|
|
18307
|
+
if (nextDepth > maxJsxDepth)
|
|
18308
|
+
maxJsxDepth = nextDepth;
|
|
18309
|
+
}
|
|
18310
|
+
if (current.type === TSESTree6.AST_NODE_TYPES.CallExpression) {
|
|
18311
|
+
const hookName = getHookName(current);
|
|
18312
|
+
if (typeof hookName === "string" && hookName.length > 0 && stateHooks.has(hookName))
|
|
18313
|
+
stateHookCount += 1;
|
|
18314
|
+
}
|
|
18315
|
+
if (current.type === TSESTree6.AST_NODE_TYPES.Literal && current.value === null) {
|
|
18316
|
+
const literalNode = current;
|
|
18317
|
+
if (!isTypeOnlyNullLiteral(literalNode))
|
|
18318
|
+
nullLiterals.push(literalNode);
|
|
18319
|
+
}
|
|
18320
|
+
function getVisitorKeysForNodeType(nodeType) {
|
|
18321
|
+
const visitorKeysUnknown = sourceCode.visitorKeys;
|
|
18322
|
+
if (visitorKeysUnknown === null || visitorKeysUnknown === undefined || typeof visitorKeysUnknown !== "object")
|
|
18323
|
+
return [];
|
|
18324
|
+
const visitorKeysRecord = visitorKeysUnknown;
|
|
18325
|
+
const keysUnknown = visitorKeysRecord[nodeType];
|
|
18326
|
+
if (!Array.isArray(keysUnknown))
|
|
18327
|
+
return [];
|
|
18328
|
+
const keys3 = new Array;
|
|
18329
|
+
for (const key of keysUnknown)
|
|
18330
|
+
if (typeof key === "string")
|
|
18331
|
+
keys3.push(key);
|
|
18332
|
+
return keys3;
|
|
18333
|
+
}
|
|
18334
|
+
const keys2 = getVisitorKeysForNodeType(current.type);
|
|
18335
|
+
const currentRecord = current;
|
|
18336
|
+
for (const key of keys2) {
|
|
18337
|
+
const value = currentRecord[key];
|
|
18338
|
+
if (Array.isArray(value)) {
|
|
18339
|
+
for (const item of value) {
|
|
18340
|
+
if (typeof item === "object" && item !== null && "type" in item) {
|
|
18341
|
+
visit(item, nextDepth);
|
|
18342
|
+
}
|
|
18343
|
+
}
|
|
18344
|
+
continue;
|
|
18345
|
+
}
|
|
18346
|
+
if (typeof value === "object" && value !== null && "type" in value) {
|
|
18347
|
+
visit(value, nextDepth);
|
|
18348
|
+
}
|
|
18349
|
+
}
|
|
18350
|
+
}
|
|
18351
|
+
visit(functionNode.body, 0);
|
|
18352
|
+
return { maxJsxDepth, nullLiterals, stateHookCount };
|
|
18353
|
+
}
|
|
18354
|
+
function parseOptions(options3) {
|
|
18355
|
+
const defaults = {
|
|
18356
|
+
enforceTargetLines: true,
|
|
18357
|
+
ignoreComponents: [],
|
|
18358
|
+
maxDestructuredProps: 5,
|
|
18359
|
+
maxLines: 200,
|
|
18360
|
+
maxStateHooks: 5,
|
|
18361
|
+
maxTsxNesting: 3,
|
|
18362
|
+
stateHooks: ["useState", "useReducer", "useBinding"],
|
|
18363
|
+
targetLines: 120
|
|
18364
|
+
};
|
|
18365
|
+
if (typeof options3 !== "object" || options3 === null)
|
|
18366
|
+
return defaults;
|
|
18367
|
+
const cast = options3;
|
|
18368
|
+
return {
|
|
18369
|
+
enforceTargetLines: typeof cast.enforceTargetLines === "boolean" ? cast.enforceTargetLines : defaults.enforceTargetLines,
|
|
18370
|
+
ignoreComponents: Array.isArray(cast.ignoreComponents) ? cast.ignoreComponents : defaults.ignoreComponents,
|
|
18371
|
+
maxDestructuredProps: typeof cast.maxDestructuredProps === "number" ? cast.maxDestructuredProps : defaults.maxDestructuredProps,
|
|
18372
|
+
maxLines: typeof cast.maxLines === "number" ? cast.maxLines : defaults.maxLines,
|
|
18373
|
+
maxStateHooks: typeof cast.maxStateHooks === "number" ? cast.maxStateHooks : defaults.maxStateHooks,
|
|
18374
|
+
maxTsxNesting: typeof cast.maxTsxNesting === "number" ? cast.maxTsxNesting : defaults.maxTsxNesting,
|
|
18375
|
+
stateHooks: Array.isArray(cast.stateHooks) ? cast.stateHooks : defaults.stateHooks,
|
|
18376
|
+
targetLines: typeof cast.targetLines === "number" ? cast.targetLines : defaults.targetLines
|
|
18377
|
+
};
|
|
18378
|
+
}
|
|
18379
|
+
var noGodComponents = {
|
|
18380
|
+
create(context) {
|
|
18381
|
+
const configuration = parseOptions(context.options[0]);
|
|
18382
|
+
const ignoreSet = new Set(configuration.ignoreComponents);
|
|
18383
|
+
const stateHooks = new Set(configuration.stateHooks);
|
|
18384
|
+
const checked = new WeakSet;
|
|
18385
|
+
const sourceCode = context.sourceCode;
|
|
18386
|
+
function checkComponent(node, name) {
|
|
18387
|
+
if (ignoreSet.has(name))
|
|
18388
|
+
return;
|
|
18389
|
+
if (checked.has(node))
|
|
18390
|
+
return;
|
|
18391
|
+
checked.add(node);
|
|
18392
|
+
const location = node.loc;
|
|
18393
|
+
if (location !== null && location !== undefined) {
|
|
18394
|
+
const lines = location.end.line - location.start.line + 1;
|
|
18395
|
+
if (lines > configuration.maxLines) {
|
|
18396
|
+
context.report({
|
|
18397
|
+
data: { lines, max: configuration.maxLines, name, target: configuration.targetLines },
|
|
18398
|
+
messageId: "exceedsMaxLines",
|
|
18399
|
+
node
|
|
18400
|
+
});
|
|
18401
|
+
} else if (configuration.enforceTargetLines && lines > configuration.targetLines) {
|
|
18402
|
+
context.report({
|
|
18403
|
+
data: { lines, max: configuration.maxLines, name, target: configuration.targetLines },
|
|
18404
|
+
messageId: "exceedsTargetLines",
|
|
18405
|
+
node
|
|
18406
|
+
});
|
|
18407
|
+
}
|
|
18408
|
+
}
|
|
18409
|
+
const propsCount = countDestructuredProps(node);
|
|
18410
|
+
if (typeof propsCount === "number" && propsCount > configuration.maxDestructuredProps) {
|
|
18411
|
+
context.report({
|
|
18412
|
+
data: { count: propsCount, max: configuration.maxDestructuredProps, name },
|
|
18413
|
+
messageId: "tooManyProps",
|
|
18414
|
+
node
|
|
18415
|
+
});
|
|
18416
|
+
}
|
|
18417
|
+
const analysis = analyzeComponentBody(node, sourceCode, stateHooks);
|
|
18418
|
+
if (analysis.maxJsxDepth > configuration.maxTsxNesting) {
|
|
18419
|
+
context.report({
|
|
18420
|
+
data: { depth: analysis.maxJsxDepth, max: configuration.maxTsxNesting, name },
|
|
18421
|
+
messageId: "tsxNestingTooDeep",
|
|
18422
|
+
node
|
|
18423
|
+
});
|
|
18424
|
+
}
|
|
18425
|
+
if (analysis.stateHookCount > configuration.maxStateHooks) {
|
|
18426
|
+
context.report({
|
|
18427
|
+
data: {
|
|
18428
|
+
count: analysis.stateHookCount,
|
|
18429
|
+
hooks: configuration.stateHooks.join(", "),
|
|
18430
|
+
max: configuration.maxStateHooks,
|
|
18431
|
+
name
|
|
18432
|
+
},
|
|
18433
|
+
messageId: "tooManyStateHooks",
|
|
18434
|
+
node
|
|
18435
|
+
});
|
|
18436
|
+
}
|
|
18437
|
+
for (const literal2 of analysis.nullLiterals) {
|
|
18438
|
+
context.report({
|
|
18439
|
+
messageId: "nullLiteral",
|
|
18440
|
+
node: literal2
|
|
18441
|
+
});
|
|
18442
|
+
}
|
|
18443
|
+
}
|
|
18444
|
+
function maybeCheckFunction(node) {
|
|
18445
|
+
const name = getComponentNameFromFunction(node);
|
|
18446
|
+
if (typeof name !== "string" || name.length === 0)
|
|
18447
|
+
return;
|
|
18448
|
+
checkComponent(node, name);
|
|
18449
|
+
}
|
|
18450
|
+
return {
|
|
18451
|
+
FunctionDeclaration(node) {
|
|
18452
|
+
maybeCheckFunction(node);
|
|
18453
|
+
},
|
|
18454
|
+
FunctionExpression(node) {
|
|
18455
|
+
maybeCheckFunction(node);
|
|
18456
|
+
},
|
|
18457
|
+
ArrowFunctionExpression(node) {
|
|
18458
|
+
maybeCheckFunction(node);
|
|
18459
|
+
},
|
|
18460
|
+
CallExpression(node) {
|
|
18461
|
+
const callExpr = node;
|
|
18462
|
+
if (!isReactComponentHOC(callExpr))
|
|
18463
|
+
return;
|
|
18464
|
+
const firstArg = callExpr.arguments[0];
|
|
18465
|
+
if (!firstArg || firstArg.type !== TSESTree6.AST_NODE_TYPES.FunctionExpression && firstArg.type !== TSESTree6.AST_NODE_TYPES.ArrowFunctionExpression)
|
|
18466
|
+
return;
|
|
18467
|
+
const nameFromParent = getComponentNameFromCallParent(callExpr);
|
|
18468
|
+
const nameFromArg = getComponentNameFromFunction(firstArg);
|
|
18469
|
+
const name = nameFromParent ?? nameFromArg;
|
|
18470
|
+
if (typeof name !== "string" || name.length === 0)
|
|
18471
|
+
return;
|
|
18472
|
+
checkComponent(firstArg, name);
|
|
18473
|
+
}
|
|
18474
|
+
};
|
|
18475
|
+
},
|
|
18476
|
+
meta: {
|
|
18477
|
+
docs: {
|
|
18478
|
+
description: "Enforce React component size and complexity limits inspired by the 'Refactor God Component' checklist.",
|
|
18479
|
+
recommended: false
|
|
18480
|
+
},
|
|
18481
|
+
messages: {
|
|
18482
|
+
exceedsTargetLines: "Component '{{name}}' is {{lines}} lines; target is {{target}} (max {{max}}). Consider extracting hooks/components.",
|
|
18483
|
+
exceedsMaxLines: "Component '{{name}}' is {{lines}} lines; max allowed is {{max}}. Split into smaller components/hooks.",
|
|
18484
|
+
tsxNestingTooDeep: "Component '{{name}}' has TSX nesting depth {{depth}}; max allowed is {{max}}. Extract child components.",
|
|
18485
|
+
tooManyStateHooks: "Component '{{name}}' has {{count}} state hooks ({{hooks}}); max allowed is {{max}}. Extract cohesive state into a custom hook.",
|
|
18486
|
+
tooManyProps: "Component '{{name}}' destructures {{count}} props; max allowed is {{max}}. Group props or split the component.",
|
|
18487
|
+
nullLiteral: "Avoid `null` in components; use `undefined` instead."
|
|
18488
|
+
},
|
|
18489
|
+
schema: [
|
|
18490
|
+
{
|
|
18491
|
+
additionalProperties: false,
|
|
18492
|
+
properties: {
|
|
18493
|
+
enforceTargetLines: {
|
|
18494
|
+
default: true,
|
|
18495
|
+
description: "Whether to report when exceeding targetLines (soft limit).",
|
|
18496
|
+
type: "boolean"
|
|
18497
|
+
},
|
|
18498
|
+
ignoreComponents: {
|
|
18499
|
+
description: "Component names to ignore.",
|
|
18500
|
+
items: { type: "string" },
|
|
18501
|
+
type: "array"
|
|
18502
|
+
},
|
|
18503
|
+
maxDestructuredProps: {
|
|
18504
|
+
default: 5,
|
|
18505
|
+
description: "Maximum number of destructured props in a component parameter.",
|
|
18506
|
+
type: "number"
|
|
18507
|
+
},
|
|
18508
|
+
maxLines: {
|
|
18509
|
+
default: 200,
|
|
18510
|
+
description: "Hard maximum lines for a component.",
|
|
18511
|
+
type: "number"
|
|
18512
|
+
},
|
|
18513
|
+
maxStateHooks: {
|
|
18514
|
+
default: 5,
|
|
18515
|
+
description: "Maximum number of stateful hook calls in a component.",
|
|
18516
|
+
type: "number"
|
|
18517
|
+
},
|
|
18518
|
+
maxTsxNesting: {
|
|
18519
|
+
default: 3,
|
|
18520
|
+
description: "Maximum JSX/TSX nesting depth in a component.",
|
|
18521
|
+
type: "number"
|
|
18522
|
+
},
|
|
18523
|
+
stateHooks: {
|
|
18524
|
+
default: ["useState", "useReducer", "useBinding"],
|
|
18525
|
+
description: "Hook names to count toward state complexity.",
|
|
18526
|
+
items: { type: "string" },
|
|
18527
|
+
type: "array"
|
|
18528
|
+
},
|
|
18529
|
+
targetLines: {
|
|
18530
|
+
default: 120,
|
|
18531
|
+
description: "Soft target lines for a component.",
|
|
18532
|
+
type: "number"
|
|
18533
|
+
}
|
|
18534
|
+
},
|
|
18535
|
+
type: "object"
|
|
18536
|
+
}
|
|
18537
|
+
],
|
|
18538
|
+
type: "problem"
|
|
18539
|
+
}
|
|
18540
|
+
};
|
|
18541
|
+
var no_god_components_default = noGodComponents;
|
|
18542
|
+
|
|
18069
18543
|
// src/rules/prefer-sequence-overloads.ts
|
|
18070
18544
|
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/types";
|
|
18071
18545
|
var sequenceDescriptors = [
|
|
@@ -18173,11 +18647,11 @@ var preferSequenceOverloads = {
|
|
|
18173
18647
|
var prefer_sequence_overloads_default = preferSequenceOverloads;
|
|
18174
18648
|
|
|
18175
18649
|
// src/rules/prefer-udim2-shorthand.ts
|
|
18176
|
-
import { TSESTree as
|
|
18650
|
+
import { TSESTree as TSESTree7 } from "@typescript-eslint/utils";
|
|
18177
18651
|
function isNumber(value) {
|
|
18178
18652
|
return typeof value === "number" && !Number.isNaN(value);
|
|
18179
18653
|
}
|
|
18180
|
-
function
|
|
18654
|
+
function isRecord3(node) {
|
|
18181
18655
|
return typeof node === "object" && node !== null;
|
|
18182
18656
|
}
|
|
18183
18657
|
function hasTypeProperty(object3) {
|
|
@@ -18186,30 +18660,30 @@ function hasTypeProperty(object3) {
|
|
|
18186
18660
|
var OPERATORS2 = new Set(["+", "-", "*", "/", "%"]);
|
|
18187
18661
|
function reconstructText(node) {
|
|
18188
18662
|
const nodeType = node.type;
|
|
18189
|
-
if (nodeType ===
|
|
18663
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.Literal) {
|
|
18190
18664
|
const { value } = node;
|
|
18191
18665
|
return isNumber(value) ? String(value) : undefined;
|
|
18192
18666
|
}
|
|
18193
|
-
if (nodeType ===
|
|
18667
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.Identifier) {
|
|
18194
18668
|
const { name } = node;
|
|
18195
18669
|
return typeof name === "string" ? name : undefined;
|
|
18196
18670
|
}
|
|
18197
|
-
if (nodeType ===
|
|
18671
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.UnaryExpression) {
|
|
18198
18672
|
const { operator } = node;
|
|
18199
18673
|
if (typeof operator !== "string")
|
|
18200
18674
|
return;
|
|
18201
18675
|
const { argument } = node;
|
|
18202
|
-
if (!
|
|
18676
|
+
if (!isRecord3(argument))
|
|
18203
18677
|
return;
|
|
18204
18678
|
const text = reconstructText(argument);
|
|
18205
18679
|
return text === undefined ? undefined : `${operator}${text}`;
|
|
18206
18680
|
}
|
|
18207
|
-
if (nodeType ===
|
|
18681
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.BinaryExpression) {
|
|
18208
18682
|
const { operator } = node;
|
|
18209
18683
|
if (typeof operator !== "string" || !OPERATORS2.has(operator))
|
|
18210
18684
|
return;
|
|
18211
18685
|
const { left, right } = node;
|
|
18212
|
-
if (!
|
|
18686
|
+
if (!isRecord3(left) || !isRecord3(right))
|
|
18213
18687
|
return;
|
|
18214
18688
|
const leftText = reconstructText(left);
|
|
18215
18689
|
const rightText = reconstructText(right);
|
|
@@ -18218,14 +18692,14 @@ function reconstructText(node) {
|
|
|
18218
18692
|
return;
|
|
18219
18693
|
}
|
|
18220
18694
|
function evaluateExpression(node) {
|
|
18221
|
-
if (!
|
|
18695
|
+
if (!isRecord3(node))
|
|
18222
18696
|
return;
|
|
18223
18697
|
const nodeType = node.type;
|
|
18224
|
-
if (nodeType ===
|
|
18698
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.Literal) {
|
|
18225
18699
|
const { value } = node;
|
|
18226
18700
|
return isNumber(value) ? value : undefined;
|
|
18227
18701
|
}
|
|
18228
|
-
if (nodeType ===
|
|
18702
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.UnaryExpression) {
|
|
18229
18703
|
const { argument, operator } = node;
|
|
18230
18704
|
if (typeof argument === "object" && argument !== null) {
|
|
18231
18705
|
const value = evaluateExpression(argument);
|
|
@@ -18238,7 +18712,7 @@ function evaluateExpression(node) {
|
|
|
18238
18712
|
}
|
|
18239
18713
|
return;
|
|
18240
18714
|
}
|
|
18241
|
-
if (nodeType ===
|
|
18715
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.BinaryExpression) {
|
|
18242
18716
|
const { right, left, operator } = node;
|
|
18243
18717
|
if (typeof left === "object" && left !== null && typeof right === "object" && right !== null) {
|
|
18244
18718
|
const leftValue = evaluateExpression(left);
|
|
@@ -18270,9 +18744,9 @@ function collectArguments(_context2, parameters3) {
|
|
|
18270
18744
|
const texts = [undefined, undefined, undefined, undefined];
|
|
18271
18745
|
for (let index2 = 0;index2 < 4; index2++) {
|
|
18272
18746
|
const parameter2 = parameters3[index2];
|
|
18273
|
-
if (!
|
|
18747
|
+
if (!isRecord3(parameter2) || !hasTypeProperty(parameter2))
|
|
18274
18748
|
return;
|
|
18275
|
-
if (parameter2.type ===
|
|
18749
|
+
if (parameter2.type === TSESTree7.AST_NODE_TYPES.SpreadElement)
|
|
18276
18750
|
return;
|
|
18277
18751
|
const text = reconstructText(parameter2);
|
|
18278
18752
|
if (text === undefined)
|
|
@@ -18288,7 +18762,7 @@ var preferUDim2Shorthand = {
|
|
|
18288
18762
|
create(context) {
|
|
18289
18763
|
return {
|
|
18290
18764
|
NewExpression(node) {
|
|
18291
|
-
if (node.callee.type !==
|
|
18765
|
+
if (node.callee.type !== TSESTree7.AST_NODE_TYPES.Identifier || node.callee.name !== "UDim2")
|
|
18292
18766
|
return;
|
|
18293
18767
|
const collected = collectArguments(context, node.arguments);
|
|
18294
18768
|
if (!collected)
|
|
@@ -18335,7 +18809,7 @@ var preferUDim2Shorthand = {
|
|
|
18335
18809
|
var prefer_udim2_shorthand_default = preferUDim2Shorthand;
|
|
18336
18810
|
|
|
18337
18811
|
// src/rules/require-named-effect-functions.ts
|
|
18338
|
-
import { TSESTree as
|
|
18812
|
+
import { TSESTree as TSESTree8 } from "@typescript-eslint/types";
|
|
18339
18813
|
var DEFAULT_HOOKS = [
|
|
18340
18814
|
{ allowAsync: false, name: "useEffect" },
|
|
18341
18815
|
{ allowAsync: false, name: "useLayoutEffect" },
|
|
@@ -18350,7 +18824,7 @@ var isRuleOptions2 = Compile(build_default.Object({
|
|
|
18350
18824
|
environment: isEnvironmentMode,
|
|
18351
18825
|
hooks: build_default.Array(isHookConfiguration)
|
|
18352
18826
|
}, { additionalProperties: true }));
|
|
18353
|
-
function
|
|
18827
|
+
function parseOptions2(options3) {
|
|
18354
18828
|
if (options3 === undefined) {
|
|
18355
18829
|
return {
|
|
18356
18830
|
environment: "roblox-ts",
|
|
@@ -18368,11 +18842,11 @@ function parseOptions(options3) {
|
|
|
18368
18842
|
hooks: options3.hooks
|
|
18369
18843
|
};
|
|
18370
18844
|
}
|
|
18371
|
-
function
|
|
18845
|
+
function getHookName2(callExpression) {
|
|
18372
18846
|
const { callee } = callExpression;
|
|
18373
|
-
if (callee.type ===
|
|
18847
|
+
if (callee.type === TSESTree8.AST_NODE_TYPES.Identifier && typeof callee.name === "string" && callee.name.length > 0)
|
|
18374
18848
|
return callee.name;
|
|
18375
|
-
if (callee.type ===
|
|
18849
|
+
if (callee.type === TSESTree8.AST_NODE_TYPES.MemberExpression && callee.property?.type === TSESTree8.AST_NODE_TYPES.Identifier && typeof callee.property.name === "string" && callee.property.name.length > 0)
|
|
18376
18850
|
return callee.property.name;
|
|
18377
18851
|
return;
|
|
18378
18852
|
}
|
|
@@ -18407,16 +18881,16 @@ function resolveIdentifierToFunction(identifier3, context) {
|
|
|
18407
18881
|
if (typeof node !== "object" || node === null)
|
|
18408
18882
|
continue;
|
|
18409
18883
|
const castNode = node;
|
|
18410
|
-
if (castNode.type ===
|
|
18884
|
+
if (castNode.type === TSESTree8.AST_NODE_TYPES.FunctionDeclaration) {
|
|
18411
18885
|
return {
|
|
18412
18886
|
isAsync: Boolean(castNode.async),
|
|
18413
18887
|
node,
|
|
18414
18888
|
type: "function-declaration"
|
|
18415
18889
|
};
|
|
18416
18890
|
}
|
|
18417
|
-
if (castNode.type ===
|
|
18891
|
+
if (castNode.type === TSESTree8.AST_NODE_TYPES.VariableDeclarator && typeof castNode.init === "object" && castNode.init !== null) {
|
|
18418
18892
|
const castInit = castNode.init;
|
|
18419
|
-
if (castInit.type ===
|
|
18893
|
+
if (castInit.type === TSESTree8.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
18420
18894
|
const arrowNode = castNode.init;
|
|
18421
18895
|
return {
|
|
18422
18896
|
isAsync: Boolean(arrowNode.async),
|
|
@@ -18424,7 +18898,7 @@ function resolveIdentifierToFunction(identifier3, context) {
|
|
|
18424
18898
|
type: "arrow"
|
|
18425
18899
|
};
|
|
18426
18900
|
}
|
|
18427
|
-
if (castInit.type ===
|
|
18901
|
+
if (castInit.type === TSESTree8.AST_NODE_TYPES.FunctionExpression) {
|
|
18428
18902
|
const castInitNode = castNode.init;
|
|
18429
18903
|
return {
|
|
18430
18904
|
isAsync: Boolean(castInitNode.async),
|
|
@@ -18470,14 +18944,14 @@ function isCallbackHookResult(identifier3, context) {
|
|
|
18470
18944
|
if (typeof node !== "object" || node === null)
|
|
18471
18945
|
continue;
|
|
18472
18946
|
const castNode = node;
|
|
18473
|
-
if (castNode.type !==
|
|
18947
|
+
if (castNode.type !== TSESTree8.AST_NODE_TYPES.VariableDeclarator)
|
|
18474
18948
|
continue;
|
|
18475
18949
|
if (typeof castNode.init !== "object" || castNode.init === null)
|
|
18476
18950
|
continue;
|
|
18477
18951
|
const init = castNode.init;
|
|
18478
|
-
if (init.type !==
|
|
18952
|
+
if (init.type !== TSESTree8.AST_NODE_TYPES.CallExpression)
|
|
18479
18953
|
continue;
|
|
18480
|
-
const calleeHookName =
|
|
18954
|
+
const calleeHookName = getHookName2(init);
|
|
18481
18955
|
if (calleeHookName === "useCallback" || calleeHookName === "useMemo")
|
|
18482
18956
|
return true;
|
|
18483
18957
|
}
|
|
@@ -18488,7 +18962,7 @@ function isCallbackHookResult(identifier3, context) {
|
|
|
18488
18962
|
}
|
|
18489
18963
|
var requireNamedEffectFunctions = {
|
|
18490
18964
|
create(context) {
|
|
18491
|
-
const { hooks, environment: environment2 } =
|
|
18965
|
+
const { hooks, environment: environment2 } = parseOptions2(context.options[0]);
|
|
18492
18966
|
const hookAsyncConfig = new Map(hooks.map((hookConfig) => [hookConfig.name, hookConfig.allowAsync]));
|
|
18493
18967
|
const effectHooks = new Set(hookAsyncConfig.keys());
|
|
18494
18968
|
const isRobloxTsMode = environment2 === "roblox-ts";
|
|
@@ -18499,14 +18973,14 @@ var requireNamedEffectFunctions = {
|
|
|
18499
18973
|
return {
|
|
18500
18974
|
CallExpression(node) {
|
|
18501
18975
|
const callExpression = node;
|
|
18502
|
-
const hookName =
|
|
18976
|
+
const hookName = getHookName2(callExpression);
|
|
18503
18977
|
if (typeof hookName !== "string" || !effectHooks.has(hookName))
|
|
18504
18978
|
return;
|
|
18505
18979
|
const firstArgument = callExpression.arguments?.[0];
|
|
18506
18980
|
if (firstArgument === undefined)
|
|
18507
18981
|
return;
|
|
18508
18982
|
const argumentNode = firstArgument;
|
|
18509
|
-
if (argumentNode.type ===
|
|
18983
|
+
if (argumentNode.type === TSESTree8.AST_NODE_TYPES.Identifier) {
|
|
18510
18984
|
const identifier3 = argumentNode;
|
|
18511
18985
|
const resolved = resolveIdentifierToFunction(identifier3, context);
|
|
18512
18986
|
if (resolved === undefined) {
|
|
@@ -18559,7 +19033,7 @@ var requireNamedEffectFunctions = {
|
|
|
18559
19033
|
}
|
|
18560
19034
|
return;
|
|
18561
19035
|
}
|
|
18562
|
-
if (argumentNode.type ===
|
|
19036
|
+
if (argumentNode.type === TSESTree8.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
18563
19037
|
if (argumentNode.async) {
|
|
18564
19038
|
context.report({
|
|
18565
19039
|
data: { hook: hookName },
|
|
@@ -18575,7 +19049,7 @@ var requireNamedEffectFunctions = {
|
|
|
18575
19049
|
}
|
|
18576
19050
|
return;
|
|
18577
19051
|
}
|
|
18578
|
-
if (argumentNode.type ===
|
|
19052
|
+
if (argumentNode.type === TSESTree8.AST_NODE_TYPES.FunctionExpression) {
|
|
18579
19053
|
const functionExpressionNode = argumentNode;
|
|
18580
19054
|
const functionHasId = Boolean(functionExpressionNode.id);
|
|
18581
19055
|
if (functionHasId && argumentNode.async) {
|
|
@@ -18603,7 +19077,6 @@ var requireNamedEffectFunctions = {
|
|
|
18603
19077
|
node
|
|
18604
19078
|
});
|
|
18605
19079
|
}
|
|
18606
|
-
return;
|
|
18607
19080
|
}
|
|
18608
19081
|
}
|
|
18609
19082
|
};
|
|
@@ -19476,7 +19949,7 @@ var rule = {
|
|
|
19476
19949
|
var require_paired_calls_default = rule;
|
|
19477
19950
|
|
|
19478
19951
|
// src/rules/require-react-component-keys.ts
|
|
19479
|
-
import { TSESTree as
|
|
19952
|
+
import { TSESTree as TSESTree9 } from "@typescript-eslint/types";
|
|
19480
19953
|
var DEFAULT_OPTIONS3 = {
|
|
19481
19954
|
allowRootKeys: false,
|
|
19482
19955
|
ignoreCallExpressions: ["ReactTree.mount", "CreateReactStory"],
|
|
@@ -19519,22 +19992,22 @@ function ascendPastWrappers(node) {
|
|
|
19519
19992
|
}
|
|
19520
19993
|
function hasKeyAttribute(node) {
|
|
19521
19994
|
for (const attribute of node.openingElement.attributes)
|
|
19522
|
-
if (attribute.type ===
|
|
19995
|
+
if (attribute.type === TSESTree9.AST_NODE_TYPES.JSXAttribute && attribute.name.name === "key")
|
|
19523
19996
|
return true;
|
|
19524
19997
|
return false;
|
|
19525
19998
|
}
|
|
19526
|
-
function
|
|
19999
|
+
function isReactComponentHOC2(callExpr) {
|
|
19527
20000
|
const { callee } = callExpr;
|
|
19528
|
-
if (callee.type ===
|
|
20001
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier)
|
|
19529
20002
|
return callee.name === "forwardRef" || callee.name === "memo";
|
|
19530
|
-
if (callee.type ===
|
|
20003
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree9.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === TSESTree9.AST_NODE_TYPES.Identifier)
|
|
19531
20004
|
return callee.property.name === "forwardRef" || callee.property.name === "memo";
|
|
19532
20005
|
return false;
|
|
19533
20006
|
}
|
|
19534
20007
|
function getEnclosingFunctionLike(node) {
|
|
19535
20008
|
let current = node.parent;
|
|
19536
20009
|
while (current) {
|
|
19537
|
-
if (current.type ===
|
|
20010
|
+
if (current.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression || current.type === TSESTree9.AST_NODE_TYPES.FunctionExpression || current.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration)
|
|
19538
20011
|
return current;
|
|
19539
20012
|
current = current.parent;
|
|
19540
20013
|
}
|
|
@@ -19542,15 +20015,15 @@ function getEnclosingFunctionLike(node) {
|
|
|
19542
20015
|
}
|
|
19543
20016
|
function isIterationOrMemoCallback(callExpr, iterationMethods, memoizationHooks) {
|
|
19544
20017
|
const { callee } = callExpr;
|
|
19545
|
-
if (callee.type ===
|
|
20018
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier && memoizationHooks.has(callee.name))
|
|
19546
20019
|
return true;
|
|
19547
|
-
if (callee.type ===
|
|
20020
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree9.AST_NODE_TYPES.Identifier) {
|
|
19548
20021
|
const methodName = callee.property.name;
|
|
19549
20022
|
if (iterationMethods.has(methodName))
|
|
19550
20023
|
return true;
|
|
19551
|
-
if (methodName === "from" && callee.object.type ===
|
|
20024
|
+
if (methodName === "from" && callee.object.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.object.object.type === TSESTree9.AST_NODE_TYPES.Identifier && callee.object.object.name === "Array" && callExpr.arguments.length >= 2)
|
|
19552
20025
|
return true;
|
|
19553
|
-
if (methodName === "call" && callee.object.type ===
|
|
20026
|
+
if (methodName === "call" && callee.object.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.object.object.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.object.object.property.type === TSESTree9.AST_NODE_TYPES.Identifier && iterationMethods.has(callee.object.object.property.name))
|
|
19554
20027
|
return true;
|
|
19555
20028
|
}
|
|
19556
20029
|
return false;
|
|
@@ -19559,11 +20032,11 @@ function findEnclosingCallExpression(node) {
|
|
|
19559
20032
|
let current = node;
|
|
19560
20033
|
let { parent } = node;
|
|
19561
20034
|
while (parent) {
|
|
19562
|
-
if (parent.type ===
|
|
20035
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.CallExpression) {
|
|
19563
20036
|
for (const argument of parent.arguments) {
|
|
19564
20037
|
if (argument === current)
|
|
19565
20038
|
return parent;
|
|
19566
|
-
if (argument.type ===
|
|
20039
|
+
if (argument.type === TSESTree9.AST_NODE_TYPES.SpreadElement && argument.argument === current)
|
|
19567
20040
|
return parent;
|
|
19568
20041
|
}
|
|
19569
20042
|
return;
|
|
@@ -19578,7 +20051,7 @@ function findEnclosingCallExpression(node) {
|
|
|
19578
20051
|
return;
|
|
19579
20052
|
}
|
|
19580
20053
|
function getVariableForFunction(context, functionLike) {
|
|
19581
|
-
if (functionLike.type ===
|
|
20054
|
+
if (functionLike.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration) {
|
|
19582
20055
|
const declared = context.sourceCode.getDeclaredVariables(functionLike);
|
|
19583
20056
|
if (declared.length > 0)
|
|
19584
20057
|
return declared[0];
|
|
@@ -19587,7 +20060,7 @@ function getVariableForFunction(context, functionLike) {
|
|
|
19587
20060
|
const { parent } = functionLike;
|
|
19588
20061
|
if (!parent)
|
|
19589
20062
|
return;
|
|
19590
|
-
if (parent.type ===
|
|
20063
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.VariableDeclarator || parent.type === TSESTree9.AST_NODE_TYPES.AssignmentExpression) {
|
|
19591
20064
|
const declared = context.sourceCode.getDeclaredVariables(parent);
|
|
19592
20065
|
if (declared.length > 0)
|
|
19593
20066
|
return declared[0];
|
|
@@ -19600,14 +20073,14 @@ function referenceActsAsCallback(reference, iterationMethods, memoizationHooks)
|
|
|
19600
20073
|
const callExpression = findEnclosingCallExpression(reference.identifier);
|
|
19601
20074
|
if (!callExpression)
|
|
19602
20075
|
return false;
|
|
19603
|
-
if (
|
|
20076
|
+
if (isReactComponentHOC2(callExpression))
|
|
19604
20077
|
return false;
|
|
19605
20078
|
return isIterationOrMemoCallback(callExpression, iterationMethods, memoizationHooks);
|
|
19606
20079
|
}
|
|
19607
20080
|
function isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoizationHooks) {
|
|
19608
20081
|
const inlineCall = findEnclosingCallExpression(functionLike);
|
|
19609
20082
|
if (inlineCall) {
|
|
19610
|
-
if (
|
|
20083
|
+
if (isReactComponentHOC2(inlineCall))
|
|
19611
20084
|
return false;
|
|
19612
20085
|
return isIterationOrMemoCallback(inlineCall, iterationMethods, memoizationHooks);
|
|
19613
20086
|
}
|
|
@@ -19620,33 +20093,33 @@ function isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoi
|
|
|
19620
20093
|
return false;
|
|
19621
20094
|
}
|
|
19622
20095
|
var SHOULD_ASCEND_TYPES = new Set([
|
|
19623
|
-
|
|
19624
|
-
|
|
20096
|
+
TSESTree9.AST_NODE_TYPES.ConditionalExpression,
|
|
20097
|
+
TSESTree9.AST_NODE_TYPES.LogicalExpression
|
|
19625
20098
|
]);
|
|
19626
20099
|
var IS_FUNCTION_EXPRESSION = new Set([
|
|
19627
|
-
|
|
19628
|
-
|
|
20100
|
+
TSESTree9.AST_NODE_TYPES.FunctionExpression,
|
|
20101
|
+
TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression
|
|
19629
20102
|
]);
|
|
19630
20103
|
var CONTROL_FLOW_TYPES = new Set([
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
|
|
19634
|
-
|
|
19635
|
-
|
|
19636
|
-
|
|
19637
|
-
|
|
19638
|
-
|
|
19639
|
-
|
|
19640
|
-
|
|
19641
|
-
|
|
19642
|
-
|
|
19643
|
-
|
|
20104
|
+
TSESTree9.AST_NODE_TYPES.BlockStatement,
|
|
20105
|
+
TSESTree9.AST_NODE_TYPES.IfStatement,
|
|
20106
|
+
TSESTree9.AST_NODE_TYPES.SwitchStatement,
|
|
20107
|
+
TSESTree9.AST_NODE_TYPES.SwitchCase,
|
|
20108
|
+
TSESTree9.AST_NODE_TYPES.TryStatement,
|
|
20109
|
+
TSESTree9.AST_NODE_TYPES.CatchClause,
|
|
20110
|
+
TSESTree9.AST_NODE_TYPES.WhileStatement,
|
|
20111
|
+
TSESTree9.AST_NODE_TYPES.DoWhileStatement,
|
|
20112
|
+
TSESTree9.AST_NODE_TYPES.ForStatement,
|
|
20113
|
+
TSESTree9.AST_NODE_TYPES.ForInStatement,
|
|
20114
|
+
TSESTree9.AST_NODE_TYPES.ForOfStatement,
|
|
20115
|
+
TSESTree9.AST_NODE_TYPES.LabeledStatement,
|
|
20116
|
+
TSESTree9.AST_NODE_TYPES.WithStatement
|
|
19644
20117
|
]);
|
|
19645
20118
|
function isTopLevelReturn(node) {
|
|
19646
20119
|
let parent = ascendPastWrappers(node.parent);
|
|
19647
20120
|
if (!parent)
|
|
19648
20121
|
return false;
|
|
19649
|
-
if (parent.type ===
|
|
20122
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer)
|
|
19650
20123
|
parent = ascendPastWrappers(parent.parent);
|
|
19651
20124
|
if (!parent)
|
|
19652
20125
|
return false;
|
|
@@ -19654,11 +20127,11 @@ function isTopLevelReturn(node) {
|
|
|
19654
20127
|
parent = ascendPastWrappers(parent.parent);
|
|
19655
20128
|
if (!parent)
|
|
19656
20129
|
return false;
|
|
19657
|
-
if (parent.type ===
|
|
20130
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer)
|
|
19658
20131
|
parent = ascendPastWrappers(parent.parent);
|
|
19659
20132
|
if (!parent)
|
|
19660
20133
|
return false;
|
|
19661
|
-
if (parent.type ===
|
|
20134
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.ReturnStatement) {
|
|
19662
20135
|
let currentNode = ascendPastWrappers(parent.parent);
|
|
19663
20136
|
while (currentNode && CONTROL_FLOW_TYPES.has(currentNode.type))
|
|
19664
20137
|
currentNode = ascendPastWrappers(currentNode.parent);
|
|
@@ -19666,16 +20139,16 @@ function isTopLevelReturn(node) {
|
|
|
19666
20139
|
return false;
|
|
19667
20140
|
if (IS_FUNCTION_EXPRESSION.has(currentNode.type)) {
|
|
19668
20141
|
const functionParent = ascendPastWrappers(currentNode.parent);
|
|
19669
|
-
if (functionParent?.type ===
|
|
19670
|
-
return
|
|
20142
|
+
if (functionParent?.type === TSESTree9.AST_NODE_TYPES.CallExpression)
|
|
20143
|
+
return isReactComponentHOC2(functionParent);
|
|
19671
20144
|
return true;
|
|
19672
20145
|
}
|
|
19673
|
-
return currentNode.type ===
|
|
20146
|
+
return currentNode.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration;
|
|
19674
20147
|
}
|
|
19675
|
-
if (parent.type ===
|
|
20148
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
19676
20149
|
const functionParent = ascendPastWrappers(parent.parent);
|
|
19677
|
-
if (functionParent?.type ===
|
|
19678
|
-
return
|
|
20150
|
+
if (functionParent?.type === TSESTree9.AST_NODE_TYPES.CallExpression)
|
|
20151
|
+
return isReactComponentHOC2(functionParent);
|
|
19679
20152
|
return true;
|
|
19680
20153
|
}
|
|
19681
20154
|
return false;
|
|
@@ -19684,7 +20157,7 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
19684
20157
|
let parent = node.parent;
|
|
19685
20158
|
if (!parent)
|
|
19686
20159
|
return false;
|
|
19687
|
-
if (parent.type ===
|
|
20160
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
19688
20161
|
parent = parent.parent;
|
|
19689
20162
|
if (!parent)
|
|
19690
20163
|
return false;
|
|
@@ -19692,11 +20165,11 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
19692
20165
|
const maxDepth = 20;
|
|
19693
20166
|
for (let depth = 0;depth < maxDepth && parent; depth += 1) {
|
|
19694
20167
|
const { type: type3 } = parent;
|
|
19695
|
-
if (type3 ===
|
|
20168
|
+
if (type3 === TSESTree9.AST_NODE_TYPES.CallExpression) {
|
|
19696
20169
|
const { callee } = parent;
|
|
19697
|
-
if (callee.type ===
|
|
20170
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier)
|
|
19698
20171
|
return ignoreList.includes(callee.name);
|
|
19699
|
-
if (callee.type ===
|
|
20172
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree9.AST_NODE_TYPES.Identifier && callee.property.type === TSESTree9.AST_NODE_TYPES.Identifier)
|
|
19700
20173
|
return ignoreList.includes(`${callee.object.name}.${callee.property.name}`);
|
|
19701
20174
|
return false;
|
|
19702
20175
|
}
|
|
@@ -19708,35 +20181,35 @@ function isJSXPropValue(node) {
|
|
|
19708
20181
|
let { parent } = node;
|
|
19709
20182
|
if (!parent)
|
|
19710
20183
|
return false;
|
|
19711
|
-
while (parent && (parent.type ===
|
|
20184
|
+
while (parent && (parent.type === TSESTree9.AST_NODE_TYPES.ConditionalExpression || parent.type === TSESTree9.AST_NODE_TYPES.LogicalExpression))
|
|
19712
20185
|
parent = parent.parent;
|
|
19713
20186
|
if (!parent)
|
|
19714
20187
|
return false;
|
|
19715
|
-
if (parent.type ===
|
|
20188
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
19716
20189
|
parent = parent.parent;
|
|
19717
20190
|
if (!parent)
|
|
19718
20191
|
return false;
|
|
19719
20192
|
}
|
|
19720
|
-
return parent.type ===
|
|
20193
|
+
return parent.type === TSESTree9.AST_NODE_TYPES.JSXAttribute;
|
|
19721
20194
|
}
|
|
19722
20195
|
function isTernaryJSXChild(node) {
|
|
19723
20196
|
let current = node.parent;
|
|
19724
20197
|
if (!current)
|
|
19725
20198
|
return false;
|
|
19726
20199
|
let foundTernary = false;
|
|
19727
|
-
while (current && (current.type ===
|
|
19728
|
-
if (current.type ===
|
|
20200
|
+
while (current && (current.type === TSESTree9.AST_NODE_TYPES.ConditionalExpression || WRAPPER_PARENT_TYPES.has(current.type))) {
|
|
20201
|
+
if (current.type === TSESTree9.AST_NODE_TYPES.ConditionalExpression)
|
|
19729
20202
|
foundTernary = true;
|
|
19730
20203
|
current = current.parent;
|
|
19731
20204
|
}
|
|
19732
20205
|
if (!foundTernary || !current)
|
|
19733
20206
|
return false;
|
|
19734
|
-
if (current.type !==
|
|
20207
|
+
if (current.type !== TSESTree9.AST_NODE_TYPES.JSXExpressionContainer)
|
|
19735
20208
|
return false;
|
|
19736
20209
|
const containerParent = current.parent;
|
|
19737
20210
|
if (!containerParent)
|
|
19738
20211
|
return false;
|
|
19739
|
-
return containerParent.type ===
|
|
20212
|
+
return containerParent.type === TSESTree9.AST_NODE_TYPES.JSXElement || containerParent.type === TSESTree9.AST_NODE_TYPES.JSXFragment;
|
|
19740
20213
|
}
|
|
19741
20214
|
var docs3 = {
|
|
19742
20215
|
description: "Enforce key props on all React elements except top-level returns",
|
|
@@ -19755,7 +20228,7 @@ var requireReactComponentKeys = {
|
|
|
19755
20228
|
const isCallback = functionLike ? isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoizationHooks) : false;
|
|
19756
20229
|
const isRoot = isTopLevelReturn(node);
|
|
19757
20230
|
if (isRoot && !isCallback) {
|
|
19758
|
-
if (!options3.allowRootKeys && node.type ===
|
|
20231
|
+
if (!options3.allowRootKeys && node.type === TSESTree9.AST_NODE_TYPES.JSXElement && hasKeyAttribute(node)) {
|
|
19759
20232
|
context.report({
|
|
19760
20233
|
messageId: "rootComponentWithKey",
|
|
19761
20234
|
node
|
|
@@ -19769,7 +20242,7 @@ var requireReactComponentKeys = {
|
|
|
19769
20242
|
return;
|
|
19770
20243
|
if (isTernaryJSXChild(node))
|
|
19771
20244
|
return;
|
|
19772
|
-
if (node.type ===
|
|
20245
|
+
if (node.type === TSESTree9.AST_NODE_TYPES.JSXFragment) {
|
|
19773
20246
|
context.report({
|
|
19774
20247
|
messageId: "missingKey",
|
|
19775
20248
|
node
|
|
@@ -19847,16 +20320,16 @@ var requireReactComponentKeys = {
|
|
|
19847
20320
|
var require_react_component_keys_default = requireReactComponentKeys;
|
|
19848
20321
|
|
|
19849
20322
|
// src/rules/use-exhaustive-dependencies.ts
|
|
19850
|
-
import { TSESTree as
|
|
20323
|
+
import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
|
|
19851
20324
|
var FUNCTION_DECLARATIONS = new Set([
|
|
19852
|
-
|
|
19853
|
-
|
|
19854
|
-
|
|
20325
|
+
TSESTree10.AST_NODE_TYPES.FunctionExpression,
|
|
20326
|
+
TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
20327
|
+
TSESTree10.AST_NODE_TYPES.FunctionDeclaration
|
|
19855
20328
|
]);
|
|
19856
20329
|
var UNSTABLE_VALUES = new Set([
|
|
19857
20330
|
...FUNCTION_DECLARATIONS,
|
|
19858
|
-
|
|
19859
|
-
|
|
20331
|
+
TSESTree10.AST_NODE_TYPES.ObjectExpression,
|
|
20332
|
+
TSESTree10.AST_NODE_TYPES.ArrayExpression
|
|
19860
20333
|
]);
|
|
19861
20334
|
var testingMetrics = {
|
|
19862
20335
|
moduleLevelStableConst: 0,
|
|
@@ -19938,11 +20411,11 @@ var GLOBAL_BUILTINS = new Set([
|
|
|
19938
20411
|
"Window",
|
|
19939
20412
|
"Event"
|
|
19940
20413
|
]);
|
|
19941
|
-
function
|
|
20414
|
+
function getHookName3(node) {
|
|
19942
20415
|
const { callee } = node;
|
|
19943
|
-
if (callee.type ===
|
|
20416
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier)
|
|
19944
20417
|
return callee.name;
|
|
19945
|
-
if (callee.type ===
|
|
20418
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
19946
20419
|
return callee.property.name;
|
|
19947
20420
|
}
|
|
19948
20421
|
return;
|
|
@@ -19950,9 +20423,9 @@ function getHookName2(node) {
|
|
|
19950
20423
|
function getMemberExpressionDepth(node) {
|
|
19951
20424
|
let depth = 0;
|
|
19952
20425
|
let current = node;
|
|
19953
|
-
if (current.type ===
|
|
20426
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ChainExpression)
|
|
19954
20427
|
current = current.expression;
|
|
19955
|
-
while (current.type ===
|
|
20428
|
+
while (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression) {
|
|
19956
20429
|
depth += 1;
|
|
19957
20430
|
current = current.object;
|
|
19958
20431
|
}
|
|
@@ -19960,36 +20433,36 @@ function getMemberExpressionDepth(node) {
|
|
|
19960
20433
|
}
|
|
19961
20434
|
function getRootIdentifier(node) {
|
|
19962
20435
|
let current = node;
|
|
19963
|
-
if (current.type ===
|
|
20436
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ChainExpression)
|
|
19964
20437
|
current = current.expression;
|
|
19965
|
-
while (current.type ===
|
|
19966
|
-
if (current.type ===
|
|
20438
|
+
while (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression || current.type === TSESTree10.AST_NODE_TYPES.TSNonNullExpression) {
|
|
20439
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression)
|
|
19967
20440
|
current = current.object;
|
|
19968
20441
|
else
|
|
19969
20442
|
current = current.expression;
|
|
19970
20443
|
}
|
|
19971
|
-
return current.type ===
|
|
20444
|
+
return current.type === TSESTree10.AST_NODE_TYPES.Identifier ? current : undefined;
|
|
19972
20445
|
}
|
|
19973
20446
|
function nodeToDependencyString(node, sourceCode) {
|
|
19974
20447
|
return sourceCode.getText(node);
|
|
19975
20448
|
}
|
|
19976
20449
|
function nodeToSafeDependencyPath(node, sourceCode) {
|
|
19977
|
-
if (node.type ===
|
|
20450
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.Identifier)
|
|
19978
20451
|
return node.name;
|
|
19979
|
-
if (node.type ===
|
|
20452
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.ChainExpression) {
|
|
19980
20453
|
return nodeToSafeDependencyPath(node.expression, sourceCode);
|
|
19981
20454
|
}
|
|
19982
20455
|
if (TS_RUNTIME_EXPRESSIONS.has(node.type)) {
|
|
19983
20456
|
const expr = node;
|
|
19984
20457
|
return nodeToSafeDependencyPath(expr.expression, sourceCode);
|
|
19985
20458
|
}
|
|
19986
|
-
if (node.type ===
|
|
20459
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.MemberExpression) {
|
|
19987
20460
|
const objectPath = nodeToSafeDependencyPath(node.object, sourceCode);
|
|
19988
20461
|
if (node.computed) {
|
|
19989
20462
|
const propertyText = sourceCode.getText(node.property);
|
|
19990
20463
|
return `${objectPath}[${propertyText}]`;
|
|
19991
20464
|
}
|
|
19992
|
-
const propertyName = node.property.type ===
|
|
20465
|
+
const propertyName = node.property.type === TSESTree10.AST_NODE_TYPES.Identifier ? node.property.name : "";
|
|
19993
20466
|
const separator = node.optional ? "?." : ".";
|
|
19994
20467
|
return `${objectPath}${separator}${propertyName}`;
|
|
19995
20468
|
}
|
|
@@ -19998,13 +20471,13 @@ function nodeToSafeDependencyPath(node, sourceCode) {
|
|
|
19998
20471
|
function isStableArrayIndex(stableResult, node, identifierName) {
|
|
19999
20472
|
if (!stableResult)
|
|
20000
20473
|
return false;
|
|
20001
|
-
if (!(stableResult instanceof Set) || node.type !==
|
|
20474
|
+
if (!(stableResult instanceof Set) || node.type !== TSESTree10.AST_NODE_TYPES.VariableDeclarator || node.id.type !== TSESTree10.AST_NODE_TYPES.ArrayPattern) {
|
|
20002
20475
|
return false;
|
|
20003
20476
|
}
|
|
20004
20477
|
const elements = node.id.elements;
|
|
20005
20478
|
let index2 = 0;
|
|
20006
20479
|
for (const element of elements) {
|
|
20007
|
-
if (element.type ===
|
|
20480
|
+
if (element.type === TSESTree10.AST_NODE_TYPES.Identifier && element.name === identifierName) {
|
|
20008
20481
|
return stableResult.has(index2);
|
|
20009
20482
|
}
|
|
20010
20483
|
index2 += 1;
|
|
@@ -20013,9 +20486,9 @@ function isStableArrayIndex(stableResult, node, identifierName) {
|
|
|
20013
20486
|
}
|
|
20014
20487
|
function isStableHookValue(init, node, identifierName, stableHooks) {
|
|
20015
20488
|
const castInit = init;
|
|
20016
|
-
if (castInit.type !==
|
|
20489
|
+
if (castInit.type !== TSESTree10.AST_NODE_TYPES.CallExpression)
|
|
20017
20490
|
return false;
|
|
20018
|
-
const hookName =
|
|
20491
|
+
const hookName = getHookName3(castInit);
|
|
20019
20492
|
if (!hookName)
|
|
20020
20493
|
return false;
|
|
20021
20494
|
const stableResult = stableHooks.get(hookName);
|
|
@@ -20033,34 +20506,34 @@ function isStableValue(variable, identifierName, stableHooks) {
|
|
|
20033
20506
|
const { node, type: type3 } = definition;
|
|
20034
20507
|
if (STABLE_VALUE_TYPES.has(type3))
|
|
20035
20508
|
return true;
|
|
20036
|
-
if (type3 === "Variable" && node.type ===
|
|
20509
|
+
if (type3 === "Variable" && node.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator) {
|
|
20037
20510
|
const parent = node.parent;
|
|
20038
|
-
if (!parent || parent.type !==
|
|
20511
|
+
if (!parent || parent.type !== TSESTree10.AST_NODE_TYPES.VariableDeclaration || parent.kind !== "const")
|
|
20039
20512
|
continue;
|
|
20040
20513
|
const init = node.init;
|
|
20041
20514
|
if (init && isStableHookValue(init, node, identifierName, stableHooks))
|
|
20042
20515
|
return true;
|
|
20043
|
-
if (init?.type ===
|
|
20516
|
+
if (init?.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
20044
20517
|
const { callee } = init;
|
|
20045
|
-
if (callee.type ===
|
|
20518
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.object.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.object.name === "React" && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.property.name === "joinBindings") {
|
|
20046
20519
|
return true;
|
|
20047
20520
|
}
|
|
20048
|
-
if (callee.type ===
|
|
20521
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.property.name === "map") {
|
|
20049
20522
|
return true;
|
|
20050
20523
|
}
|
|
20051
20524
|
}
|
|
20052
20525
|
if (init) {
|
|
20053
|
-
if (init.type ===
|
|
20526
|
+
if (init.type === TSESTree10.AST_NODE_TYPES.Literal || init.type === TSESTree10.AST_NODE_TYPES.TemplateLiteral) {
|
|
20054
20527
|
return true;
|
|
20055
20528
|
}
|
|
20056
|
-
if (init.type ===
|
|
20529
|
+
if (init.type === TSESTree10.AST_NODE_TYPES.UnaryExpression && init.argument.type === TSESTree10.AST_NODE_TYPES.Literal) {
|
|
20057
20530
|
return true;
|
|
20058
20531
|
}
|
|
20059
20532
|
}
|
|
20060
20533
|
const variableDefinition = variable.defs.find((definition2) => definition2.node === node);
|
|
20061
|
-
if (variableDefinition && variableDefinition.node.type ===
|
|
20534
|
+
if (variableDefinition && variableDefinition.node.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator) {
|
|
20062
20535
|
const declarationParent = variableDefinition.node.parent?.parent;
|
|
20063
|
-
if (declarationParent && (declarationParent.type ===
|
|
20536
|
+
if (declarationParent && (declarationParent.type === TSESTree10.AST_NODE_TYPES.Program || declarationParent.type === TSESTree10.AST_NODE_TYPES.ExportNamedDeclaration)) {
|
|
20064
20537
|
testingMetrics.moduleLevelStableConst += 1;
|
|
20065
20538
|
return true;
|
|
20066
20539
|
}
|
|
@@ -20073,14 +20546,14 @@ function findTopmostMemberExpression(node) {
|
|
|
20073
20546
|
let current = node;
|
|
20074
20547
|
let { parent } = node;
|
|
20075
20548
|
while (parent) {
|
|
20076
|
-
if (parent.type ===
|
|
20077
|
-
if (current.type ===
|
|
20549
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.CallExpression && parent.callee === current) {
|
|
20550
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression)
|
|
20078
20551
|
return current.object;
|
|
20079
20552
|
break;
|
|
20080
20553
|
}
|
|
20081
|
-
const isMemberParent = parent.type ===
|
|
20082
|
-
const isChainParent = parent.type ===
|
|
20083
|
-
const isNonNullParent = parent.type ===
|
|
20554
|
+
const isMemberParent = parent.type === TSESTree10.AST_NODE_TYPES.MemberExpression && parent.object === current;
|
|
20555
|
+
const isChainParent = parent.type === TSESTree10.AST_NODE_TYPES.ChainExpression;
|
|
20556
|
+
const isNonNullParent = parent.type === TSESTree10.AST_NODE_TYPES.TSNonNullExpression;
|
|
20084
20557
|
if (!isMemberParent && !isChainParent && !isNonNullParent)
|
|
20085
20558
|
break;
|
|
20086
20559
|
current = parent;
|
|
@@ -20089,21 +20562,21 @@ function findTopmostMemberExpression(node) {
|
|
|
20089
20562
|
return current;
|
|
20090
20563
|
}
|
|
20091
20564
|
var IS_CEASE_BOUNDARY = new Set([
|
|
20092
|
-
|
|
20093
|
-
|
|
20094
|
-
|
|
20095
|
-
|
|
20565
|
+
TSESTree10.AST_NODE_TYPES.FunctionDeclaration,
|
|
20566
|
+
TSESTree10.AST_NODE_TYPES.FunctionExpression,
|
|
20567
|
+
TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
20568
|
+
TSESTree10.AST_NODE_TYPES.VariableDeclarator
|
|
20096
20569
|
]);
|
|
20097
20570
|
var TS_RUNTIME_EXPRESSIONS = new Set([
|
|
20098
|
-
|
|
20099
|
-
|
|
20100
|
-
|
|
20101
|
-
|
|
20102
|
-
|
|
20571
|
+
TSESTree10.AST_NODE_TYPES.TSNonNullExpression,
|
|
20572
|
+
TSESTree10.AST_NODE_TYPES.TSAsExpression,
|
|
20573
|
+
TSESTree10.AST_NODE_TYPES.TSSatisfiesExpression,
|
|
20574
|
+
TSESTree10.AST_NODE_TYPES.TSTypeAssertion,
|
|
20575
|
+
TSESTree10.AST_NODE_TYPES.TSInstantiationExpression
|
|
20103
20576
|
]);
|
|
20104
20577
|
function isComputedPropertyIdentifier(identifier3) {
|
|
20105
20578
|
const parent = identifier3.parent;
|
|
20106
|
-
return parent?.type ===
|
|
20579
|
+
return parent?.type === TSESTree10.AST_NODE_TYPES.Property && parent.computed && parent.key === identifier3;
|
|
20107
20580
|
}
|
|
20108
20581
|
function isInTypePosition(identifier3) {
|
|
20109
20582
|
let parent = identifier3.parent;
|
|
@@ -20157,10 +20630,10 @@ function resolveFunctionReference(identifier3, scope) {
|
|
|
20157
20630
|
return;
|
|
20158
20631
|
for (const definition of variable.defs) {
|
|
20159
20632
|
const { node } = definition;
|
|
20160
|
-
if (node.type ===
|
|
20633
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
20161
20634
|
return node;
|
|
20162
20635
|
}
|
|
20163
|
-
if (node.type ===
|
|
20636
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator && node.init && (node.init.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression || node.init.type === TSESTree10.AST_NODE_TYPES.FunctionExpression)) {
|
|
20164
20637
|
return node.init;
|
|
20165
20638
|
}
|
|
20166
20639
|
}
|
|
@@ -20170,7 +20643,7 @@ function collectCaptures(node, sourceCode) {
|
|
|
20170
20643
|
const captures = new Array;
|
|
20171
20644
|
const captureSet = new Set;
|
|
20172
20645
|
function visit(current) {
|
|
20173
|
-
if (current.type ===
|
|
20646
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
20174
20647
|
const { name } = current;
|
|
20175
20648
|
if (captureSet.has(name) || GLOBAL_BUILTINS.has(name) || isInTypePosition(current))
|
|
20176
20649
|
return;
|
|
@@ -20212,21 +20685,21 @@ function collectCaptures(node, sourceCode) {
|
|
|
20212
20685
|
}
|
|
20213
20686
|
}
|
|
20214
20687
|
}
|
|
20215
|
-
if (current.type ===
|
|
20688
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.TSSatisfiesExpression || current.type === TSESTree10.AST_NODE_TYPES.TSAsExpression || current.type === TSESTree10.AST_NODE_TYPES.TSTypeAssertion || current.type === TSESTree10.AST_NODE_TYPES.TSNonNullExpression) {
|
|
20216
20689
|
visit(current.expression);
|
|
20217
20690
|
return;
|
|
20218
20691
|
}
|
|
20219
|
-
if (current.type ===
|
|
20692
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression) {
|
|
20220
20693
|
visit(current.object);
|
|
20221
20694
|
if (current.computed)
|
|
20222
20695
|
visit(current.property);
|
|
20223
20696
|
return;
|
|
20224
20697
|
}
|
|
20225
|
-
if (current.type ===
|
|
20698
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ChainExpression) {
|
|
20226
20699
|
visit(current.expression);
|
|
20227
20700
|
return;
|
|
20228
20701
|
}
|
|
20229
|
-
if (current.type ===
|
|
20702
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.Property) {
|
|
20230
20703
|
if (current.computed)
|
|
20231
20704
|
visit(current.key);
|
|
20232
20705
|
visit(current.value);
|
|
@@ -20251,7 +20724,7 @@ function parseDependencies(node, sourceCode) {
|
|
|
20251
20724
|
for (const element of node.elements) {
|
|
20252
20725
|
if (!element)
|
|
20253
20726
|
continue;
|
|
20254
|
-
const actualNode = element.type ===
|
|
20727
|
+
const actualNode = element.type === TSESTree10.AST_NODE_TYPES.SpreadElement ? element.argument : element;
|
|
20255
20728
|
const name = nodeToDependencyString(actualNode, sourceCode);
|
|
20256
20729
|
const depth = getMemberExpressionDepth(actualNode);
|
|
20257
20730
|
dependencies4.push({
|
|
@@ -20316,7 +20789,7 @@ var useExhaustiveDependencies = {
|
|
|
20316
20789
|
return {
|
|
20317
20790
|
CallExpression(node) {
|
|
20318
20791
|
const callNode = node;
|
|
20319
|
-
const hookName =
|
|
20792
|
+
const hookName = getHookName3(callNode);
|
|
20320
20793
|
if (hookName === undefined || hookName === "")
|
|
20321
20794
|
return;
|
|
20322
20795
|
const hookConfig = hookConfigs.get(hookName);
|
|
@@ -20328,9 +20801,9 @@ var useExhaustiveDependencies = {
|
|
|
20328
20801
|
if (closureArgument === undefined)
|
|
20329
20802
|
return;
|
|
20330
20803
|
let closureFunction;
|
|
20331
|
-
if (closureArgument.type ===
|
|
20804
|
+
if (closureArgument.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression || closureArgument.type === TSESTree10.AST_NODE_TYPES.FunctionExpression) {
|
|
20332
20805
|
closureFunction = closureArgument;
|
|
20333
|
-
} else if (closureArgument.type ===
|
|
20806
|
+
} else if (closureArgument.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
20334
20807
|
const scope = getScope(callNode);
|
|
20335
20808
|
closureFunction = resolveFunctionReference(closureArgument, scope);
|
|
20336
20809
|
}
|
|
@@ -20364,7 +20837,7 @@ var useExhaustiveDependencies = {
|
|
|
20364
20837
|
}
|
|
20365
20838
|
if (!dependenciesArgument)
|
|
20366
20839
|
return;
|
|
20367
|
-
if (dependenciesArgument.type !==
|
|
20840
|
+
if (dependenciesArgument.type !== TSESTree10.AST_NODE_TYPES.ArrayExpression)
|
|
20368
20841
|
return;
|
|
20369
20842
|
const dependenciesArray = dependenciesArgument;
|
|
20370
20843
|
const captures = collectCaptures(closureFunction, context.sourceCode);
|
|
@@ -20445,7 +20918,7 @@ var useExhaustiveDependencies = {
|
|
|
20445
20918
|
context.report({
|
|
20446
20919
|
data: { name: firstMissing.usagePath },
|
|
20447
20920
|
messageId: "missingDependency",
|
|
20448
|
-
node: lastDependency?.node
|
|
20921
|
+
node: lastDependency?.node ?? dependenciesArray,
|
|
20449
20922
|
suggest: [
|
|
20450
20923
|
{
|
|
20451
20924
|
desc: `Add '${firstMissing.usagePath}' to dependencies array`,
|
|
@@ -20460,7 +20933,7 @@ var useExhaustiveDependencies = {
|
|
|
20460
20933
|
context.report({
|
|
20461
20934
|
data: { names: missingNames },
|
|
20462
20935
|
messageId: "missingDependencies",
|
|
20463
|
-
node: lastDependency?.node
|
|
20936
|
+
node: lastDependency?.node ?? dependenciesArray,
|
|
20464
20937
|
suggest: [
|
|
20465
20938
|
{
|
|
20466
20939
|
desc: "Add missing dependencies to array",
|
|
@@ -20574,33 +21047,33 @@ var useExhaustiveDependencies = {
|
|
|
20574
21047
|
var use_exhaustive_dependencies_default = useExhaustiveDependencies;
|
|
20575
21048
|
|
|
20576
21049
|
// src/rules/use-hook-at-top-level.ts
|
|
20577
|
-
import { TSESTree as
|
|
21050
|
+
import { TSESTree as TSESTree11 } from "@typescript-eslint/types";
|
|
20578
21051
|
var HOOK_NAME_PATTERN = /^use[A-Z]/;
|
|
20579
|
-
var
|
|
21052
|
+
var COMPONENT_NAME_PATTERN2 = /^[A-Z]/;
|
|
20580
21053
|
function isReactHook(name) {
|
|
20581
21054
|
return HOOK_NAME_PATTERN.test(name);
|
|
20582
21055
|
}
|
|
20583
21056
|
function isComponent(name) {
|
|
20584
|
-
return
|
|
21057
|
+
return COMPONENT_NAME_PATTERN2.test(name);
|
|
20585
21058
|
}
|
|
20586
21059
|
function isComponentOrHook(node) {
|
|
20587
|
-
if (node.type ===
|
|
21060
|
+
if (node.type === TSESTree11.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
20588
21061
|
const { name } = node.id;
|
|
20589
21062
|
return isComponent(name) || isReactHook(name);
|
|
20590
21063
|
}
|
|
20591
|
-
if (node.type ===
|
|
21064
|
+
if (node.type === TSESTree11.AST_NODE_TYPES.FunctionExpression || node.type === TSESTree11.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
20592
21065
|
const { parent } = node;
|
|
20593
21066
|
if (!parent)
|
|
20594
21067
|
return false;
|
|
20595
|
-
if (parent.type ===
|
|
21068
|
+
if (parent.type === TSESTree11.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20596
21069
|
const { name } = parent.id;
|
|
20597
21070
|
return isComponent(name) || isReactHook(name);
|
|
20598
21071
|
}
|
|
20599
|
-
if (parent.type ===
|
|
21072
|
+
if (parent.type === TSESTree11.AST_NODE_TYPES.Property && parent.key.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20600
21073
|
const { name } = parent.key;
|
|
20601
21074
|
return isComponent(name) || isReactHook(name);
|
|
20602
21075
|
}
|
|
20603
|
-
if (parent.type ===
|
|
21076
|
+
if (parent.type === TSESTree11.AST_NODE_TYPES.MethodDefinition && parent.key.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20604
21077
|
const { name } = parent.key;
|
|
20605
21078
|
return isComponent(name) || isReactHook(name);
|
|
20606
21079
|
}
|
|
@@ -20609,24 +21082,24 @@ function isComponentOrHook(node) {
|
|
|
20609
21082
|
}
|
|
20610
21083
|
function isHookCall(node) {
|
|
20611
21084
|
const { callee } = node;
|
|
20612
|
-
if (callee.type ===
|
|
21085
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
20613
21086
|
return isReactHook(callee.name);
|
|
20614
|
-
if (callee.type ===
|
|
21087
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
20615
21088
|
return isReactHook(callee.property.name);
|
|
20616
21089
|
return false;
|
|
20617
21090
|
}
|
|
20618
|
-
var
|
|
20619
|
-
|
|
20620
|
-
|
|
20621
|
-
|
|
21091
|
+
var FUNCTION_BOUNDARIES2 = new Set([
|
|
21092
|
+
TSESTree11.AST_NODE_TYPES.FunctionDeclaration,
|
|
21093
|
+
TSESTree11.AST_NODE_TYPES.FunctionExpression,
|
|
21094
|
+
TSESTree11.AST_NODE_TYPES.ArrowFunctionExpression
|
|
20622
21095
|
]);
|
|
20623
21096
|
function isInFinallyBlock(node) {
|
|
20624
21097
|
let current = node.parent;
|
|
20625
21098
|
const maxDepth = 20;
|
|
20626
21099
|
for (let depth = 0;depth < maxDepth && current; depth += 1) {
|
|
20627
|
-
if (
|
|
21100
|
+
if (FUNCTION_BOUNDARIES2.has(current.type))
|
|
20628
21101
|
return false;
|
|
20629
|
-
if (current.type ===
|
|
21102
|
+
if (current.type === TSESTree11.AST_NODE_TYPES.TryStatement) {
|
|
20630
21103
|
let checkNode = node;
|
|
20631
21104
|
while (checkNode && checkNode !== current) {
|
|
20632
21105
|
if (checkNode === current.finalizer)
|
|
@@ -20649,7 +21122,7 @@ function isRecursiveCall(node, functionName) {
|
|
|
20649
21122
|
}
|
|
20650
21123
|
var useHookAtTopLevel = {
|
|
20651
21124
|
create(context) {
|
|
20652
|
-
const configuration = context.options[0]
|
|
21125
|
+
const configuration = context.options[0] ?? {};
|
|
20653
21126
|
const contextStack = new Array;
|
|
20654
21127
|
let currentFunctionName;
|
|
20655
21128
|
const importSourceMap = new Map;
|
|
@@ -20674,14 +21147,14 @@ var useHookAtTopLevel = {
|
|
|
20674
21147
|
if (ignoreHooks?.includes(hookName))
|
|
20675
21148
|
return true;
|
|
20676
21149
|
if (importSources && Object.keys(importSources).length > 0) {
|
|
20677
|
-
if (node.callee.type ===
|
|
20678
|
-
const objectName = node.callee.object.type ===
|
|
21150
|
+
if (node.callee.type === TSESTree11.AST_NODE_TYPES.MemberExpression) {
|
|
21151
|
+
const objectName = node.callee.object.type === TSESTree11.AST_NODE_TYPES.Identifier ? node.callee.object.name : undefined;
|
|
20679
21152
|
if (objectName && importSources[objectName] === false)
|
|
20680
21153
|
return true;
|
|
20681
21154
|
if (objectName && importSources[objectName] === true)
|
|
20682
21155
|
return false;
|
|
20683
21156
|
}
|
|
20684
|
-
if (node.callee.type ===
|
|
21157
|
+
if (node.callee.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20685
21158
|
const importSource = importSourceMap.get(hookName);
|
|
20686
21159
|
if (importSource && importSources[importSource] === false)
|
|
20687
21160
|
return true;
|
|
@@ -20696,7 +21169,7 @@ var useHookAtTopLevel = {
|
|
|
20696
21169
|
const current = getCurrentContext();
|
|
20697
21170
|
const depth = current ? current.functionDepth + 1 : 0;
|
|
20698
21171
|
const isComponentOrHookFlag = isComponentOrHook(functionNode);
|
|
20699
|
-
if (functionNode.type ===
|
|
21172
|
+
if (functionNode.type === TSESTree11.AST_NODE_TYPES.FunctionDeclaration && functionNode.id)
|
|
20700
21173
|
currentFunctionName = functionNode.id.name;
|
|
20701
21174
|
if (current?.isComponentOrHook) {
|
|
20702
21175
|
pushContext({
|
|
@@ -20734,7 +21207,7 @@ var useHookAtTopLevel = {
|
|
|
20734
21207
|
if (!isHookCall(callNode))
|
|
20735
21208
|
return;
|
|
20736
21209
|
const { callee } = callNode;
|
|
20737
|
-
const hookName = callee.type ===
|
|
21210
|
+
const hookName = callee.type === TSESTree11.AST_NODE_TYPES.Identifier ? callee.name : callee.type === TSESTree11.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree11.AST_NODE_TYPES.Identifier ? callee.property.name : undefined;
|
|
20738
21211
|
if (!hookName || shouldIgnoreHook(hookName, callNode))
|
|
20739
21212
|
return;
|
|
20740
21213
|
const current = getCurrentContext();
|
|
@@ -20832,10 +21305,10 @@ var useHookAtTopLevel = {
|
|
|
20832
21305
|
if (!configuration.importSources || Object.keys(configuration.importSources).length === 0)
|
|
20833
21306
|
return;
|
|
20834
21307
|
for (const specifier of importNode.specifiers) {
|
|
20835
|
-
if (specifier.type !==
|
|
21308
|
+
if (specifier.type !== TSESTree11.AST_NODE_TYPES.ImportSpecifier)
|
|
20836
21309
|
continue;
|
|
20837
21310
|
const { imported } = specifier;
|
|
20838
|
-
if (imported.type !==
|
|
21311
|
+
if (imported.type !== TSESTree11.AST_NODE_TYPES.Identifier)
|
|
20839
21312
|
continue;
|
|
20840
21313
|
if (isReactHook(imported.name))
|
|
20841
21314
|
importSourceMap.set(specifier.local.name, source);
|
|
@@ -20971,6 +21444,19 @@ function createReactKeysOptions(options3 = {}) {
|
|
|
20971
21444
|
...options3
|
|
20972
21445
|
};
|
|
20973
21446
|
}
|
|
21447
|
+
function createNoGodComponentsOptions(options3 = {}) {
|
|
21448
|
+
return {
|
|
21449
|
+
enforceTargetLines: true,
|
|
21450
|
+
ignoreComponents: [],
|
|
21451
|
+
maxDestructuredProps: 5,
|
|
21452
|
+
maxLines: 200,
|
|
21453
|
+
maxStateHooks: 5,
|
|
21454
|
+
maxTsxNesting: 3,
|
|
21455
|
+
stateHooks: ["useState", "useReducer", "useBinding"],
|
|
21456
|
+
targetLines: 120,
|
|
21457
|
+
...options3
|
|
21458
|
+
};
|
|
21459
|
+
}
|
|
20974
21460
|
function createUseExhaustiveDependenciesOptions(options3 = {}) {
|
|
20975
21461
|
return {
|
|
20976
21462
|
hooks: [],
|
|
@@ -21004,6 +21490,7 @@ var rules = {
|
|
|
21004
21490
|
"no-async-constructor": no_async_constructor_default,
|
|
21005
21491
|
"no-color3-constructor": no_color3_constructor_default,
|
|
21006
21492
|
"no-commented-code": no_commented_code_default,
|
|
21493
|
+
"no-god-components": no_god_components_default,
|
|
21007
21494
|
"no-instance-methods-without-this": no_instance_methods_without_this_default,
|
|
21008
21495
|
"no-print": no_print_default,
|
|
21009
21496
|
"no-shorthand-names": no_shorthand_names_default,
|
|
@@ -21029,6 +21516,7 @@ var recommended = {
|
|
|
21029
21516
|
"cease-nonsense/no-async-constructor": "error",
|
|
21030
21517
|
"cease-nonsense/no-color3-constructor": "error",
|
|
21031
21518
|
"cease-nonsense/no-instance-methods-without-this": "error",
|
|
21519
|
+
"cease-nonsense/no-god-components": "error",
|
|
21032
21520
|
"cease-nonsense/no-print": "error",
|
|
21033
21521
|
"cease-nonsense/no-shorthand-names": "error",
|
|
21034
21522
|
"cease-nonsense/no-warn": "error",
|
|
@@ -21056,10 +21544,11 @@ export {
|
|
|
21056
21544
|
createNoUselessUseSpringOptions,
|
|
21057
21545
|
createNoShorthandOptions,
|
|
21058
21546
|
createNoInstanceMethodsOptions,
|
|
21547
|
+
createNoGodComponentsOptions,
|
|
21059
21548
|
createHookConfiguration,
|
|
21060
21549
|
createEffectFunctionOptions,
|
|
21061
21550
|
createComplexityConfiguration,
|
|
21062
21551
|
createBanInstancesOptions
|
|
21063
21552
|
};
|
|
21064
21553
|
|
|
21065
|
-
//# debugId=
|
|
21554
|
+
//# debugId=BE95AD3504B774A764756E2164756E21
|