eslint-plugin-react-hooks 7.1.0-canary-b45bb335-20251211 → 7.1.0-canary-b061b597-20251212
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.
|
@@ -26148,7 +26148,7 @@ function lowerIdentifierForAssignment(builder, loc, kind, path) {
|
|
|
26148
26148
|
return place;
|
|
26149
26149
|
}
|
|
26150
26150
|
function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind) {
|
|
26151
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
26151
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
26152
26152
|
const lvalueNode = lvaluePath.node;
|
|
26153
26153
|
switch (lvalueNode.type) {
|
|
26154
26154
|
case 'Identifier': {
|
|
@@ -26381,13 +26381,14 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26381
26381
|
pattern: {
|
|
26382
26382
|
kind: 'ArrayPattern',
|
|
26383
26383
|
items,
|
|
26384
|
+
loc: (_p = lvalue.node.loc) !== null && _p !== void 0 ? _p : GeneratedSource,
|
|
26384
26385
|
},
|
|
26385
26386
|
},
|
|
26386
26387
|
value,
|
|
26387
26388
|
loc,
|
|
26388
26389
|
});
|
|
26389
26390
|
for (const { place, path } of followups) {
|
|
26390
|
-
lowerAssignment(builder, (
|
|
26391
|
+
lowerAssignment(builder, (_q = path.node.loc) !== null && _q !== void 0 ? _q : loc, kind, path, place, assignmentKind);
|
|
26391
26392
|
}
|
|
26392
26393
|
return { kind: 'LoadLocal', place: temporary, loc: value.loc };
|
|
26393
26394
|
}
|
|
@@ -26409,14 +26410,14 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26409
26410
|
builder.errors.push({
|
|
26410
26411
|
reason: `(BuildHIR::lowerAssignment) Handle ${argument.node.type} rest element in ObjectPattern`,
|
|
26411
26412
|
category: ErrorCategory.Todo,
|
|
26412
|
-
loc: (
|
|
26413
|
+
loc: (_r = argument.node.loc) !== null && _r !== void 0 ? _r : null,
|
|
26413
26414
|
suggestions: null,
|
|
26414
26415
|
});
|
|
26415
26416
|
continue;
|
|
26416
26417
|
}
|
|
26417
26418
|
if (forceTemporaries ||
|
|
26418
26419
|
getStoreKind(builder, argument) === 'StoreContext') {
|
|
26419
|
-
const temp = buildTemporaryPlace(builder, (
|
|
26420
|
+
const temp = buildTemporaryPlace(builder, (_s = property.node.loc) !== null && _s !== void 0 ? _s : GeneratedSource);
|
|
26420
26421
|
promoteTemporary(temp.identifier);
|
|
26421
26422
|
properties.push({
|
|
26422
26423
|
kind: 'Spread',
|
|
@@ -26425,7 +26426,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26425
26426
|
followups.push({ place: temp, path: argument });
|
|
26426
26427
|
}
|
|
26427
26428
|
else {
|
|
26428
|
-
const identifier = lowerIdentifierForAssignment(builder, (
|
|
26429
|
+
const identifier = lowerIdentifierForAssignment(builder, (_t = property.node.loc) !== null && _t !== void 0 ? _t : GeneratedSource, kind, argument);
|
|
26429
26430
|
if (identifier === null) {
|
|
26430
26431
|
continue;
|
|
26431
26432
|
}
|
|
@@ -26433,7 +26434,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26433
26434
|
builder.errors.push({
|
|
26434
26435
|
category: ErrorCategory.Todo,
|
|
26435
26436
|
reason: 'Expected reassignment of globals to enable forceTemporaries',
|
|
26436
|
-
loc: (
|
|
26437
|
+
loc: (_u = property.node.loc) !== null && _u !== void 0 ? _u : GeneratedSource,
|
|
26437
26438
|
});
|
|
26438
26439
|
continue;
|
|
26439
26440
|
}
|
|
@@ -26448,7 +26449,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26448
26449
|
builder.errors.push({
|
|
26449
26450
|
reason: `(BuildHIR::lowerAssignment) Handle ${property.type} properties in ObjectPattern`,
|
|
26450
26451
|
category: ErrorCategory.Todo,
|
|
26451
|
-
loc: (
|
|
26452
|
+
loc: (_v = property.node.loc) !== null && _v !== void 0 ? _v : null,
|
|
26452
26453
|
suggestions: null,
|
|
26453
26454
|
});
|
|
26454
26455
|
continue;
|
|
@@ -26457,7 +26458,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26457
26458
|
builder.errors.push({
|
|
26458
26459
|
reason: `(BuildHIR::lowerAssignment) Handle computed properties in ObjectPattern`,
|
|
26459
26460
|
category: ErrorCategory.Todo,
|
|
26460
|
-
loc: (
|
|
26461
|
+
loc: (_w = property.node.loc) !== null && _w !== void 0 ? _w : null,
|
|
26461
26462
|
suggestions: null,
|
|
26462
26463
|
});
|
|
26463
26464
|
continue;
|
|
@@ -26471,7 +26472,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26471
26472
|
builder.errors.push({
|
|
26472
26473
|
reason: `(BuildHIR::lowerAssignment) Expected object property value to be an LVal, got: ${element.type}`,
|
|
26473
26474
|
category: ErrorCategory.Todo,
|
|
26474
|
-
loc: (
|
|
26475
|
+
loc: (_x = element.node.loc) !== null && _x !== void 0 ? _x : null,
|
|
26475
26476
|
suggestions: null,
|
|
26476
26477
|
});
|
|
26477
26478
|
continue;
|
|
@@ -26480,7 +26481,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26480
26481
|
!forceTemporaries &&
|
|
26481
26482
|
(assignmentKind === 'Assignment' ||
|
|
26482
26483
|
getStoreKind(builder, element) === 'StoreLocal')) {
|
|
26483
|
-
const identifier = lowerIdentifierForAssignment(builder, (
|
|
26484
|
+
const identifier = lowerIdentifierForAssignment(builder, (_y = element.node.loc) !== null && _y !== void 0 ? _y : GeneratedSource, kind, element);
|
|
26484
26485
|
if (identifier === null) {
|
|
26485
26486
|
continue;
|
|
26486
26487
|
}
|
|
@@ -26488,7 +26489,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26488
26489
|
builder.errors.push({
|
|
26489
26490
|
category: ErrorCategory.Todo,
|
|
26490
26491
|
reason: 'Expected reassignment of globals to enable forceTemporaries',
|
|
26491
|
-
loc: (
|
|
26492
|
+
loc: (_z = element.node.loc) !== null && _z !== void 0 ? _z : GeneratedSource,
|
|
26492
26493
|
});
|
|
26493
26494
|
continue;
|
|
26494
26495
|
}
|
|
@@ -26500,7 +26501,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26500
26501
|
});
|
|
26501
26502
|
}
|
|
26502
26503
|
else {
|
|
26503
|
-
const temp = buildTemporaryPlace(builder, (
|
|
26504
|
+
const temp = buildTemporaryPlace(builder, (_0 = element.node.loc) !== null && _0 !== void 0 ? _0 : GeneratedSource);
|
|
26504
26505
|
promoteTemporary(temp.identifier);
|
|
26505
26506
|
properties.push({
|
|
26506
26507
|
kind: 'ObjectProperty',
|
|
@@ -26519,19 +26520,20 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26519
26520
|
pattern: {
|
|
26520
26521
|
kind: 'ObjectPattern',
|
|
26521
26522
|
properties,
|
|
26523
|
+
loc: (_1 = lvalue.node.loc) !== null && _1 !== void 0 ? _1 : GeneratedSource,
|
|
26522
26524
|
},
|
|
26523
26525
|
},
|
|
26524
26526
|
value,
|
|
26525
26527
|
loc,
|
|
26526
26528
|
});
|
|
26527
26529
|
for (const { place, path } of followups) {
|
|
26528
|
-
lowerAssignment(builder, (
|
|
26530
|
+
lowerAssignment(builder, (_2 = path.node.loc) !== null && _2 !== void 0 ? _2 : loc, kind, path, place, assignmentKind);
|
|
26529
26531
|
}
|
|
26530
26532
|
return { kind: 'LoadLocal', place: temporary, loc: value.loc };
|
|
26531
26533
|
}
|
|
26532
26534
|
case 'AssignmentPattern': {
|
|
26533
26535
|
const lvalue = lvaluePath;
|
|
26534
|
-
const loc = (
|
|
26536
|
+
const loc = (_3 = lvalue.node.loc) !== null && _3 !== void 0 ? _3 : GeneratedSource;
|
|
26535
26537
|
const temp = buildTemporaryPlace(builder, loc);
|
|
26536
26538
|
const testBlock = builder.reserve('value');
|
|
26537
26539
|
const continuationBlock = builder.reserve(builder.currentBlockKind());
|
|
@@ -26602,7 +26604,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26602
26604
|
builder.errors.push({
|
|
26603
26605
|
reason: `(BuildHIR::lowerAssignment) Handle ${lvaluePath.type} assignments`,
|
|
26604
26606
|
category: ErrorCategory.Todo,
|
|
26605
|
-
loc: (
|
|
26607
|
+
loc: (_4 = lvaluePath.node.loc) !== null && _4 !== void 0 ? _4 : null,
|
|
26606
26608
|
suggestions: null,
|
|
26607
26609
|
});
|
|
26608
26610
|
return { kind: 'UnsupportedNode', node: lvalueNode, loc };
|
|
@@ -37853,7 +37855,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
|
37853
37855
|
const name = convertIdentifier(identifier);
|
|
37854
37856
|
outputComments.push(name.name);
|
|
37855
37857
|
if (!cx.hasDeclared(identifier)) {
|
|
37856
|
-
statements.push(libExports$1.variableDeclaration('let', [
|
|
37858
|
+
statements.push(libExports$1.variableDeclaration('let', [createVariableDeclarator(name, null)]));
|
|
37857
37859
|
}
|
|
37858
37860
|
cacheLoads.push({ name, index, value: wrapCacheDep(cx, name) });
|
|
37859
37861
|
cx.declare(identifier);
|
|
@@ -38334,7 +38336,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
|
38334
38336
|
suggestions: null,
|
|
38335
38337
|
});
|
|
38336
38338
|
return createVariableDeclaration(instr.loc, 'const', [
|
|
38337
|
-
|
|
38339
|
+
createVariableDeclarator(codegenLValue(cx, lvalue), value),
|
|
38338
38340
|
]);
|
|
38339
38341
|
}
|
|
38340
38342
|
case InstructionKind.Function: {
|
|
@@ -38391,7 +38393,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
|
38391
38393
|
suggestions: null,
|
|
38392
38394
|
});
|
|
38393
38395
|
return createVariableDeclaration(instr.loc, 'let', [
|
|
38394
|
-
|
|
38396
|
+
createVariableDeclarator(codegenLValue(cx, lvalue), value),
|
|
38395
38397
|
]);
|
|
38396
38398
|
}
|
|
38397
38399
|
case InstructionKind.Reassign: {
|
|
@@ -38599,6 +38601,9 @@ function withLoc(fn) {
|
|
|
38599
38601
|
return node;
|
|
38600
38602
|
};
|
|
38601
38603
|
}
|
|
38604
|
+
const createIdentifier = withLoc(libExports$1.identifier);
|
|
38605
|
+
const createArrayPattern = withLoc(libExports$1.arrayPattern);
|
|
38606
|
+
const createObjectPattern = withLoc(libExports$1.objectPattern);
|
|
38602
38607
|
const createBinaryExpression = withLoc(libExports$1.binaryExpression);
|
|
38603
38608
|
const createExpressionStatement = withLoc(libExports$1.expressionStatement);
|
|
38604
38609
|
const createVariableDeclaration = withLoc(libExports$1.variableDeclaration);
|
|
@@ -38628,6 +38633,19 @@ const createThrowStatement = withLoc(libExports$1.throwStatement);
|
|
|
38628
38633
|
const createTryStatement = withLoc(libExports$1.tryStatement);
|
|
38629
38634
|
const createBreakStatement = withLoc(libExports$1.breakStatement);
|
|
38630
38635
|
const createContinueStatement = withLoc(libExports$1.continueStatement);
|
|
38636
|
+
function createVariableDeclarator(id, init) {
|
|
38637
|
+
var _a, _b;
|
|
38638
|
+
const node = libExports$1.variableDeclarator(id, init);
|
|
38639
|
+
if (id.loc && (init === null || (init === null || init === void 0 ? void 0 : init.loc))) {
|
|
38640
|
+
node.loc = {
|
|
38641
|
+
start: id.loc.start,
|
|
38642
|
+
end: (_b = (_a = init === null || init === void 0 ? void 0 : init.loc) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : id.loc.end,
|
|
38643
|
+
filename: id.loc.filename,
|
|
38644
|
+
identifierName: undefined,
|
|
38645
|
+
};
|
|
38646
|
+
}
|
|
38647
|
+
return node;
|
|
38648
|
+
}
|
|
38631
38649
|
function createHookGuard(guard, context, stmts, before, after) {
|
|
38632
38650
|
const guardFnName = context.addImportSpecifier(guard).name;
|
|
38633
38651
|
function createHookGuardImpl(kind) {
|
|
@@ -38672,7 +38690,7 @@ function codegenInstruction(cx, instr, value) {
|
|
|
38672
38690
|
}
|
|
38673
38691
|
else {
|
|
38674
38692
|
return createVariableDeclaration(instr.loc, 'const', [
|
|
38675
|
-
|
|
38693
|
+
createVariableDeclarator(convertIdentifier(instr.lvalue.identifier), expressionValue),
|
|
38676
38694
|
]);
|
|
38677
38695
|
}
|
|
38678
38696
|
}
|
|
@@ -39322,7 +39340,7 @@ function codegenObjectPropertyKey(cx, key) {
|
|
|
39322
39340
|
function codegenArrayPattern(cx, pattern) {
|
|
39323
39341
|
const hasHoles = !pattern.items.every(e => e.kind !== 'Hole');
|
|
39324
39342
|
if (hasHoles) {
|
|
39325
|
-
const result =
|
|
39343
|
+
const result = createArrayPattern(pattern.loc, []);
|
|
39326
39344
|
for (const item of pattern.items) {
|
|
39327
39345
|
if (item.kind === 'Hole') {
|
|
39328
39346
|
result.elements.push(null);
|
|
@@ -39334,7 +39352,7 @@ function codegenArrayPattern(cx, pattern) {
|
|
|
39334
39352
|
return result;
|
|
39335
39353
|
}
|
|
39336
39354
|
else {
|
|
39337
|
-
return
|
|
39355
|
+
return createArrayPattern(pattern.loc, pattern.items.map(item => {
|
|
39338
39356
|
if (item.kind === 'Hole') {
|
|
39339
39357
|
return null;
|
|
39340
39358
|
}
|
|
@@ -39348,7 +39366,7 @@ function codegenLValue(cx, pattern) {
|
|
|
39348
39366
|
return codegenArrayPattern(cx, pattern);
|
|
39349
39367
|
}
|
|
39350
39368
|
case 'ObjectPattern': {
|
|
39351
|
-
return
|
|
39369
|
+
return createObjectPattern(pattern.loc, pattern.properties.map(property => {
|
|
39352
39370
|
if (property.kind === 'ObjectProperty') {
|
|
39353
39371
|
const key = codegenObjectPropertyKey(cx, property.key);
|
|
39354
39372
|
const value = codegenLValue(cx, property.place);
|
|
@@ -39443,7 +39461,7 @@ function convertIdentifier(identifier) {
|
|
|
39443
39461
|
description: `identifier ${identifier.id} is unnamed`,
|
|
39444
39462
|
suggestions: null,
|
|
39445
39463
|
});
|
|
39446
|
-
return
|
|
39464
|
+
return createIdentifier(identifier.loc, identifier.name.value);
|
|
39447
39465
|
}
|
|
39448
39466
|
function compareScopeDependency(a, b) {
|
|
39449
39467
|
var _a, _b;
|
|
@@ -50546,6 +50564,8 @@ const IMPORTANT_INSTRUMENTED_TYPES = new Set([
|
|
|
50546
50564
|
'LabeledStatement',
|
|
50547
50565
|
'ConditionalExpression',
|
|
50548
50566
|
'LogicalExpression',
|
|
50567
|
+
'VariableDeclaration',
|
|
50568
|
+
'Identifier',
|
|
50549
50569
|
]);
|
|
50550
50570
|
function isManualMemoization(node) {
|
|
50551
50571
|
if (libExports$1.isCallExpression(node)) {
|
|
@@ -50580,17 +50600,30 @@ function validateSourceLocations(func, generatedAst) {
|
|
|
50580
50600
|
}
|
|
50581
50601
|
if (node.loc) {
|
|
50582
50602
|
const key = locationKey(node.loc);
|
|
50583
|
-
importantOriginalLocations.
|
|
50584
|
-
|
|
50585
|
-
|
|
50586
|
-
}
|
|
50603
|
+
const existing = importantOriginalLocations.get(key);
|
|
50604
|
+
if (existing) {
|
|
50605
|
+
existing.nodeTypes.add(node.type);
|
|
50606
|
+
}
|
|
50607
|
+
else {
|
|
50608
|
+
importantOriginalLocations.set(key, {
|
|
50609
|
+
loc: node.loc,
|
|
50610
|
+
nodeTypes: new Set([node.type]),
|
|
50611
|
+
});
|
|
50612
|
+
}
|
|
50587
50613
|
}
|
|
50588
50614
|
},
|
|
50589
50615
|
});
|
|
50590
|
-
const generatedLocations = new
|
|
50616
|
+
const generatedLocations = new Map();
|
|
50591
50617
|
function collectGeneratedLocations(node) {
|
|
50592
50618
|
if (node.loc) {
|
|
50593
|
-
|
|
50619
|
+
const key = locationKey(node.loc);
|
|
50620
|
+
const nodeTypes = generatedLocations.get(key);
|
|
50621
|
+
if (nodeTypes) {
|
|
50622
|
+
nodeTypes.add(node.type);
|
|
50623
|
+
}
|
|
50624
|
+
else {
|
|
50625
|
+
generatedLocations.set(key, new Set([node.type]));
|
|
50626
|
+
}
|
|
50594
50627
|
}
|
|
50595
50628
|
const keys = libExports$1.VISITOR_KEYS[node.type];
|
|
50596
50629
|
if (!keys) {
|
|
@@ -50614,18 +50647,53 @@ function validateSourceLocations(func, generatedAst) {
|
|
|
50614
50647
|
for (const outlined of generatedAst.outlined) {
|
|
50615
50648
|
collectGeneratedLocations(outlined.fn.body);
|
|
50616
50649
|
}
|
|
50617
|
-
|
|
50618
|
-
|
|
50619
|
-
|
|
50620
|
-
|
|
50621
|
-
|
|
50622
|
-
|
|
50623
|
-
|
|
50624
|
-
|
|
50625
|
-
|
|
50626
|
-
|
|
50627
|
-
|
|
50628
|
-
|
|
50650
|
+
const strictNodeTypes = new Set([
|
|
50651
|
+
'VariableDeclaration',
|
|
50652
|
+
'VariableDeclarator',
|
|
50653
|
+
'Identifier',
|
|
50654
|
+
]);
|
|
50655
|
+
const reportMissingLocation = (loc, nodeType) => {
|
|
50656
|
+
errors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50657
|
+
category: ErrorCategory.Todo,
|
|
50658
|
+
reason: 'Important source location missing in generated code',
|
|
50659
|
+
description: `Source location for ${nodeType} is missing in the generated output. This can cause coverage instrumentation ` +
|
|
50660
|
+
`to fail to track this code properly, resulting in inaccurate coverage reports.`,
|
|
50661
|
+
}).withDetails({
|
|
50662
|
+
kind: 'error',
|
|
50663
|
+
loc,
|
|
50664
|
+
message: null,
|
|
50665
|
+
}));
|
|
50666
|
+
};
|
|
50667
|
+
const reportWrongNodeType = (loc, expectedType, actualTypes) => {
|
|
50668
|
+
errors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50669
|
+
category: ErrorCategory.Todo,
|
|
50670
|
+
reason: 'Important source location has wrong node type in generated code',
|
|
50671
|
+
description: `Source location for ${expectedType} exists in the generated output but with wrong node type(s): ${Array.from(actualTypes).join(', ')}. ` +
|
|
50672
|
+
`This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports.`,
|
|
50673
|
+
}).withDetails({
|
|
50674
|
+
kind: 'error',
|
|
50675
|
+
loc,
|
|
50676
|
+
message: null,
|
|
50677
|
+
}));
|
|
50678
|
+
};
|
|
50679
|
+
for (const [key, { loc, nodeTypes }] of importantOriginalLocations) {
|
|
50680
|
+
const generatedNodeTypes = generatedLocations.get(key);
|
|
50681
|
+
if (!generatedNodeTypes) {
|
|
50682
|
+
reportMissingLocation(loc, Array.from(nodeTypes).join(', '));
|
|
50683
|
+
}
|
|
50684
|
+
else {
|
|
50685
|
+
for (const nodeType of nodeTypes) {
|
|
50686
|
+
if (strictNodeTypes.has(nodeType) &&
|
|
50687
|
+
!generatedNodeTypes.has(nodeType)) {
|
|
50688
|
+
const hasValidNodeType = Array.from(generatedNodeTypes).some(genType => nodeTypes.has(genType));
|
|
50689
|
+
if (hasValidNodeType) {
|
|
50690
|
+
reportMissingLocation(loc, nodeType);
|
|
50691
|
+
}
|
|
50692
|
+
else {
|
|
50693
|
+
reportWrongNodeType(loc, nodeType, generatedNodeTypes);
|
|
50694
|
+
}
|
|
50695
|
+
}
|
|
50696
|
+
}
|
|
50629
50697
|
}
|
|
50630
50698
|
}
|
|
50631
50699
|
return errors.asResult();
|
|
@@ -51810,6 +51878,7 @@ function emitDestructureProps(env, propsObj, oldToNewProps) {
|
|
|
51810
51878
|
pattern: {
|
|
51811
51879
|
kind: 'ObjectPattern',
|
|
51812
51880
|
properties,
|
|
51881
|
+
loc: GeneratedSource,
|
|
51813
51882
|
},
|
|
51814
51883
|
kind: InstructionKind.Let,
|
|
51815
51884
|
},
|
|
@@ -54356,16 +54425,17 @@ function runWithEnvironment(func, env) {
|
|
|
54356
54425
|
if (env.config.validateNoSetStateInRender) {
|
|
54357
54426
|
validateNoSetStateInRender(hir).unwrap();
|
|
54358
54427
|
}
|
|
54359
|
-
if (env.config.validateNoDerivedComputationsInEffects_exp
|
|
54428
|
+
if (env.config.validateNoDerivedComputationsInEffects_exp &&
|
|
54429
|
+
env.outputMode === 'lint') {
|
|
54360
54430
|
env.logErrors(validateNoDerivedComputationsInEffects_exp(hir));
|
|
54361
54431
|
}
|
|
54362
54432
|
else if (env.config.validateNoDerivedComputationsInEffects) {
|
|
54363
54433
|
validateNoDerivedComputationsInEffects(hir);
|
|
54364
54434
|
}
|
|
54365
|
-
if (env.config.validateNoSetStateInEffects) {
|
|
54435
|
+
if (env.config.validateNoSetStateInEffects && env.outputMode === 'lint') {
|
|
54366
54436
|
env.logErrors(validateNoSetStateInEffects(hir, env));
|
|
54367
54437
|
}
|
|
54368
|
-
if (env.config.validateNoJSXInTryStatements) {
|
|
54438
|
+
if (env.config.validateNoJSXInTryStatements && env.outputMode === 'lint') {
|
|
54369
54439
|
env.logErrors(validateNoJSXInTryStatement(hir));
|
|
54370
54440
|
}
|
|
54371
54441
|
if (env.config.validateNoImpureFunctionsInRender) {
|
|
@@ -54387,7 +54457,9 @@ function runWithEnvironment(func, env) {
|
|
|
54387
54457
|
name: 'RewriteInstructionKindsBasedOnReassignment',
|
|
54388
54458
|
value: hir,
|
|
54389
54459
|
});
|
|
54390
|
-
if (env.enableValidations &&
|
|
54460
|
+
if (env.enableValidations &&
|
|
54461
|
+
env.config.validateStaticComponents &&
|
|
54462
|
+
env.outputMode === 'lint') {
|
|
54391
54463
|
env.logErrors(validateStaticComponents(hir));
|
|
54392
54464
|
}
|
|
54393
54465
|
if (env.enableMemoization) {
|
|
@@ -26139,7 +26139,7 @@ function lowerIdentifierForAssignment(builder, loc, kind, path) {
|
|
|
26139
26139
|
return place;
|
|
26140
26140
|
}
|
|
26141
26141
|
function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind) {
|
|
26142
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2;
|
|
26142
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
26143
26143
|
const lvalueNode = lvaluePath.node;
|
|
26144
26144
|
switch (lvalueNode.type) {
|
|
26145
26145
|
case 'Identifier': {
|
|
@@ -26372,13 +26372,14 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26372
26372
|
pattern: {
|
|
26373
26373
|
kind: 'ArrayPattern',
|
|
26374
26374
|
items,
|
|
26375
|
+
loc: (_p = lvalue.node.loc) !== null && _p !== void 0 ? _p : GeneratedSource,
|
|
26375
26376
|
},
|
|
26376
26377
|
},
|
|
26377
26378
|
value,
|
|
26378
26379
|
loc,
|
|
26379
26380
|
});
|
|
26380
26381
|
for (const { place, path } of followups) {
|
|
26381
|
-
lowerAssignment(builder, (
|
|
26382
|
+
lowerAssignment(builder, (_q = path.node.loc) !== null && _q !== void 0 ? _q : loc, kind, path, place, assignmentKind);
|
|
26382
26383
|
}
|
|
26383
26384
|
return { kind: 'LoadLocal', place: temporary, loc: value.loc };
|
|
26384
26385
|
}
|
|
@@ -26400,14 +26401,14 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26400
26401
|
builder.errors.push({
|
|
26401
26402
|
reason: `(BuildHIR::lowerAssignment) Handle ${argument.node.type} rest element in ObjectPattern`,
|
|
26402
26403
|
category: ErrorCategory.Todo,
|
|
26403
|
-
loc: (
|
|
26404
|
+
loc: (_r = argument.node.loc) !== null && _r !== void 0 ? _r : null,
|
|
26404
26405
|
suggestions: null,
|
|
26405
26406
|
});
|
|
26406
26407
|
continue;
|
|
26407
26408
|
}
|
|
26408
26409
|
if (forceTemporaries ||
|
|
26409
26410
|
getStoreKind(builder, argument) === 'StoreContext') {
|
|
26410
|
-
const temp = buildTemporaryPlace(builder, (
|
|
26411
|
+
const temp = buildTemporaryPlace(builder, (_s = property.node.loc) !== null && _s !== void 0 ? _s : GeneratedSource);
|
|
26411
26412
|
promoteTemporary(temp.identifier);
|
|
26412
26413
|
properties.push({
|
|
26413
26414
|
kind: 'Spread',
|
|
@@ -26416,7 +26417,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26416
26417
|
followups.push({ place: temp, path: argument });
|
|
26417
26418
|
}
|
|
26418
26419
|
else {
|
|
26419
|
-
const identifier = lowerIdentifierForAssignment(builder, (
|
|
26420
|
+
const identifier = lowerIdentifierForAssignment(builder, (_t = property.node.loc) !== null && _t !== void 0 ? _t : GeneratedSource, kind, argument);
|
|
26420
26421
|
if (identifier === null) {
|
|
26421
26422
|
continue;
|
|
26422
26423
|
}
|
|
@@ -26424,7 +26425,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26424
26425
|
builder.errors.push({
|
|
26425
26426
|
category: ErrorCategory.Todo,
|
|
26426
26427
|
reason: 'Expected reassignment of globals to enable forceTemporaries',
|
|
26427
|
-
loc: (
|
|
26428
|
+
loc: (_u = property.node.loc) !== null && _u !== void 0 ? _u : GeneratedSource,
|
|
26428
26429
|
});
|
|
26429
26430
|
continue;
|
|
26430
26431
|
}
|
|
@@ -26439,7 +26440,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26439
26440
|
builder.errors.push({
|
|
26440
26441
|
reason: `(BuildHIR::lowerAssignment) Handle ${property.type} properties in ObjectPattern`,
|
|
26441
26442
|
category: ErrorCategory.Todo,
|
|
26442
|
-
loc: (
|
|
26443
|
+
loc: (_v = property.node.loc) !== null && _v !== void 0 ? _v : null,
|
|
26443
26444
|
suggestions: null,
|
|
26444
26445
|
});
|
|
26445
26446
|
continue;
|
|
@@ -26448,7 +26449,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26448
26449
|
builder.errors.push({
|
|
26449
26450
|
reason: `(BuildHIR::lowerAssignment) Handle computed properties in ObjectPattern`,
|
|
26450
26451
|
category: ErrorCategory.Todo,
|
|
26451
|
-
loc: (
|
|
26452
|
+
loc: (_w = property.node.loc) !== null && _w !== void 0 ? _w : null,
|
|
26452
26453
|
suggestions: null,
|
|
26453
26454
|
});
|
|
26454
26455
|
continue;
|
|
@@ -26462,7 +26463,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26462
26463
|
builder.errors.push({
|
|
26463
26464
|
reason: `(BuildHIR::lowerAssignment) Expected object property value to be an LVal, got: ${element.type}`,
|
|
26464
26465
|
category: ErrorCategory.Todo,
|
|
26465
|
-
loc: (
|
|
26466
|
+
loc: (_x = element.node.loc) !== null && _x !== void 0 ? _x : null,
|
|
26466
26467
|
suggestions: null,
|
|
26467
26468
|
});
|
|
26468
26469
|
continue;
|
|
@@ -26471,7 +26472,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26471
26472
|
!forceTemporaries &&
|
|
26472
26473
|
(assignmentKind === 'Assignment' ||
|
|
26473
26474
|
getStoreKind(builder, element) === 'StoreLocal')) {
|
|
26474
|
-
const identifier = lowerIdentifierForAssignment(builder, (
|
|
26475
|
+
const identifier = lowerIdentifierForAssignment(builder, (_y = element.node.loc) !== null && _y !== void 0 ? _y : GeneratedSource, kind, element);
|
|
26475
26476
|
if (identifier === null) {
|
|
26476
26477
|
continue;
|
|
26477
26478
|
}
|
|
@@ -26479,7 +26480,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26479
26480
|
builder.errors.push({
|
|
26480
26481
|
category: ErrorCategory.Todo,
|
|
26481
26482
|
reason: 'Expected reassignment of globals to enable forceTemporaries',
|
|
26482
|
-
loc: (
|
|
26483
|
+
loc: (_z = element.node.loc) !== null && _z !== void 0 ? _z : GeneratedSource,
|
|
26483
26484
|
});
|
|
26484
26485
|
continue;
|
|
26485
26486
|
}
|
|
@@ -26491,7 +26492,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26491
26492
|
});
|
|
26492
26493
|
}
|
|
26493
26494
|
else {
|
|
26494
|
-
const temp = buildTemporaryPlace(builder, (
|
|
26495
|
+
const temp = buildTemporaryPlace(builder, (_0 = element.node.loc) !== null && _0 !== void 0 ? _0 : GeneratedSource);
|
|
26495
26496
|
promoteTemporary(temp.identifier);
|
|
26496
26497
|
properties.push({
|
|
26497
26498
|
kind: 'ObjectProperty',
|
|
@@ -26510,19 +26511,20 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26510
26511
|
pattern: {
|
|
26511
26512
|
kind: 'ObjectPattern',
|
|
26512
26513
|
properties,
|
|
26514
|
+
loc: (_1 = lvalue.node.loc) !== null && _1 !== void 0 ? _1 : GeneratedSource,
|
|
26513
26515
|
},
|
|
26514
26516
|
},
|
|
26515
26517
|
value,
|
|
26516
26518
|
loc,
|
|
26517
26519
|
});
|
|
26518
26520
|
for (const { place, path } of followups) {
|
|
26519
|
-
lowerAssignment(builder, (
|
|
26521
|
+
lowerAssignment(builder, (_2 = path.node.loc) !== null && _2 !== void 0 ? _2 : loc, kind, path, place, assignmentKind);
|
|
26520
26522
|
}
|
|
26521
26523
|
return { kind: 'LoadLocal', place: temporary, loc: value.loc };
|
|
26522
26524
|
}
|
|
26523
26525
|
case 'AssignmentPattern': {
|
|
26524
26526
|
const lvalue = lvaluePath;
|
|
26525
|
-
const loc = (
|
|
26527
|
+
const loc = (_3 = lvalue.node.loc) !== null && _3 !== void 0 ? _3 : GeneratedSource;
|
|
26526
26528
|
const temp = buildTemporaryPlace(builder, loc);
|
|
26527
26529
|
const testBlock = builder.reserve('value');
|
|
26528
26530
|
const continuationBlock = builder.reserve(builder.currentBlockKind());
|
|
@@ -26593,7 +26595,7 @@ function lowerAssignment(builder, loc, kind, lvaluePath, value, assignmentKind)
|
|
|
26593
26595
|
builder.errors.push({
|
|
26594
26596
|
reason: `(BuildHIR::lowerAssignment) Handle ${lvaluePath.type} assignments`,
|
|
26595
26597
|
category: ErrorCategory.Todo,
|
|
26596
|
-
loc: (
|
|
26598
|
+
loc: (_4 = lvaluePath.node.loc) !== null && _4 !== void 0 ? _4 : null,
|
|
26597
26599
|
suggestions: null,
|
|
26598
26600
|
});
|
|
26599
26601
|
return { kind: 'UnsupportedNode', node: lvalueNode, loc };
|
|
@@ -37680,7 +37682,7 @@ function codegenReactiveScope(cx, statements, scope, block) {
|
|
|
37680
37682
|
const name = convertIdentifier(identifier);
|
|
37681
37683
|
outputComments.push(name.name);
|
|
37682
37684
|
if (!cx.hasDeclared(identifier)) {
|
|
37683
|
-
statements.push(libExports$1.variableDeclaration('let', [
|
|
37685
|
+
statements.push(libExports$1.variableDeclaration('let', [createVariableDeclarator(name, null)]));
|
|
37684
37686
|
}
|
|
37685
37687
|
cacheLoads.push({ name, index, value: wrapCacheDep(cx, name) });
|
|
37686
37688
|
cx.declare(identifier);
|
|
@@ -38161,7 +38163,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
|
38161
38163
|
suggestions: null,
|
|
38162
38164
|
});
|
|
38163
38165
|
return createVariableDeclaration(instr.loc, 'const', [
|
|
38164
|
-
|
|
38166
|
+
createVariableDeclarator(codegenLValue(cx, lvalue), value),
|
|
38165
38167
|
]);
|
|
38166
38168
|
}
|
|
38167
38169
|
case InstructionKind.Function: {
|
|
@@ -38218,7 +38220,7 @@ function codegenInstructionNullable(cx, instr) {
|
|
|
38218
38220
|
suggestions: null,
|
|
38219
38221
|
});
|
|
38220
38222
|
return createVariableDeclaration(instr.loc, 'let', [
|
|
38221
|
-
|
|
38223
|
+
createVariableDeclarator(codegenLValue(cx, lvalue), value),
|
|
38222
38224
|
]);
|
|
38223
38225
|
}
|
|
38224
38226
|
case InstructionKind.Reassign: {
|
|
@@ -38426,6 +38428,9 @@ function withLoc(fn) {
|
|
|
38426
38428
|
return node;
|
|
38427
38429
|
};
|
|
38428
38430
|
}
|
|
38431
|
+
const createIdentifier = withLoc(libExports$1.identifier);
|
|
38432
|
+
const createArrayPattern = withLoc(libExports$1.arrayPattern);
|
|
38433
|
+
const createObjectPattern = withLoc(libExports$1.objectPattern);
|
|
38429
38434
|
const createBinaryExpression = withLoc(libExports$1.binaryExpression);
|
|
38430
38435
|
const createExpressionStatement = withLoc(libExports$1.expressionStatement);
|
|
38431
38436
|
const createVariableDeclaration = withLoc(libExports$1.variableDeclaration);
|
|
@@ -38455,6 +38460,19 @@ const createThrowStatement = withLoc(libExports$1.throwStatement);
|
|
|
38455
38460
|
const createTryStatement = withLoc(libExports$1.tryStatement);
|
|
38456
38461
|
const createBreakStatement = withLoc(libExports$1.breakStatement);
|
|
38457
38462
|
const createContinueStatement = withLoc(libExports$1.continueStatement);
|
|
38463
|
+
function createVariableDeclarator(id, init) {
|
|
38464
|
+
var _a, _b;
|
|
38465
|
+
const node = libExports$1.variableDeclarator(id, init);
|
|
38466
|
+
if (id.loc && (init === null || (init === null || init === void 0 ? void 0 : init.loc))) {
|
|
38467
|
+
node.loc = {
|
|
38468
|
+
start: id.loc.start,
|
|
38469
|
+
end: (_b = (_a = init === null || init === void 0 ? void 0 : init.loc) === null || _a === void 0 ? void 0 : _a.end) !== null && _b !== void 0 ? _b : id.loc.end,
|
|
38470
|
+
filename: id.loc.filename,
|
|
38471
|
+
identifierName: undefined,
|
|
38472
|
+
};
|
|
38473
|
+
}
|
|
38474
|
+
return node;
|
|
38475
|
+
}
|
|
38458
38476
|
function createHookGuard(guard, context, stmts, before, after) {
|
|
38459
38477
|
const guardFnName = context.addImportSpecifier(guard).name;
|
|
38460
38478
|
function createHookGuardImpl(kind) {
|
|
@@ -38499,7 +38517,7 @@ function codegenInstruction(cx, instr, value) {
|
|
|
38499
38517
|
}
|
|
38500
38518
|
else {
|
|
38501
38519
|
return createVariableDeclaration(instr.loc, 'const', [
|
|
38502
|
-
|
|
38520
|
+
createVariableDeclarator(convertIdentifier(instr.lvalue.identifier), expressionValue),
|
|
38503
38521
|
]);
|
|
38504
38522
|
}
|
|
38505
38523
|
}
|
|
@@ -39149,7 +39167,7 @@ function codegenObjectPropertyKey(cx, key) {
|
|
|
39149
39167
|
function codegenArrayPattern(cx, pattern) {
|
|
39150
39168
|
const hasHoles = !pattern.items.every(e => e.kind !== 'Hole');
|
|
39151
39169
|
if (hasHoles) {
|
|
39152
|
-
const result =
|
|
39170
|
+
const result = createArrayPattern(pattern.loc, []);
|
|
39153
39171
|
for (const item of pattern.items) {
|
|
39154
39172
|
if (item.kind === 'Hole') {
|
|
39155
39173
|
result.elements.push(null);
|
|
@@ -39161,7 +39179,7 @@ function codegenArrayPattern(cx, pattern) {
|
|
|
39161
39179
|
return result;
|
|
39162
39180
|
}
|
|
39163
39181
|
else {
|
|
39164
|
-
return
|
|
39182
|
+
return createArrayPattern(pattern.loc, pattern.items.map(item => {
|
|
39165
39183
|
if (item.kind === 'Hole') {
|
|
39166
39184
|
return null;
|
|
39167
39185
|
}
|
|
@@ -39175,7 +39193,7 @@ function codegenLValue(cx, pattern) {
|
|
|
39175
39193
|
return codegenArrayPattern(cx, pattern);
|
|
39176
39194
|
}
|
|
39177
39195
|
case 'ObjectPattern': {
|
|
39178
|
-
return
|
|
39196
|
+
return createObjectPattern(pattern.loc, pattern.properties.map(property => {
|
|
39179
39197
|
if (property.kind === 'ObjectProperty') {
|
|
39180
39198
|
const key = codegenObjectPropertyKey(cx, property.key);
|
|
39181
39199
|
const value = codegenLValue(cx, property.place);
|
|
@@ -39270,7 +39288,7 @@ function convertIdentifier(identifier) {
|
|
|
39270
39288
|
description: `identifier ${identifier.id} is unnamed`,
|
|
39271
39289
|
suggestions: null,
|
|
39272
39290
|
});
|
|
39273
|
-
return
|
|
39291
|
+
return createIdentifier(identifier.loc, identifier.name.value);
|
|
39274
39292
|
}
|
|
39275
39293
|
function compareScopeDependency(a, b) {
|
|
39276
39294
|
var _a, _b;
|
|
@@ -50373,6 +50391,8 @@ const IMPORTANT_INSTRUMENTED_TYPES = new Set([
|
|
|
50373
50391
|
'LabeledStatement',
|
|
50374
50392
|
'ConditionalExpression',
|
|
50375
50393
|
'LogicalExpression',
|
|
50394
|
+
'VariableDeclaration',
|
|
50395
|
+
'Identifier',
|
|
50376
50396
|
]);
|
|
50377
50397
|
function isManualMemoization(node) {
|
|
50378
50398
|
if (libExports$1.isCallExpression(node)) {
|
|
@@ -50407,17 +50427,30 @@ function validateSourceLocations(func, generatedAst) {
|
|
|
50407
50427
|
}
|
|
50408
50428
|
if (node.loc) {
|
|
50409
50429
|
const key = locationKey(node.loc);
|
|
50410
|
-
importantOriginalLocations.
|
|
50411
|
-
|
|
50412
|
-
|
|
50413
|
-
}
|
|
50430
|
+
const existing = importantOriginalLocations.get(key);
|
|
50431
|
+
if (existing) {
|
|
50432
|
+
existing.nodeTypes.add(node.type);
|
|
50433
|
+
}
|
|
50434
|
+
else {
|
|
50435
|
+
importantOriginalLocations.set(key, {
|
|
50436
|
+
loc: node.loc,
|
|
50437
|
+
nodeTypes: new Set([node.type]),
|
|
50438
|
+
});
|
|
50439
|
+
}
|
|
50414
50440
|
}
|
|
50415
50441
|
},
|
|
50416
50442
|
});
|
|
50417
|
-
const generatedLocations = new
|
|
50443
|
+
const generatedLocations = new Map();
|
|
50418
50444
|
function collectGeneratedLocations(node) {
|
|
50419
50445
|
if (node.loc) {
|
|
50420
|
-
|
|
50446
|
+
const key = locationKey(node.loc);
|
|
50447
|
+
const nodeTypes = generatedLocations.get(key);
|
|
50448
|
+
if (nodeTypes) {
|
|
50449
|
+
nodeTypes.add(node.type);
|
|
50450
|
+
}
|
|
50451
|
+
else {
|
|
50452
|
+
generatedLocations.set(key, new Set([node.type]));
|
|
50453
|
+
}
|
|
50421
50454
|
}
|
|
50422
50455
|
const keys = libExports$1.VISITOR_KEYS[node.type];
|
|
50423
50456
|
if (!keys) {
|
|
@@ -50441,18 +50474,53 @@ function validateSourceLocations(func, generatedAst) {
|
|
|
50441
50474
|
for (const outlined of generatedAst.outlined) {
|
|
50442
50475
|
collectGeneratedLocations(outlined.fn.body);
|
|
50443
50476
|
}
|
|
50444
|
-
|
|
50445
|
-
|
|
50446
|
-
|
|
50447
|
-
|
|
50448
|
-
|
|
50449
|
-
|
|
50450
|
-
|
|
50451
|
-
|
|
50452
|
-
|
|
50453
|
-
|
|
50454
|
-
|
|
50455
|
-
|
|
50477
|
+
const strictNodeTypes = new Set([
|
|
50478
|
+
'VariableDeclaration',
|
|
50479
|
+
'VariableDeclarator',
|
|
50480
|
+
'Identifier',
|
|
50481
|
+
]);
|
|
50482
|
+
const reportMissingLocation = (loc, nodeType) => {
|
|
50483
|
+
errors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50484
|
+
category: ErrorCategory.Todo,
|
|
50485
|
+
reason: 'Important source location missing in generated code',
|
|
50486
|
+
description: `Source location for ${nodeType} is missing in the generated output. This can cause coverage instrumentation ` +
|
|
50487
|
+
`to fail to track this code properly, resulting in inaccurate coverage reports.`,
|
|
50488
|
+
}).withDetails({
|
|
50489
|
+
kind: 'error',
|
|
50490
|
+
loc,
|
|
50491
|
+
message: null,
|
|
50492
|
+
}));
|
|
50493
|
+
};
|
|
50494
|
+
const reportWrongNodeType = (loc, expectedType, actualTypes) => {
|
|
50495
|
+
errors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50496
|
+
category: ErrorCategory.Todo,
|
|
50497
|
+
reason: 'Important source location has wrong node type in generated code',
|
|
50498
|
+
description: `Source location for ${expectedType} exists in the generated output but with wrong node type(s): ${Array.from(actualTypes).join(', ')}. ` +
|
|
50499
|
+
`This can cause coverage instrumentation to fail to track this code properly, resulting in inaccurate coverage reports.`,
|
|
50500
|
+
}).withDetails({
|
|
50501
|
+
kind: 'error',
|
|
50502
|
+
loc,
|
|
50503
|
+
message: null,
|
|
50504
|
+
}));
|
|
50505
|
+
};
|
|
50506
|
+
for (const [key, { loc, nodeTypes }] of importantOriginalLocations) {
|
|
50507
|
+
const generatedNodeTypes = generatedLocations.get(key);
|
|
50508
|
+
if (!generatedNodeTypes) {
|
|
50509
|
+
reportMissingLocation(loc, Array.from(nodeTypes).join(', '));
|
|
50510
|
+
}
|
|
50511
|
+
else {
|
|
50512
|
+
for (const nodeType of nodeTypes) {
|
|
50513
|
+
if (strictNodeTypes.has(nodeType) &&
|
|
50514
|
+
!generatedNodeTypes.has(nodeType)) {
|
|
50515
|
+
const hasValidNodeType = Array.from(generatedNodeTypes).some(genType => nodeTypes.has(genType));
|
|
50516
|
+
if (hasValidNodeType) {
|
|
50517
|
+
reportMissingLocation(loc, nodeType);
|
|
50518
|
+
}
|
|
50519
|
+
else {
|
|
50520
|
+
reportWrongNodeType(loc, nodeType, generatedNodeTypes);
|
|
50521
|
+
}
|
|
50522
|
+
}
|
|
50523
|
+
}
|
|
50456
50524
|
}
|
|
50457
50525
|
}
|
|
50458
50526
|
return errors.asResult();
|
|
@@ -51637,6 +51705,7 @@ function emitDestructureProps(env, propsObj, oldToNewProps) {
|
|
|
51637
51705
|
pattern: {
|
|
51638
51706
|
kind: 'ObjectPattern',
|
|
51639
51707
|
properties,
|
|
51708
|
+
loc: GeneratedSource,
|
|
51640
51709
|
},
|
|
51641
51710
|
kind: InstructionKind.Let,
|
|
51642
51711
|
},
|
|
@@ -54183,16 +54252,17 @@ function runWithEnvironment(func, env) {
|
|
|
54183
54252
|
if (env.config.validateNoSetStateInRender) {
|
|
54184
54253
|
validateNoSetStateInRender(hir).unwrap();
|
|
54185
54254
|
}
|
|
54186
|
-
if (env.config.validateNoDerivedComputationsInEffects_exp
|
|
54255
|
+
if (env.config.validateNoDerivedComputationsInEffects_exp &&
|
|
54256
|
+
env.outputMode === 'lint') {
|
|
54187
54257
|
env.logErrors(validateNoDerivedComputationsInEffects_exp(hir));
|
|
54188
54258
|
}
|
|
54189
54259
|
else if (env.config.validateNoDerivedComputationsInEffects) {
|
|
54190
54260
|
validateNoDerivedComputationsInEffects(hir);
|
|
54191
54261
|
}
|
|
54192
|
-
if (env.config.validateNoSetStateInEffects) {
|
|
54262
|
+
if (env.config.validateNoSetStateInEffects && env.outputMode === 'lint') {
|
|
54193
54263
|
env.logErrors(validateNoSetStateInEffects(hir, env));
|
|
54194
54264
|
}
|
|
54195
|
-
if (env.config.validateNoJSXInTryStatements) {
|
|
54265
|
+
if (env.config.validateNoJSXInTryStatements && env.outputMode === 'lint') {
|
|
54196
54266
|
env.logErrors(validateNoJSXInTryStatement(hir));
|
|
54197
54267
|
}
|
|
54198
54268
|
if (env.config.validateNoImpureFunctionsInRender) {
|
|
@@ -54214,7 +54284,9 @@ function runWithEnvironment(func, env) {
|
|
|
54214
54284
|
name: 'RewriteInstructionKindsBasedOnReassignment',
|
|
54215
54285
|
value: hir,
|
|
54216
54286
|
});
|
|
54217
|
-
if (env.enableValidations &&
|
|
54287
|
+
if (env.enableValidations &&
|
|
54288
|
+
env.config.validateStaticComponents &&
|
|
54289
|
+
env.outputMode === 'lint') {
|
|
54218
54290
|
env.logErrors(validateStaticComponents(hir));
|
|
54219
54291
|
}
|
|
54220
54292
|
if (env.enableMemoization) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-hooks",
|
|
3
3
|
"description": "ESLint rules for React Hooks",
|
|
4
|
-
"version": "7.1.0-canary-
|
|
4
|
+
"version": "7.1.0-canary-b061b597-20251212",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/facebook/react.git",
|