@pobammer-ts/eslint-cease-nonsense-rules 1.5.3 → 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 +700 -257
- package/dist/index.js.map +20 -19
- 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
|
});
|
|
@@ -18112,6 +18199,347 @@ var noWarn = {
|
|
|
18112
18199
|
};
|
|
18113
18200
|
var no_warn_default = noWarn;
|
|
18114
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
|
+
|
|
18115
18543
|
// src/rules/prefer-sequence-overloads.ts
|
|
18116
18544
|
import { AST_NODE_TYPES as AST_NODE_TYPES4 } from "@typescript-eslint/types";
|
|
18117
18545
|
var sequenceDescriptors = [
|
|
@@ -18219,11 +18647,11 @@ var preferSequenceOverloads = {
|
|
|
18219
18647
|
var prefer_sequence_overloads_default = preferSequenceOverloads;
|
|
18220
18648
|
|
|
18221
18649
|
// src/rules/prefer-udim2-shorthand.ts
|
|
18222
|
-
import { TSESTree as
|
|
18650
|
+
import { TSESTree as TSESTree7 } from "@typescript-eslint/utils";
|
|
18223
18651
|
function isNumber(value) {
|
|
18224
18652
|
return typeof value === "number" && !Number.isNaN(value);
|
|
18225
18653
|
}
|
|
18226
|
-
function
|
|
18654
|
+
function isRecord3(node) {
|
|
18227
18655
|
return typeof node === "object" && node !== null;
|
|
18228
18656
|
}
|
|
18229
18657
|
function hasTypeProperty(object3) {
|
|
@@ -18232,30 +18660,30 @@ function hasTypeProperty(object3) {
|
|
|
18232
18660
|
var OPERATORS2 = new Set(["+", "-", "*", "/", "%"]);
|
|
18233
18661
|
function reconstructText(node) {
|
|
18234
18662
|
const nodeType = node.type;
|
|
18235
|
-
if (nodeType ===
|
|
18663
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.Literal) {
|
|
18236
18664
|
const { value } = node;
|
|
18237
18665
|
return isNumber(value) ? String(value) : undefined;
|
|
18238
18666
|
}
|
|
18239
|
-
if (nodeType ===
|
|
18667
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.Identifier) {
|
|
18240
18668
|
const { name } = node;
|
|
18241
18669
|
return typeof name === "string" ? name : undefined;
|
|
18242
18670
|
}
|
|
18243
|
-
if (nodeType ===
|
|
18671
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.UnaryExpression) {
|
|
18244
18672
|
const { operator } = node;
|
|
18245
18673
|
if (typeof operator !== "string")
|
|
18246
18674
|
return;
|
|
18247
18675
|
const { argument } = node;
|
|
18248
|
-
if (!
|
|
18676
|
+
if (!isRecord3(argument))
|
|
18249
18677
|
return;
|
|
18250
18678
|
const text = reconstructText(argument);
|
|
18251
18679
|
return text === undefined ? undefined : `${operator}${text}`;
|
|
18252
18680
|
}
|
|
18253
|
-
if (nodeType ===
|
|
18681
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.BinaryExpression) {
|
|
18254
18682
|
const { operator } = node;
|
|
18255
18683
|
if (typeof operator !== "string" || !OPERATORS2.has(operator))
|
|
18256
18684
|
return;
|
|
18257
18685
|
const { left, right } = node;
|
|
18258
|
-
if (!
|
|
18686
|
+
if (!isRecord3(left) || !isRecord3(right))
|
|
18259
18687
|
return;
|
|
18260
18688
|
const leftText = reconstructText(left);
|
|
18261
18689
|
const rightText = reconstructText(right);
|
|
@@ -18264,14 +18692,14 @@ function reconstructText(node) {
|
|
|
18264
18692
|
return;
|
|
18265
18693
|
}
|
|
18266
18694
|
function evaluateExpression(node) {
|
|
18267
|
-
if (!
|
|
18695
|
+
if (!isRecord3(node))
|
|
18268
18696
|
return;
|
|
18269
18697
|
const nodeType = node.type;
|
|
18270
|
-
if (nodeType ===
|
|
18698
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.Literal) {
|
|
18271
18699
|
const { value } = node;
|
|
18272
18700
|
return isNumber(value) ? value : undefined;
|
|
18273
18701
|
}
|
|
18274
|
-
if (nodeType ===
|
|
18702
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.UnaryExpression) {
|
|
18275
18703
|
const { argument, operator } = node;
|
|
18276
18704
|
if (typeof argument === "object" && argument !== null) {
|
|
18277
18705
|
const value = evaluateExpression(argument);
|
|
@@ -18284,7 +18712,7 @@ function evaluateExpression(node) {
|
|
|
18284
18712
|
}
|
|
18285
18713
|
return;
|
|
18286
18714
|
}
|
|
18287
|
-
if (nodeType ===
|
|
18715
|
+
if (nodeType === TSESTree7.AST_NODE_TYPES.BinaryExpression) {
|
|
18288
18716
|
const { right, left, operator } = node;
|
|
18289
18717
|
if (typeof left === "object" && left !== null && typeof right === "object" && right !== null) {
|
|
18290
18718
|
const leftValue = evaluateExpression(left);
|
|
@@ -18316,9 +18744,9 @@ function collectArguments(_context2, parameters3) {
|
|
|
18316
18744
|
const texts = [undefined, undefined, undefined, undefined];
|
|
18317
18745
|
for (let index2 = 0;index2 < 4; index2++) {
|
|
18318
18746
|
const parameter2 = parameters3[index2];
|
|
18319
|
-
if (!
|
|
18747
|
+
if (!isRecord3(parameter2) || !hasTypeProperty(parameter2))
|
|
18320
18748
|
return;
|
|
18321
|
-
if (parameter2.type ===
|
|
18749
|
+
if (parameter2.type === TSESTree7.AST_NODE_TYPES.SpreadElement)
|
|
18322
18750
|
return;
|
|
18323
18751
|
const text = reconstructText(parameter2);
|
|
18324
18752
|
if (text === undefined)
|
|
@@ -18334,7 +18762,7 @@ var preferUDim2Shorthand = {
|
|
|
18334
18762
|
create(context) {
|
|
18335
18763
|
return {
|
|
18336
18764
|
NewExpression(node) {
|
|
18337
|
-
if (node.callee.type !==
|
|
18765
|
+
if (node.callee.type !== TSESTree7.AST_NODE_TYPES.Identifier || node.callee.name !== "UDim2")
|
|
18338
18766
|
return;
|
|
18339
18767
|
const collected = collectArguments(context, node.arguments);
|
|
18340
18768
|
if (!collected)
|
|
@@ -18381,7 +18809,7 @@ var preferUDim2Shorthand = {
|
|
|
18381
18809
|
var prefer_udim2_shorthand_default = preferUDim2Shorthand;
|
|
18382
18810
|
|
|
18383
18811
|
// src/rules/require-named-effect-functions.ts
|
|
18384
|
-
import { TSESTree as
|
|
18812
|
+
import { TSESTree as TSESTree8 } from "@typescript-eslint/types";
|
|
18385
18813
|
var DEFAULT_HOOKS = [
|
|
18386
18814
|
{ allowAsync: false, name: "useEffect" },
|
|
18387
18815
|
{ allowAsync: false, name: "useLayoutEffect" },
|
|
@@ -18396,7 +18824,7 @@ var isRuleOptions2 = Compile(build_default.Object({
|
|
|
18396
18824
|
environment: isEnvironmentMode,
|
|
18397
18825
|
hooks: build_default.Array(isHookConfiguration)
|
|
18398
18826
|
}, { additionalProperties: true }));
|
|
18399
|
-
function
|
|
18827
|
+
function parseOptions2(options3) {
|
|
18400
18828
|
if (options3 === undefined) {
|
|
18401
18829
|
return {
|
|
18402
18830
|
environment: "roblox-ts",
|
|
@@ -18414,11 +18842,11 @@ function parseOptions(options3) {
|
|
|
18414
18842
|
hooks: options3.hooks
|
|
18415
18843
|
};
|
|
18416
18844
|
}
|
|
18417
|
-
function
|
|
18845
|
+
function getHookName2(callExpression) {
|
|
18418
18846
|
const { callee } = callExpression;
|
|
18419
|
-
if (callee.type ===
|
|
18847
|
+
if (callee.type === TSESTree8.AST_NODE_TYPES.Identifier && typeof callee.name === "string" && callee.name.length > 0)
|
|
18420
18848
|
return callee.name;
|
|
18421
|
-
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)
|
|
18422
18850
|
return callee.property.name;
|
|
18423
18851
|
return;
|
|
18424
18852
|
}
|
|
@@ -18453,16 +18881,16 @@ function resolveIdentifierToFunction(identifier3, context) {
|
|
|
18453
18881
|
if (typeof node !== "object" || node === null)
|
|
18454
18882
|
continue;
|
|
18455
18883
|
const castNode = node;
|
|
18456
|
-
if (castNode.type ===
|
|
18884
|
+
if (castNode.type === TSESTree8.AST_NODE_TYPES.FunctionDeclaration) {
|
|
18457
18885
|
return {
|
|
18458
18886
|
isAsync: Boolean(castNode.async),
|
|
18459
18887
|
node,
|
|
18460
18888
|
type: "function-declaration"
|
|
18461
18889
|
};
|
|
18462
18890
|
}
|
|
18463
|
-
if (castNode.type ===
|
|
18891
|
+
if (castNode.type === TSESTree8.AST_NODE_TYPES.VariableDeclarator && typeof castNode.init === "object" && castNode.init !== null) {
|
|
18464
18892
|
const castInit = castNode.init;
|
|
18465
|
-
if (castInit.type ===
|
|
18893
|
+
if (castInit.type === TSESTree8.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
18466
18894
|
const arrowNode = castNode.init;
|
|
18467
18895
|
return {
|
|
18468
18896
|
isAsync: Boolean(arrowNode.async),
|
|
@@ -18470,7 +18898,7 @@ function resolveIdentifierToFunction(identifier3, context) {
|
|
|
18470
18898
|
type: "arrow"
|
|
18471
18899
|
};
|
|
18472
18900
|
}
|
|
18473
|
-
if (castInit.type ===
|
|
18901
|
+
if (castInit.type === TSESTree8.AST_NODE_TYPES.FunctionExpression) {
|
|
18474
18902
|
const castInitNode = castNode.init;
|
|
18475
18903
|
return {
|
|
18476
18904
|
isAsync: Boolean(castInitNode.async),
|
|
@@ -18516,14 +18944,14 @@ function isCallbackHookResult(identifier3, context) {
|
|
|
18516
18944
|
if (typeof node !== "object" || node === null)
|
|
18517
18945
|
continue;
|
|
18518
18946
|
const castNode = node;
|
|
18519
|
-
if (castNode.type !==
|
|
18947
|
+
if (castNode.type !== TSESTree8.AST_NODE_TYPES.VariableDeclarator)
|
|
18520
18948
|
continue;
|
|
18521
18949
|
if (typeof castNode.init !== "object" || castNode.init === null)
|
|
18522
18950
|
continue;
|
|
18523
18951
|
const init = castNode.init;
|
|
18524
|
-
if (init.type !==
|
|
18952
|
+
if (init.type !== TSESTree8.AST_NODE_TYPES.CallExpression)
|
|
18525
18953
|
continue;
|
|
18526
|
-
const calleeHookName =
|
|
18954
|
+
const calleeHookName = getHookName2(init);
|
|
18527
18955
|
if (calleeHookName === "useCallback" || calleeHookName === "useMemo")
|
|
18528
18956
|
return true;
|
|
18529
18957
|
}
|
|
@@ -18534,7 +18962,7 @@ function isCallbackHookResult(identifier3, context) {
|
|
|
18534
18962
|
}
|
|
18535
18963
|
var requireNamedEffectFunctions = {
|
|
18536
18964
|
create(context) {
|
|
18537
|
-
const { hooks, environment: environment2 } =
|
|
18965
|
+
const { hooks, environment: environment2 } = parseOptions2(context.options[0]);
|
|
18538
18966
|
const hookAsyncConfig = new Map(hooks.map((hookConfig) => [hookConfig.name, hookConfig.allowAsync]));
|
|
18539
18967
|
const effectHooks = new Set(hookAsyncConfig.keys());
|
|
18540
18968
|
const isRobloxTsMode = environment2 === "roblox-ts";
|
|
@@ -18545,14 +18973,14 @@ var requireNamedEffectFunctions = {
|
|
|
18545
18973
|
return {
|
|
18546
18974
|
CallExpression(node) {
|
|
18547
18975
|
const callExpression = node;
|
|
18548
|
-
const hookName =
|
|
18976
|
+
const hookName = getHookName2(callExpression);
|
|
18549
18977
|
if (typeof hookName !== "string" || !effectHooks.has(hookName))
|
|
18550
18978
|
return;
|
|
18551
18979
|
const firstArgument = callExpression.arguments?.[0];
|
|
18552
18980
|
if (firstArgument === undefined)
|
|
18553
18981
|
return;
|
|
18554
18982
|
const argumentNode = firstArgument;
|
|
18555
|
-
if (argumentNode.type ===
|
|
18983
|
+
if (argumentNode.type === TSESTree8.AST_NODE_TYPES.Identifier) {
|
|
18556
18984
|
const identifier3 = argumentNode;
|
|
18557
18985
|
const resolved = resolveIdentifierToFunction(identifier3, context);
|
|
18558
18986
|
if (resolved === undefined) {
|
|
@@ -18605,7 +19033,7 @@ var requireNamedEffectFunctions = {
|
|
|
18605
19033
|
}
|
|
18606
19034
|
return;
|
|
18607
19035
|
}
|
|
18608
|
-
if (argumentNode.type ===
|
|
19036
|
+
if (argumentNode.type === TSESTree8.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
18609
19037
|
if (argumentNode.async) {
|
|
18610
19038
|
context.report({
|
|
18611
19039
|
data: { hook: hookName },
|
|
@@ -18621,7 +19049,7 @@ var requireNamedEffectFunctions = {
|
|
|
18621
19049
|
}
|
|
18622
19050
|
return;
|
|
18623
19051
|
}
|
|
18624
|
-
if (argumentNode.type ===
|
|
19052
|
+
if (argumentNode.type === TSESTree8.AST_NODE_TYPES.FunctionExpression) {
|
|
18625
19053
|
const functionExpressionNode = argumentNode;
|
|
18626
19054
|
const functionHasId = Boolean(functionExpressionNode.id);
|
|
18627
19055
|
if (functionHasId && argumentNode.async) {
|
|
@@ -18649,7 +19077,6 @@ var requireNamedEffectFunctions = {
|
|
|
18649
19077
|
node
|
|
18650
19078
|
});
|
|
18651
19079
|
}
|
|
18652
|
-
return;
|
|
18653
19080
|
}
|
|
18654
19081
|
}
|
|
18655
19082
|
};
|
|
@@ -19522,7 +19949,7 @@ var rule = {
|
|
|
19522
19949
|
var require_paired_calls_default = rule;
|
|
19523
19950
|
|
|
19524
19951
|
// src/rules/require-react-component-keys.ts
|
|
19525
|
-
import { TSESTree as
|
|
19952
|
+
import { TSESTree as TSESTree9 } from "@typescript-eslint/types";
|
|
19526
19953
|
var DEFAULT_OPTIONS3 = {
|
|
19527
19954
|
allowRootKeys: false,
|
|
19528
19955
|
ignoreCallExpressions: ["ReactTree.mount", "CreateReactStory"],
|
|
@@ -19565,22 +19992,22 @@ function ascendPastWrappers(node) {
|
|
|
19565
19992
|
}
|
|
19566
19993
|
function hasKeyAttribute(node) {
|
|
19567
19994
|
for (const attribute of node.openingElement.attributes)
|
|
19568
|
-
if (attribute.type ===
|
|
19995
|
+
if (attribute.type === TSESTree9.AST_NODE_TYPES.JSXAttribute && attribute.name.name === "key")
|
|
19569
19996
|
return true;
|
|
19570
19997
|
return false;
|
|
19571
19998
|
}
|
|
19572
|
-
function
|
|
19999
|
+
function isReactComponentHOC2(callExpr) {
|
|
19573
20000
|
const { callee } = callExpr;
|
|
19574
|
-
if (callee.type ===
|
|
20001
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier)
|
|
19575
20002
|
return callee.name === "forwardRef" || callee.name === "memo";
|
|
19576
|
-
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)
|
|
19577
20004
|
return callee.property.name === "forwardRef" || callee.property.name === "memo";
|
|
19578
20005
|
return false;
|
|
19579
20006
|
}
|
|
19580
20007
|
function getEnclosingFunctionLike(node) {
|
|
19581
20008
|
let current = node.parent;
|
|
19582
20009
|
while (current) {
|
|
19583
|
-
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)
|
|
19584
20011
|
return current;
|
|
19585
20012
|
current = current.parent;
|
|
19586
20013
|
}
|
|
@@ -19588,15 +20015,15 @@ function getEnclosingFunctionLike(node) {
|
|
|
19588
20015
|
}
|
|
19589
20016
|
function isIterationOrMemoCallback(callExpr, iterationMethods, memoizationHooks) {
|
|
19590
20017
|
const { callee } = callExpr;
|
|
19591
|
-
if (callee.type ===
|
|
20018
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier && memoizationHooks.has(callee.name))
|
|
19592
20019
|
return true;
|
|
19593
|
-
if (callee.type ===
|
|
20020
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree9.AST_NODE_TYPES.Identifier) {
|
|
19594
20021
|
const methodName = callee.property.name;
|
|
19595
20022
|
if (iterationMethods.has(methodName))
|
|
19596
20023
|
return true;
|
|
19597
|
-
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)
|
|
19598
20025
|
return true;
|
|
19599
|
-
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))
|
|
19600
20027
|
return true;
|
|
19601
20028
|
}
|
|
19602
20029
|
return false;
|
|
@@ -19605,11 +20032,11 @@ function findEnclosingCallExpression(node) {
|
|
|
19605
20032
|
let current = node;
|
|
19606
20033
|
let { parent } = node;
|
|
19607
20034
|
while (parent) {
|
|
19608
|
-
if (parent.type ===
|
|
20035
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.CallExpression) {
|
|
19609
20036
|
for (const argument of parent.arguments) {
|
|
19610
20037
|
if (argument === current)
|
|
19611
20038
|
return parent;
|
|
19612
|
-
if (argument.type ===
|
|
20039
|
+
if (argument.type === TSESTree9.AST_NODE_TYPES.SpreadElement && argument.argument === current)
|
|
19613
20040
|
return parent;
|
|
19614
20041
|
}
|
|
19615
20042
|
return;
|
|
@@ -19624,7 +20051,7 @@ function findEnclosingCallExpression(node) {
|
|
|
19624
20051
|
return;
|
|
19625
20052
|
}
|
|
19626
20053
|
function getVariableForFunction(context, functionLike) {
|
|
19627
|
-
if (functionLike.type ===
|
|
20054
|
+
if (functionLike.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration) {
|
|
19628
20055
|
const declared = context.sourceCode.getDeclaredVariables(functionLike);
|
|
19629
20056
|
if (declared.length > 0)
|
|
19630
20057
|
return declared[0];
|
|
@@ -19633,7 +20060,7 @@ function getVariableForFunction(context, functionLike) {
|
|
|
19633
20060
|
const { parent } = functionLike;
|
|
19634
20061
|
if (!parent)
|
|
19635
20062
|
return;
|
|
19636
|
-
if (parent.type ===
|
|
20063
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.VariableDeclarator || parent.type === TSESTree9.AST_NODE_TYPES.AssignmentExpression) {
|
|
19637
20064
|
const declared = context.sourceCode.getDeclaredVariables(parent);
|
|
19638
20065
|
if (declared.length > 0)
|
|
19639
20066
|
return declared[0];
|
|
@@ -19646,14 +20073,14 @@ function referenceActsAsCallback(reference, iterationMethods, memoizationHooks)
|
|
|
19646
20073
|
const callExpression = findEnclosingCallExpression(reference.identifier);
|
|
19647
20074
|
if (!callExpression)
|
|
19648
20075
|
return false;
|
|
19649
|
-
if (
|
|
20076
|
+
if (isReactComponentHOC2(callExpression))
|
|
19650
20077
|
return false;
|
|
19651
20078
|
return isIterationOrMemoCallback(callExpression, iterationMethods, memoizationHooks);
|
|
19652
20079
|
}
|
|
19653
20080
|
function isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoizationHooks) {
|
|
19654
20081
|
const inlineCall = findEnclosingCallExpression(functionLike);
|
|
19655
20082
|
if (inlineCall) {
|
|
19656
|
-
if (
|
|
20083
|
+
if (isReactComponentHOC2(inlineCall))
|
|
19657
20084
|
return false;
|
|
19658
20085
|
return isIterationOrMemoCallback(inlineCall, iterationMethods, memoizationHooks);
|
|
19659
20086
|
}
|
|
@@ -19666,33 +20093,33 @@ function isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoi
|
|
|
19666
20093
|
return false;
|
|
19667
20094
|
}
|
|
19668
20095
|
var SHOULD_ASCEND_TYPES = new Set([
|
|
19669
|
-
|
|
19670
|
-
|
|
20096
|
+
TSESTree9.AST_NODE_TYPES.ConditionalExpression,
|
|
20097
|
+
TSESTree9.AST_NODE_TYPES.LogicalExpression
|
|
19671
20098
|
]);
|
|
19672
20099
|
var IS_FUNCTION_EXPRESSION = new Set([
|
|
19673
|
-
|
|
19674
|
-
|
|
20100
|
+
TSESTree9.AST_NODE_TYPES.FunctionExpression,
|
|
20101
|
+
TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression
|
|
19675
20102
|
]);
|
|
19676
20103
|
var CONTROL_FLOW_TYPES = new Set([
|
|
19677
|
-
|
|
19678
|
-
|
|
19679
|
-
|
|
19680
|
-
|
|
19681
|
-
|
|
19682
|
-
|
|
19683
|
-
|
|
19684
|
-
|
|
19685
|
-
|
|
19686
|
-
|
|
19687
|
-
|
|
19688
|
-
|
|
19689
|
-
|
|
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
|
|
19690
20117
|
]);
|
|
19691
20118
|
function isTopLevelReturn(node) {
|
|
19692
20119
|
let parent = ascendPastWrappers(node.parent);
|
|
19693
20120
|
if (!parent)
|
|
19694
20121
|
return false;
|
|
19695
|
-
if (parent.type ===
|
|
20122
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer)
|
|
19696
20123
|
parent = ascendPastWrappers(parent.parent);
|
|
19697
20124
|
if (!parent)
|
|
19698
20125
|
return false;
|
|
@@ -19700,11 +20127,11 @@ function isTopLevelReturn(node) {
|
|
|
19700
20127
|
parent = ascendPastWrappers(parent.parent);
|
|
19701
20128
|
if (!parent)
|
|
19702
20129
|
return false;
|
|
19703
|
-
if (parent.type ===
|
|
20130
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer)
|
|
19704
20131
|
parent = ascendPastWrappers(parent.parent);
|
|
19705
20132
|
if (!parent)
|
|
19706
20133
|
return false;
|
|
19707
|
-
if (parent.type ===
|
|
20134
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.ReturnStatement) {
|
|
19708
20135
|
let currentNode = ascendPastWrappers(parent.parent);
|
|
19709
20136
|
while (currentNode && CONTROL_FLOW_TYPES.has(currentNode.type))
|
|
19710
20137
|
currentNode = ascendPastWrappers(currentNode.parent);
|
|
@@ -19712,16 +20139,16 @@ function isTopLevelReturn(node) {
|
|
|
19712
20139
|
return false;
|
|
19713
20140
|
if (IS_FUNCTION_EXPRESSION.has(currentNode.type)) {
|
|
19714
20141
|
const functionParent = ascendPastWrappers(currentNode.parent);
|
|
19715
|
-
if (functionParent?.type ===
|
|
19716
|
-
return
|
|
20142
|
+
if (functionParent?.type === TSESTree9.AST_NODE_TYPES.CallExpression)
|
|
20143
|
+
return isReactComponentHOC2(functionParent);
|
|
19717
20144
|
return true;
|
|
19718
20145
|
}
|
|
19719
|
-
return currentNode.type ===
|
|
20146
|
+
return currentNode.type === TSESTree9.AST_NODE_TYPES.FunctionDeclaration;
|
|
19720
20147
|
}
|
|
19721
|
-
if (parent.type ===
|
|
20148
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
19722
20149
|
const functionParent = ascendPastWrappers(parent.parent);
|
|
19723
|
-
if (functionParent?.type ===
|
|
19724
|
-
return
|
|
20150
|
+
if (functionParent?.type === TSESTree9.AST_NODE_TYPES.CallExpression)
|
|
20151
|
+
return isReactComponentHOC2(functionParent);
|
|
19725
20152
|
return true;
|
|
19726
20153
|
}
|
|
19727
20154
|
return false;
|
|
@@ -19730,7 +20157,7 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
19730
20157
|
let parent = node.parent;
|
|
19731
20158
|
if (!parent)
|
|
19732
20159
|
return false;
|
|
19733
|
-
if (parent.type ===
|
|
20160
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
19734
20161
|
parent = parent.parent;
|
|
19735
20162
|
if (!parent)
|
|
19736
20163
|
return false;
|
|
@@ -19738,11 +20165,11 @@ function isIgnoredCallExpression(node, ignoreList) {
|
|
|
19738
20165
|
const maxDepth = 20;
|
|
19739
20166
|
for (let depth = 0;depth < maxDepth && parent; depth += 1) {
|
|
19740
20167
|
const { type: type3 } = parent;
|
|
19741
|
-
if (type3 ===
|
|
20168
|
+
if (type3 === TSESTree9.AST_NODE_TYPES.CallExpression) {
|
|
19742
20169
|
const { callee } = parent;
|
|
19743
|
-
if (callee.type ===
|
|
20170
|
+
if (callee.type === TSESTree9.AST_NODE_TYPES.Identifier)
|
|
19744
20171
|
return ignoreList.includes(callee.name);
|
|
19745
|
-
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)
|
|
19746
20173
|
return ignoreList.includes(`${callee.object.name}.${callee.property.name}`);
|
|
19747
20174
|
return false;
|
|
19748
20175
|
}
|
|
@@ -19754,35 +20181,35 @@ function isJSXPropValue(node) {
|
|
|
19754
20181
|
let { parent } = node;
|
|
19755
20182
|
if (!parent)
|
|
19756
20183
|
return false;
|
|
19757
|
-
while (parent && (parent.type ===
|
|
20184
|
+
while (parent && (parent.type === TSESTree9.AST_NODE_TYPES.ConditionalExpression || parent.type === TSESTree9.AST_NODE_TYPES.LogicalExpression))
|
|
19758
20185
|
parent = parent.parent;
|
|
19759
20186
|
if (!parent)
|
|
19760
20187
|
return false;
|
|
19761
|
-
if (parent.type ===
|
|
20188
|
+
if (parent.type === TSESTree9.AST_NODE_TYPES.JSXExpressionContainer) {
|
|
19762
20189
|
parent = parent.parent;
|
|
19763
20190
|
if (!parent)
|
|
19764
20191
|
return false;
|
|
19765
20192
|
}
|
|
19766
|
-
return parent.type ===
|
|
20193
|
+
return parent.type === TSESTree9.AST_NODE_TYPES.JSXAttribute;
|
|
19767
20194
|
}
|
|
19768
20195
|
function isTernaryJSXChild(node) {
|
|
19769
20196
|
let current = node.parent;
|
|
19770
20197
|
if (!current)
|
|
19771
20198
|
return false;
|
|
19772
20199
|
let foundTernary = false;
|
|
19773
|
-
while (current && (current.type ===
|
|
19774
|
-
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)
|
|
19775
20202
|
foundTernary = true;
|
|
19776
20203
|
current = current.parent;
|
|
19777
20204
|
}
|
|
19778
20205
|
if (!foundTernary || !current)
|
|
19779
20206
|
return false;
|
|
19780
|
-
if (current.type !==
|
|
20207
|
+
if (current.type !== TSESTree9.AST_NODE_TYPES.JSXExpressionContainer)
|
|
19781
20208
|
return false;
|
|
19782
20209
|
const containerParent = current.parent;
|
|
19783
20210
|
if (!containerParent)
|
|
19784
20211
|
return false;
|
|
19785
|
-
return containerParent.type ===
|
|
20212
|
+
return containerParent.type === TSESTree9.AST_NODE_TYPES.JSXElement || containerParent.type === TSESTree9.AST_NODE_TYPES.JSXFragment;
|
|
19786
20213
|
}
|
|
19787
20214
|
var docs3 = {
|
|
19788
20215
|
description: "Enforce key props on all React elements except top-level returns",
|
|
@@ -19801,7 +20228,7 @@ var requireReactComponentKeys = {
|
|
|
19801
20228
|
const isCallback = functionLike ? isFunctionUsedAsCallback(context, functionLike, iterationMethods, memoizationHooks) : false;
|
|
19802
20229
|
const isRoot = isTopLevelReturn(node);
|
|
19803
20230
|
if (isRoot && !isCallback) {
|
|
19804
|
-
if (!options3.allowRootKeys && node.type ===
|
|
20231
|
+
if (!options3.allowRootKeys && node.type === TSESTree9.AST_NODE_TYPES.JSXElement && hasKeyAttribute(node)) {
|
|
19805
20232
|
context.report({
|
|
19806
20233
|
messageId: "rootComponentWithKey",
|
|
19807
20234
|
node
|
|
@@ -19815,7 +20242,7 @@ var requireReactComponentKeys = {
|
|
|
19815
20242
|
return;
|
|
19816
20243
|
if (isTernaryJSXChild(node))
|
|
19817
20244
|
return;
|
|
19818
|
-
if (node.type ===
|
|
20245
|
+
if (node.type === TSESTree9.AST_NODE_TYPES.JSXFragment) {
|
|
19819
20246
|
context.report({
|
|
19820
20247
|
messageId: "missingKey",
|
|
19821
20248
|
node
|
|
@@ -19893,16 +20320,16 @@ var requireReactComponentKeys = {
|
|
|
19893
20320
|
var require_react_component_keys_default = requireReactComponentKeys;
|
|
19894
20321
|
|
|
19895
20322
|
// src/rules/use-exhaustive-dependencies.ts
|
|
19896
|
-
import { TSESTree as
|
|
20323
|
+
import { TSESTree as TSESTree10 } from "@typescript-eslint/types";
|
|
19897
20324
|
var FUNCTION_DECLARATIONS = new Set([
|
|
19898
|
-
|
|
19899
|
-
|
|
19900
|
-
|
|
20325
|
+
TSESTree10.AST_NODE_TYPES.FunctionExpression,
|
|
20326
|
+
TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
20327
|
+
TSESTree10.AST_NODE_TYPES.FunctionDeclaration
|
|
19901
20328
|
]);
|
|
19902
20329
|
var UNSTABLE_VALUES = new Set([
|
|
19903
20330
|
...FUNCTION_DECLARATIONS,
|
|
19904
|
-
|
|
19905
|
-
|
|
20331
|
+
TSESTree10.AST_NODE_TYPES.ObjectExpression,
|
|
20332
|
+
TSESTree10.AST_NODE_TYPES.ArrayExpression
|
|
19906
20333
|
]);
|
|
19907
20334
|
var testingMetrics = {
|
|
19908
20335
|
moduleLevelStableConst: 0,
|
|
@@ -19984,11 +20411,11 @@ var GLOBAL_BUILTINS = new Set([
|
|
|
19984
20411
|
"Window",
|
|
19985
20412
|
"Event"
|
|
19986
20413
|
]);
|
|
19987
|
-
function
|
|
20414
|
+
function getHookName3(node) {
|
|
19988
20415
|
const { callee } = node;
|
|
19989
|
-
if (callee.type ===
|
|
20416
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.Identifier)
|
|
19990
20417
|
return callee.name;
|
|
19991
|
-
if (callee.type ===
|
|
20418
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
19992
20419
|
return callee.property.name;
|
|
19993
20420
|
}
|
|
19994
20421
|
return;
|
|
@@ -19996,9 +20423,9 @@ function getHookName2(node) {
|
|
|
19996
20423
|
function getMemberExpressionDepth(node) {
|
|
19997
20424
|
let depth = 0;
|
|
19998
20425
|
let current = node;
|
|
19999
|
-
if (current.type ===
|
|
20426
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ChainExpression)
|
|
20000
20427
|
current = current.expression;
|
|
20001
|
-
while (current.type ===
|
|
20428
|
+
while (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression) {
|
|
20002
20429
|
depth += 1;
|
|
20003
20430
|
current = current.object;
|
|
20004
20431
|
}
|
|
@@ -20006,36 +20433,36 @@ function getMemberExpressionDepth(node) {
|
|
|
20006
20433
|
}
|
|
20007
20434
|
function getRootIdentifier(node) {
|
|
20008
20435
|
let current = node;
|
|
20009
|
-
if (current.type ===
|
|
20436
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ChainExpression)
|
|
20010
20437
|
current = current.expression;
|
|
20011
|
-
while (current.type ===
|
|
20012
|
-
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)
|
|
20013
20440
|
current = current.object;
|
|
20014
20441
|
else
|
|
20015
20442
|
current = current.expression;
|
|
20016
20443
|
}
|
|
20017
|
-
return current.type ===
|
|
20444
|
+
return current.type === TSESTree10.AST_NODE_TYPES.Identifier ? current : undefined;
|
|
20018
20445
|
}
|
|
20019
20446
|
function nodeToDependencyString(node, sourceCode) {
|
|
20020
20447
|
return sourceCode.getText(node);
|
|
20021
20448
|
}
|
|
20022
20449
|
function nodeToSafeDependencyPath(node, sourceCode) {
|
|
20023
|
-
if (node.type ===
|
|
20450
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.Identifier)
|
|
20024
20451
|
return node.name;
|
|
20025
|
-
if (node.type ===
|
|
20452
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.ChainExpression) {
|
|
20026
20453
|
return nodeToSafeDependencyPath(node.expression, sourceCode);
|
|
20027
20454
|
}
|
|
20028
20455
|
if (TS_RUNTIME_EXPRESSIONS.has(node.type)) {
|
|
20029
20456
|
const expr = node;
|
|
20030
20457
|
return nodeToSafeDependencyPath(expr.expression, sourceCode);
|
|
20031
20458
|
}
|
|
20032
|
-
if (node.type ===
|
|
20459
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.MemberExpression) {
|
|
20033
20460
|
const objectPath = nodeToSafeDependencyPath(node.object, sourceCode);
|
|
20034
20461
|
if (node.computed) {
|
|
20035
20462
|
const propertyText = sourceCode.getText(node.property);
|
|
20036
20463
|
return `${objectPath}[${propertyText}]`;
|
|
20037
20464
|
}
|
|
20038
|
-
const propertyName = node.property.type ===
|
|
20465
|
+
const propertyName = node.property.type === TSESTree10.AST_NODE_TYPES.Identifier ? node.property.name : "";
|
|
20039
20466
|
const separator = node.optional ? "?." : ".";
|
|
20040
20467
|
return `${objectPath}${separator}${propertyName}`;
|
|
20041
20468
|
}
|
|
@@ -20044,13 +20471,13 @@ function nodeToSafeDependencyPath(node, sourceCode) {
|
|
|
20044
20471
|
function isStableArrayIndex(stableResult, node, identifierName) {
|
|
20045
20472
|
if (!stableResult)
|
|
20046
20473
|
return false;
|
|
20047
|
-
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) {
|
|
20048
20475
|
return false;
|
|
20049
20476
|
}
|
|
20050
20477
|
const elements = node.id.elements;
|
|
20051
20478
|
let index2 = 0;
|
|
20052
20479
|
for (const element of elements) {
|
|
20053
|
-
if (element.type ===
|
|
20480
|
+
if (element.type === TSESTree10.AST_NODE_TYPES.Identifier && element.name === identifierName) {
|
|
20054
20481
|
return stableResult.has(index2);
|
|
20055
20482
|
}
|
|
20056
20483
|
index2 += 1;
|
|
@@ -20059,9 +20486,9 @@ function isStableArrayIndex(stableResult, node, identifierName) {
|
|
|
20059
20486
|
}
|
|
20060
20487
|
function isStableHookValue(init, node, identifierName, stableHooks) {
|
|
20061
20488
|
const castInit = init;
|
|
20062
|
-
if (castInit.type !==
|
|
20489
|
+
if (castInit.type !== TSESTree10.AST_NODE_TYPES.CallExpression)
|
|
20063
20490
|
return false;
|
|
20064
|
-
const hookName =
|
|
20491
|
+
const hookName = getHookName3(castInit);
|
|
20065
20492
|
if (!hookName)
|
|
20066
20493
|
return false;
|
|
20067
20494
|
const stableResult = stableHooks.get(hookName);
|
|
@@ -20079,34 +20506,34 @@ function isStableValue(variable, identifierName, stableHooks) {
|
|
|
20079
20506
|
const { node, type: type3 } = definition;
|
|
20080
20507
|
if (STABLE_VALUE_TYPES.has(type3))
|
|
20081
20508
|
return true;
|
|
20082
|
-
if (type3 === "Variable" && node.type ===
|
|
20509
|
+
if (type3 === "Variable" && node.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator) {
|
|
20083
20510
|
const parent = node.parent;
|
|
20084
|
-
if (!parent || parent.type !==
|
|
20511
|
+
if (!parent || parent.type !== TSESTree10.AST_NODE_TYPES.VariableDeclaration || parent.kind !== "const")
|
|
20085
20512
|
continue;
|
|
20086
20513
|
const init = node.init;
|
|
20087
20514
|
if (init && isStableHookValue(init, node, identifierName, stableHooks))
|
|
20088
20515
|
return true;
|
|
20089
|
-
if (init?.type ===
|
|
20516
|
+
if (init?.type === TSESTree10.AST_NODE_TYPES.CallExpression) {
|
|
20090
20517
|
const { callee } = init;
|
|
20091
|
-
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") {
|
|
20092
20519
|
return true;
|
|
20093
20520
|
}
|
|
20094
|
-
if (callee.type ===
|
|
20521
|
+
if (callee.type === TSESTree10.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree10.AST_NODE_TYPES.Identifier && callee.property.name === "map") {
|
|
20095
20522
|
return true;
|
|
20096
20523
|
}
|
|
20097
20524
|
}
|
|
20098
20525
|
if (init) {
|
|
20099
|
-
if (init.type ===
|
|
20526
|
+
if (init.type === TSESTree10.AST_NODE_TYPES.Literal || init.type === TSESTree10.AST_NODE_TYPES.TemplateLiteral) {
|
|
20100
20527
|
return true;
|
|
20101
20528
|
}
|
|
20102
|
-
if (init.type ===
|
|
20529
|
+
if (init.type === TSESTree10.AST_NODE_TYPES.UnaryExpression && init.argument.type === TSESTree10.AST_NODE_TYPES.Literal) {
|
|
20103
20530
|
return true;
|
|
20104
20531
|
}
|
|
20105
20532
|
}
|
|
20106
20533
|
const variableDefinition = variable.defs.find((definition2) => definition2.node === node);
|
|
20107
|
-
if (variableDefinition && variableDefinition.node.type ===
|
|
20534
|
+
if (variableDefinition && variableDefinition.node.type === TSESTree10.AST_NODE_TYPES.VariableDeclarator) {
|
|
20108
20535
|
const declarationParent = variableDefinition.node.parent?.parent;
|
|
20109
|
-
if (declarationParent && (declarationParent.type ===
|
|
20536
|
+
if (declarationParent && (declarationParent.type === TSESTree10.AST_NODE_TYPES.Program || declarationParent.type === TSESTree10.AST_NODE_TYPES.ExportNamedDeclaration)) {
|
|
20110
20537
|
testingMetrics.moduleLevelStableConst += 1;
|
|
20111
20538
|
return true;
|
|
20112
20539
|
}
|
|
@@ -20119,14 +20546,14 @@ function findTopmostMemberExpression(node) {
|
|
|
20119
20546
|
let current = node;
|
|
20120
20547
|
let { parent } = node;
|
|
20121
20548
|
while (parent) {
|
|
20122
|
-
if (parent.type ===
|
|
20123
|
-
if (current.type ===
|
|
20549
|
+
if (parent.type === TSESTree10.AST_NODE_TYPES.CallExpression && parent.callee === current) {
|
|
20550
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression)
|
|
20124
20551
|
return current.object;
|
|
20125
20552
|
break;
|
|
20126
20553
|
}
|
|
20127
|
-
const isMemberParent = parent.type ===
|
|
20128
|
-
const isChainParent = parent.type ===
|
|
20129
|
-
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;
|
|
20130
20557
|
if (!isMemberParent && !isChainParent && !isNonNullParent)
|
|
20131
20558
|
break;
|
|
20132
20559
|
current = parent;
|
|
@@ -20135,21 +20562,21 @@ function findTopmostMemberExpression(node) {
|
|
|
20135
20562
|
return current;
|
|
20136
20563
|
}
|
|
20137
20564
|
var IS_CEASE_BOUNDARY = new Set([
|
|
20138
|
-
|
|
20139
|
-
|
|
20140
|
-
|
|
20141
|
-
|
|
20565
|
+
TSESTree10.AST_NODE_TYPES.FunctionDeclaration,
|
|
20566
|
+
TSESTree10.AST_NODE_TYPES.FunctionExpression,
|
|
20567
|
+
TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression,
|
|
20568
|
+
TSESTree10.AST_NODE_TYPES.VariableDeclarator
|
|
20142
20569
|
]);
|
|
20143
20570
|
var TS_RUNTIME_EXPRESSIONS = new Set([
|
|
20144
|
-
|
|
20145
|
-
|
|
20146
|
-
|
|
20147
|
-
|
|
20148
|
-
|
|
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
|
|
20149
20576
|
]);
|
|
20150
20577
|
function isComputedPropertyIdentifier(identifier3) {
|
|
20151
20578
|
const parent = identifier3.parent;
|
|
20152
|
-
return parent?.type ===
|
|
20579
|
+
return parent?.type === TSESTree10.AST_NODE_TYPES.Property && parent.computed && parent.key === identifier3;
|
|
20153
20580
|
}
|
|
20154
20581
|
function isInTypePosition(identifier3) {
|
|
20155
20582
|
let parent = identifier3.parent;
|
|
@@ -20203,10 +20630,10 @@ function resolveFunctionReference(identifier3, scope) {
|
|
|
20203
20630
|
return;
|
|
20204
20631
|
for (const definition of variable.defs) {
|
|
20205
20632
|
const { node } = definition;
|
|
20206
|
-
if (node.type ===
|
|
20633
|
+
if (node.type === TSESTree10.AST_NODE_TYPES.FunctionDeclaration) {
|
|
20207
20634
|
return node;
|
|
20208
20635
|
}
|
|
20209
|
-
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)) {
|
|
20210
20637
|
return node.init;
|
|
20211
20638
|
}
|
|
20212
20639
|
}
|
|
@@ -20216,7 +20643,7 @@ function collectCaptures(node, sourceCode) {
|
|
|
20216
20643
|
const captures = new Array;
|
|
20217
20644
|
const captureSet = new Set;
|
|
20218
20645
|
function visit(current) {
|
|
20219
|
-
if (current.type ===
|
|
20646
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
20220
20647
|
const { name } = current;
|
|
20221
20648
|
if (captureSet.has(name) || GLOBAL_BUILTINS.has(name) || isInTypePosition(current))
|
|
20222
20649
|
return;
|
|
@@ -20258,21 +20685,21 @@ function collectCaptures(node, sourceCode) {
|
|
|
20258
20685
|
}
|
|
20259
20686
|
}
|
|
20260
20687
|
}
|
|
20261
|
-
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) {
|
|
20262
20689
|
visit(current.expression);
|
|
20263
20690
|
return;
|
|
20264
20691
|
}
|
|
20265
|
-
if (current.type ===
|
|
20692
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.MemberExpression) {
|
|
20266
20693
|
visit(current.object);
|
|
20267
20694
|
if (current.computed)
|
|
20268
20695
|
visit(current.property);
|
|
20269
20696
|
return;
|
|
20270
20697
|
}
|
|
20271
|
-
if (current.type ===
|
|
20698
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.ChainExpression) {
|
|
20272
20699
|
visit(current.expression);
|
|
20273
20700
|
return;
|
|
20274
20701
|
}
|
|
20275
|
-
if (current.type ===
|
|
20702
|
+
if (current.type === TSESTree10.AST_NODE_TYPES.Property) {
|
|
20276
20703
|
if (current.computed)
|
|
20277
20704
|
visit(current.key);
|
|
20278
20705
|
visit(current.value);
|
|
@@ -20297,7 +20724,7 @@ function parseDependencies(node, sourceCode) {
|
|
|
20297
20724
|
for (const element of node.elements) {
|
|
20298
20725
|
if (!element)
|
|
20299
20726
|
continue;
|
|
20300
|
-
const actualNode = element.type ===
|
|
20727
|
+
const actualNode = element.type === TSESTree10.AST_NODE_TYPES.SpreadElement ? element.argument : element;
|
|
20301
20728
|
const name = nodeToDependencyString(actualNode, sourceCode);
|
|
20302
20729
|
const depth = getMemberExpressionDepth(actualNode);
|
|
20303
20730
|
dependencies4.push({
|
|
@@ -20362,7 +20789,7 @@ var useExhaustiveDependencies = {
|
|
|
20362
20789
|
return {
|
|
20363
20790
|
CallExpression(node) {
|
|
20364
20791
|
const callNode = node;
|
|
20365
|
-
const hookName =
|
|
20792
|
+
const hookName = getHookName3(callNode);
|
|
20366
20793
|
if (hookName === undefined || hookName === "")
|
|
20367
20794
|
return;
|
|
20368
20795
|
const hookConfig = hookConfigs.get(hookName);
|
|
@@ -20374,9 +20801,9 @@ var useExhaustiveDependencies = {
|
|
|
20374
20801
|
if (closureArgument === undefined)
|
|
20375
20802
|
return;
|
|
20376
20803
|
let closureFunction;
|
|
20377
|
-
if (closureArgument.type ===
|
|
20804
|
+
if (closureArgument.type === TSESTree10.AST_NODE_TYPES.ArrowFunctionExpression || closureArgument.type === TSESTree10.AST_NODE_TYPES.FunctionExpression) {
|
|
20378
20805
|
closureFunction = closureArgument;
|
|
20379
|
-
} else if (closureArgument.type ===
|
|
20806
|
+
} else if (closureArgument.type === TSESTree10.AST_NODE_TYPES.Identifier) {
|
|
20380
20807
|
const scope = getScope(callNode);
|
|
20381
20808
|
closureFunction = resolveFunctionReference(closureArgument, scope);
|
|
20382
20809
|
}
|
|
@@ -20410,7 +20837,7 @@ var useExhaustiveDependencies = {
|
|
|
20410
20837
|
}
|
|
20411
20838
|
if (!dependenciesArgument)
|
|
20412
20839
|
return;
|
|
20413
|
-
if (dependenciesArgument.type !==
|
|
20840
|
+
if (dependenciesArgument.type !== TSESTree10.AST_NODE_TYPES.ArrayExpression)
|
|
20414
20841
|
return;
|
|
20415
20842
|
const dependenciesArray = dependenciesArgument;
|
|
20416
20843
|
const captures = collectCaptures(closureFunction, context.sourceCode);
|
|
@@ -20491,7 +20918,7 @@ var useExhaustiveDependencies = {
|
|
|
20491
20918
|
context.report({
|
|
20492
20919
|
data: { name: firstMissing.usagePath },
|
|
20493
20920
|
messageId: "missingDependency",
|
|
20494
|
-
node: lastDependency?.node
|
|
20921
|
+
node: lastDependency?.node ?? dependenciesArray,
|
|
20495
20922
|
suggest: [
|
|
20496
20923
|
{
|
|
20497
20924
|
desc: `Add '${firstMissing.usagePath}' to dependencies array`,
|
|
@@ -20506,7 +20933,7 @@ var useExhaustiveDependencies = {
|
|
|
20506
20933
|
context.report({
|
|
20507
20934
|
data: { names: missingNames },
|
|
20508
20935
|
messageId: "missingDependencies",
|
|
20509
|
-
node: lastDependency?.node
|
|
20936
|
+
node: lastDependency?.node ?? dependenciesArray,
|
|
20510
20937
|
suggest: [
|
|
20511
20938
|
{
|
|
20512
20939
|
desc: "Add missing dependencies to array",
|
|
@@ -20620,33 +21047,33 @@ var useExhaustiveDependencies = {
|
|
|
20620
21047
|
var use_exhaustive_dependencies_default = useExhaustiveDependencies;
|
|
20621
21048
|
|
|
20622
21049
|
// src/rules/use-hook-at-top-level.ts
|
|
20623
|
-
import { TSESTree as
|
|
21050
|
+
import { TSESTree as TSESTree11 } from "@typescript-eslint/types";
|
|
20624
21051
|
var HOOK_NAME_PATTERN = /^use[A-Z]/;
|
|
20625
|
-
var
|
|
21052
|
+
var COMPONENT_NAME_PATTERN2 = /^[A-Z]/;
|
|
20626
21053
|
function isReactHook(name) {
|
|
20627
21054
|
return HOOK_NAME_PATTERN.test(name);
|
|
20628
21055
|
}
|
|
20629
21056
|
function isComponent(name) {
|
|
20630
|
-
return
|
|
21057
|
+
return COMPONENT_NAME_PATTERN2.test(name);
|
|
20631
21058
|
}
|
|
20632
21059
|
function isComponentOrHook(node) {
|
|
20633
|
-
if (node.type ===
|
|
21060
|
+
if (node.type === TSESTree11.AST_NODE_TYPES.FunctionDeclaration && node.id) {
|
|
20634
21061
|
const { name } = node.id;
|
|
20635
21062
|
return isComponent(name) || isReactHook(name);
|
|
20636
21063
|
}
|
|
20637
|
-
if (node.type ===
|
|
21064
|
+
if (node.type === TSESTree11.AST_NODE_TYPES.FunctionExpression || node.type === TSESTree11.AST_NODE_TYPES.ArrowFunctionExpression) {
|
|
20638
21065
|
const { parent } = node;
|
|
20639
21066
|
if (!parent)
|
|
20640
21067
|
return false;
|
|
20641
|
-
if (parent.type ===
|
|
21068
|
+
if (parent.type === TSESTree11.AST_NODE_TYPES.VariableDeclarator && parent.id.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20642
21069
|
const { name } = parent.id;
|
|
20643
21070
|
return isComponent(name) || isReactHook(name);
|
|
20644
21071
|
}
|
|
20645
|
-
if (parent.type ===
|
|
21072
|
+
if (parent.type === TSESTree11.AST_NODE_TYPES.Property && parent.key.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20646
21073
|
const { name } = parent.key;
|
|
20647
21074
|
return isComponent(name) || isReactHook(name);
|
|
20648
21075
|
}
|
|
20649
|
-
if (parent.type ===
|
|
21076
|
+
if (parent.type === TSESTree11.AST_NODE_TYPES.MethodDefinition && parent.key.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20650
21077
|
const { name } = parent.key;
|
|
20651
21078
|
return isComponent(name) || isReactHook(name);
|
|
20652
21079
|
}
|
|
@@ -20655,24 +21082,24 @@ function isComponentOrHook(node) {
|
|
|
20655
21082
|
}
|
|
20656
21083
|
function isHookCall(node) {
|
|
20657
21084
|
const { callee } = node;
|
|
20658
|
-
if (callee.type ===
|
|
21085
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
20659
21086
|
return isReactHook(callee.name);
|
|
20660
|
-
if (callee.type ===
|
|
21087
|
+
if (callee.type === TSESTree11.AST_NODE_TYPES.MemberExpression && callee.property.type === TSESTree11.AST_NODE_TYPES.Identifier)
|
|
20661
21088
|
return isReactHook(callee.property.name);
|
|
20662
21089
|
return false;
|
|
20663
21090
|
}
|
|
20664
|
-
var
|
|
20665
|
-
|
|
20666
|
-
|
|
20667
|
-
|
|
21091
|
+
var FUNCTION_BOUNDARIES2 = new Set([
|
|
21092
|
+
TSESTree11.AST_NODE_TYPES.FunctionDeclaration,
|
|
21093
|
+
TSESTree11.AST_NODE_TYPES.FunctionExpression,
|
|
21094
|
+
TSESTree11.AST_NODE_TYPES.ArrowFunctionExpression
|
|
20668
21095
|
]);
|
|
20669
21096
|
function isInFinallyBlock(node) {
|
|
20670
21097
|
let current = node.parent;
|
|
20671
21098
|
const maxDepth = 20;
|
|
20672
21099
|
for (let depth = 0;depth < maxDepth && current; depth += 1) {
|
|
20673
|
-
if (
|
|
21100
|
+
if (FUNCTION_BOUNDARIES2.has(current.type))
|
|
20674
21101
|
return false;
|
|
20675
|
-
if (current.type ===
|
|
21102
|
+
if (current.type === TSESTree11.AST_NODE_TYPES.TryStatement) {
|
|
20676
21103
|
let checkNode = node;
|
|
20677
21104
|
while (checkNode && checkNode !== current) {
|
|
20678
21105
|
if (checkNode === current.finalizer)
|
|
@@ -20695,7 +21122,7 @@ function isRecursiveCall(node, functionName) {
|
|
|
20695
21122
|
}
|
|
20696
21123
|
var useHookAtTopLevel = {
|
|
20697
21124
|
create(context) {
|
|
20698
|
-
const configuration = context.options[0]
|
|
21125
|
+
const configuration = context.options[0] ?? {};
|
|
20699
21126
|
const contextStack = new Array;
|
|
20700
21127
|
let currentFunctionName;
|
|
20701
21128
|
const importSourceMap = new Map;
|
|
@@ -20720,14 +21147,14 @@ var useHookAtTopLevel = {
|
|
|
20720
21147
|
if (ignoreHooks?.includes(hookName))
|
|
20721
21148
|
return true;
|
|
20722
21149
|
if (importSources && Object.keys(importSources).length > 0) {
|
|
20723
|
-
if (node.callee.type ===
|
|
20724
|
-
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;
|
|
20725
21152
|
if (objectName && importSources[objectName] === false)
|
|
20726
21153
|
return true;
|
|
20727
21154
|
if (objectName && importSources[objectName] === true)
|
|
20728
21155
|
return false;
|
|
20729
21156
|
}
|
|
20730
|
-
if (node.callee.type ===
|
|
21157
|
+
if (node.callee.type === TSESTree11.AST_NODE_TYPES.Identifier) {
|
|
20731
21158
|
const importSource = importSourceMap.get(hookName);
|
|
20732
21159
|
if (importSource && importSources[importSource] === false)
|
|
20733
21160
|
return true;
|
|
@@ -20742,7 +21169,7 @@ var useHookAtTopLevel = {
|
|
|
20742
21169
|
const current = getCurrentContext();
|
|
20743
21170
|
const depth = current ? current.functionDepth + 1 : 0;
|
|
20744
21171
|
const isComponentOrHookFlag = isComponentOrHook(functionNode);
|
|
20745
|
-
if (functionNode.type ===
|
|
21172
|
+
if (functionNode.type === TSESTree11.AST_NODE_TYPES.FunctionDeclaration && functionNode.id)
|
|
20746
21173
|
currentFunctionName = functionNode.id.name;
|
|
20747
21174
|
if (current?.isComponentOrHook) {
|
|
20748
21175
|
pushContext({
|
|
@@ -20780,7 +21207,7 @@ var useHookAtTopLevel = {
|
|
|
20780
21207
|
if (!isHookCall(callNode))
|
|
20781
21208
|
return;
|
|
20782
21209
|
const { callee } = callNode;
|
|
20783
|
-
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;
|
|
20784
21211
|
if (!hookName || shouldIgnoreHook(hookName, callNode))
|
|
20785
21212
|
return;
|
|
20786
21213
|
const current = getCurrentContext();
|
|
@@ -20878,10 +21305,10 @@ var useHookAtTopLevel = {
|
|
|
20878
21305
|
if (!configuration.importSources || Object.keys(configuration.importSources).length === 0)
|
|
20879
21306
|
return;
|
|
20880
21307
|
for (const specifier of importNode.specifiers) {
|
|
20881
|
-
if (specifier.type !==
|
|
21308
|
+
if (specifier.type !== TSESTree11.AST_NODE_TYPES.ImportSpecifier)
|
|
20882
21309
|
continue;
|
|
20883
21310
|
const { imported } = specifier;
|
|
20884
|
-
if (imported.type !==
|
|
21311
|
+
if (imported.type !== TSESTree11.AST_NODE_TYPES.Identifier)
|
|
20885
21312
|
continue;
|
|
20886
21313
|
if (isReactHook(imported.name))
|
|
20887
21314
|
importSourceMap.set(specifier.local.name, source);
|
|
@@ -21017,6 +21444,19 @@ function createReactKeysOptions(options3 = {}) {
|
|
|
21017
21444
|
...options3
|
|
21018
21445
|
};
|
|
21019
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
|
+
}
|
|
21020
21460
|
function createUseExhaustiveDependenciesOptions(options3 = {}) {
|
|
21021
21461
|
return {
|
|
21022
21462
|
hooks: [],
|
|
@@ -21050,6 +21490,7 @@ var rules = {
|
|
|
21050
21490
|
"no-async-constructor": no_async_constructor_default,
|
|
21051
21491
|
"no-color3-constructor": no_color3_constructor_default,
|
|
21052
21492
|
"no-commented-code": no_commented_code_default,
|
|
21493
|
+
"no-god-components": no_god_components_default,
|
|
21053
21494
|
"no-instance-methods-without-this": no_instance_methods_without_this_default,
|
|
21054
21495
|
"no-print": no_print_default,
|
|
21055
21496
|
"no-shorthand-names": no_shorthand_names_default,
|
|
@@ -21075,6 +21516,7 @@ var recommended = {
|
|
|
21075
21516
|
"cease-nonsense/no-async-constructor": "error",
|
|
21076
21517
|
"cease-nonsense/no-color3-constructor": "error",
|
|
21077
21518
|
"cease-nonsense/no-instance-methods-without-this": "error",
|
|
21519
|
+
"cease-nonsense/no-god-components": "error",
|
|
21078
21520
|
"cease-nonsense/no-print": "error",
|
|
21079
21521
|
"cease-nonsense/no-shorthand-names": "error",
|
|
21080
21522
|
"cease-nonsense/no-warn": "error",
|
|
@@ -21102,10 +21544,11 @@ export {
|
|
|
21102
21544
|
createNoUselessUseSpringOptions,
|
|
21103
21545
|
createNoShorthandOptions,
|
|
21104
21546
|
createNoInstanceMethodsOptions,
|
|
21547
|
+
createNoGodComponentsOptions,
|
|
21105
21548
|
createHookConfiguration,
|
|
21106
21549
|
createEffectFunctionOptions,
|
|
21107
21550
|
createComplexityConfiguration,
|
|
21108
21551
|
createBanInstancesOptions
|
|
21109
21552
|
};
|
|
21110
21553
|
|
|
21111
|
-
//# debugId=
|
|
21554
|
+
//# debugId=BE95AD3504B774A764756E2164756E21
|