eslint-plugin-react-hooks 6.1.0-canary-e9638c33-20250721 → 6.1.0-canary-7513996f-20250722
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.
|
@@ -30061,7 +30061,7 @@ const EnvironmentConfigSchema = zod.z.object({
|
|
|
30061
30061
|
inferEffectDependencies: zod.z
|
|
30062
30062
|
.nullable(zod.z.array(zod.z.object({
|
|
30063
30063
|
function: ExternalFunctionSchema,
|
|
30064
|
-
|
|
30064
|
+
autodepsIndex: zod.z.number().min(1, 'autodepsIndex must be > 0'),
|
|
30065
30065
|
})))
|
|
30066
30066
|
.default(null),
|
|
30067
30067
|
inlineJsxTransform: ReactElementSymbolSchema.nullable().default(null),
|
|
@@ -45128,7 +45128,7 @@ function inferEffectDependencies(fn) {
|
|
|
45128
45128
|
const autodepFnConfigs = new Map();
|
|
45129
45129
|
for (const effectTarget of fn.env.config.inferEffectDependencies) {
|
|
45130
45130
|
const moduleTargets = getOrInsertWith(autodepFnConfigs, effectTarget.function.source, () => new Map());
|
|
45131
|
-
moduleTargets.set(effectTarget.function.importSpecifierName, effectTarget.
|
|
45131
|
+
moduleTargets.set(effectTarget.function.importSpecifierName, effectTarget.autodepsIndex);
|
|
45132
45132
|
}
|
|
45133
45133
|
const autodepFnLoads = new Map();
|
|
45134
45134
|
const autodepModuleLoads = new Map();
|
|
@@ -45190,8 +45190,10 @@ function inferEffectDependencies(fn) {
|
|
|
45190
45190
|
const autodepsArgIndex = value.args.findIndex(arg => arg.kind === 'Identifier' &&
|
|
45191
45191
|
arg.identifier.type.kind === 'Object' &&
|
|
45192
45192
|
arg.identifier.type.shapeId === BuiltInAutodepsId);
|
|
45193
|
-
|
|
45194
|
-
|
|
45193
|
+
const autodepsArgExpectedIndex = autodepFnLoads.get(callee.identifier.id);
|
|
45194
|
+
if (value.args.length > 0 &&
|
|
45195
|
+
autodepsArgExpectedIndex != null &&
|
|
45196
|
+
autodepsArgIndex === autodepsArgExpectedIndex &&
|
|
45195
45197
|
autodepFnLoads.has(callee.identifier.id) &&
|
|
45196
45198
|
value.args[0].kind === 'Identifier') {
|
|
45197
45199
|
const effectDeps = [];
|
|
@@ -51540,7 +51542,30 @@ function throwInvalidReact(options, { logger, filename }) {
|
|
|
51540
51542
|
});
|
|
51541
51543
|
CompilerError.throw(detail);
|
|
51542
51544
|
}
|
|
51543
|
-
function
|
|
51545
|
+
function isAutodepsSigil(arg) {
|
|
51546
|
+
if (arg.isIdentifier() && arg.node.name === 'AUTODEPS') {
|
|
51547
|
+
const binding = arg.scope.getBinding(arg.node.name);
|
|
51548
|
+
if (binding && binding.path.isImportSpecifier()) {
|
|
51549
|
+
const importSpecifier = binding.path.node;
|
|
51550
|
+
if (importSpecifier.imported.type === 'Identifier') {
|
|
51551
|
+
return importSpecifier.imported.name === 'AUTODEPS';
|
|
51552
|
+
}
|
|
51553
|
+
}
|
|
51554
|
+
return false;
|
|
51555
|
+
}
|
|
51556
|
+
if (arg.isMemberExpression() && !arg.node.computed) {
|
|
51557
|
+
const object = arg.get('object');
|
|
51558
|
+
const property = arg.get('property');
|
|
51559
|
+
if (object.isIdentifier() &&
|
|
51560
|
+
object.node.name === 'React' &&
|
|
51561
|
+
property.isIdentifier() &&
|
|
51562
|
+
property.node.name === 'AUTODEPS') {
|
|
51563
|
+
return true;
|
|
51564
|
+
}
|
|
51565
|
+
}
|
|
51566
|
+
return false;
|
|
51567
|
+
}
|
|
51568
|
+
function assertValidEffectImportReference(autodepsIndex, paths, context) {
|
|
51544
51569
|
var _a;
|
|
51545
51570
|
for (const path of paths) {
|
|
51546
51571
|
const parent = path.parentPath;
|
|
@@ -51549,7 +51574,8 @@ function assertValidEffectImportReference(numArgs, paths, context) {
|
|
|
51549
51574
|
const maybeCalleeLoc = path.node.loc;
|
|
51550
51575
|
const hasInferredEffect = maybeCalleeLoc != null &&
|
|
51551
51576
|
context.inferredEffectLocations.has(maybeCalleeLoc);
|
|
51552
|
-
|
|
51577
|
+
const hasAutodepsArg = args.some(isAutodepsSigil);
|
|
51578
|
+
if (hasAutodepsArg && !hasInferredEffect) {
|
|
51553
51579
|
const maybeErrorDiagnostic = matchCompilerDiagnostic(path, context.transformErrors);
|
|
51554
51580
|
throwInvalidReact({
|
|
51555
51581
|
reason: '[InferEffectDependencies] React Compiler is unable to infer dependencies of this effect. ' +
|
|
@@ -51587,9 +51613,9 @@ function validateNoUntransformedReferences(path, filename, logger, env, compileR
|
|
|
51587
51613
|
}
|
|
51588
51614
|
}
|
|
51589
51615
|
if (env.inferEffectDependencies) {
|
|
51590
|
-
for (const { function: { source, importSpecifierName },
|
|
51616
|
+
for (const { function: { source, importSpecifierName }, autodepsIndex, } of env.inferEffectDependencies) {
|
|
51591
51617
|
const module = getOrInsertWith(moduleLoadChecks, source, () => new Map());
|
|
51592
|
-
module.set(importSpecifierName, assertValidEffectImportReference.bind(null,
|
|
51618
|
+
module.set(importSpecifierName, assertValidEffectImportReference.bind(null, autodepsIndex));
|
|
51593
51619
|
}
|
|
51594
51620
|
}
|
|
51595
51621
|
if (moduleLoadChecks.size > 0) {
|
|
@@ -29888,7 +29888,7 @@ const EnvironmentConfigSchema = zod.z.object({
|
|
|
29888
29888
|
inferEffectDependencies: zod.z
|
|
29889
29889
|
.nullable(zod.z.array(zod.z.object({
|
|
29890
29890
|
function: ExternalFunctionSchema,
|
|
29891
|
-
|
|
29891
|
+
autodepsIndex: zod.z.number().min(1, 'autodepsIndex must be > 0'),
|
|
29892
29892
|
})))
|
|
29893
29893
|
.default(null),
|
|
29894
29894
|
inlineJsxTransform: ReactElementSymbolSchema.nullable().default(null),
|
|
@@ -44955,7 +44955,7 @@ function inferEffectDependencies(fn) {
|
|
|
44955
44955
|
const autodepFnConfigs = new Map();
|
|
44956
44956
|
for (const effectTarget of fn.env.config.inferEffectDependencies) {
|
|
44957
44957
|
const moduleTargets = getOrInsertWith(autodepFnConfigs, effectTarget.function.source, () => new Map());
|
|
44958
|
-
moduleTargets.set(effectTarget.function.importSpecifierName, effectTarget.
|
|
44958
|
+
moduleTargets.set(effectTarget.function.importSpecifierName, effectTarget.autodepsIndex);
|
|
44959
44959
|
}
|
|
44960
44960
|
const autodepFnLoads = new Map();
|
|
44961
44961
|
const autodepModuleLoads = new Map();
|
|
@@ -45017,8 +45017,10 @@ function inferEffectDependencies(fn) {
|
|
|
45017
45017
|
const autodepsArgIndex = value.args.findIndex(arg => arg.kind === 'Identifier' &&
|
|
45018
45018
|
arg.identifier.type.kind === 'Object' &&
|
|
45019
45019
|
arg.identifier.type.shapeId === BuiltInAutodepsId);
|
|
45020
|
-
|
|
45021
|
-
|
|
45020
|
+
const autodepsArgExpectedIndex = autodepFnLoads.get(callee.identifier.id);
|
|
45021
|
+
if (value.args.length > 0 &&
|
|
45022
|
+
autodepsArgExpectedIndex != null &&
|
|
45023
|
+
autodepsArgIndex === autodepsArgExpectedIndex &&
|
|
45022
45024
|
autodepFnLoads.has(callee.identifier.id) &&
|
|
45023
45025
|
value.args[0].kind === 'Identifier') {
|
|
45024
45026
|
const effectDeps = [];
|
|
@@ -51367,7 +51369,30 @@ function throwInvalidReact(options, { logger, filename }) {
|
|
|
51367
51369
|
});
|
|
51368
51370
|
CompilerError.throw(detail);
|
|
51369
51371
|
}
|
|
51370
|
-
function
|
|
51372
|
+
function isAutodepsSigil(arg) {
|
|
51373
|
+
if (arg.isIdentifier() && arg.node.name === 'AUTODEPS') {
|
|
51374
|
+
const binding = arg.scope.getBinding(arg.node.name);
|
|
51375
|
+
if (binding && binding.path.isImportSpecifier()) {
|
|
51376
|
+
const importSpecifier = binding.path.node;
|
|
51377
|
+
if (importSpecifier.imported.type === 'Identifier') {
|
|
51378
|
+
return importSpecifier.imported.name === 'AUTODEPS';
|
|
51379
|
+
}
|
|
51380
|
+
}
|
|
51381
|
+
return false;
|
|
51382
|
+
}
|
|
51383
|
+
if (arg.isMemberExpression() && !arg.node.computed) {
|
|
51384
|
+
const object = arg.get('object');
|
|
51385
|
+
const property = arg.get('property');
|
|
51386
|
+
if (object.isIdentifier() &&
|
|
51387
|
+
object.node.name === 'React' &&
|
|
51388
|
+
property.isIdentifier() &&
|
|
51389
|
+
property.node.name === 'AUTODEPS') {
|
|
51390
|
+
return true;
|
|
51391
|
+
}
|
|
51392
|
+
}
|
|
51393
|
+
return false;
|
|
51394
|
+
}
|
|
51395
|
+
function assertValidEffectImportReference(autodepsIndex, paths, context) {
|
|
51371
51396
|
var _a;
|
|
51372
51397
|
for (const path of paths) {
|
|
51373
51398
|
const parent = path.parentPath;
|
|
@@ -51376,7 +51401,8 @@ function assertValidEffectImportReference(numArgs, paths, context) {
|
|
|
51376
51401
|
const maybeCalleeLoc = path.node.loc;
|
|
51377
51402
|
const hasInferredEffect = maybeCalleeLoc != null &&
|
|
51378
51403
|
context.inferredEffectLocations.has(maybeCalleeLoc);
|
|
51379
|
-
|
|
51404
|
+
const hasAutodepsArg = args.some(isAutodepsSigil);
|
|
51405
|
+
if (hasAutodepsArg && !hasInferredEffect) {
|
|
51380
51406
|
const maybeErrorDiagnostic = matchCompilerDiagnostic(path, context.transformErrors);
|
|
51381
51407
|
throwInvalidReact({
|
|
51382
51408
|
reason: '[InferEffectDependencies] React Compiler is unable to infer dependencies of this effect. ' +
|
|
@@ -51414,9 +51440,9 @@ function validateNoUntransformedReferences(path, filename, logger, env, compileR
|
|
|
51414
51440
|
}
|
|
51415
51441
|
}
|
|
51416
51442
|
if (env.inferEffectDependencies) {
|
|
51417
|
-
for (const { function: { source, importSpecifierName },
|
|
51443
|
+
for (const { function: { source, importSpecifierName }, autodepsIndex, } of env.inferEffectDependencies) {
|
|
51418
51444
|
const module = getOrInsertWith(moduleLoadChecks, source, () => new Map());
|
|
51419
|
-
module.set(importSpecifierName, assertValidEffectImportReference.bind(null,
|
|
51445
|
+
module.set(importSpecifierName, assertValidEffectImportReference.bind(null, autodepsIndex));
|
|
51420
51446
|
}
|
|
51421
51447
|
}
|
|
51422
51448
|
if (moduleLoadChecks.size > 0) {
|
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": "6.1.0-canary-
|
|
4
|
+
"version": "6.1.0-canary-7513996f-20250722",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/facebook/react.git",
|