eslint-plugin-react-hooks 7.0.0-canary-1873ad79-20251015 → 7.0.0-canary-93f85932-20251016
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.
|
@@ -37130,30 +37130,49 @@ function memoizeFbtAndMacroOperandsInSameScope(fn) {
|
|
|
37130
37130
|
...Array.from(FBT_TAGS).map((tag) => [tag, []]),
|
|
37131
37131
|
...((_a = fn.env.config.customMacros) !== null && _a !== void 0 ? _a : []),
|
|
37132
37132
|
]);
|
|
37133
|
-
const
|
|
37133
|
+
const macroTagsCalls = new Set();
|
|
37134
|
+
const macroValues = new Map();
|
|
37134
37135
|
const macroMethods = new Map();
|
|
37135
|
-
|
|
37136
|
-
|
|
37137
|
-
|
|
37138
|
-
|
|
37139
|
-
|
|
37140
|
-
break;
|
|
37136
|
+
visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues);
|
|
37137
|
+
for (const root of macroValues.keys()) {
|
|
37138
|
+
const scope = root.scope;
|
|
37139
|
+
if (scope == null) {
|
|
37140
|
+
continue;
|
|
37141
37141
|
}
|
|
37142
|
+
if (!macroTagsCalls.has(root.id)) {
|
|
37143
|
+
continue;
|
|
37144
|
+
}
|
|
37145
|
+
mergeScopes(root, scope, macroValues, macroTagsCalls);
|
|
37142
37146
|
}
|
|
37143
|
-
return
|
|
37147
|
+
return macroTagsCalls;
|
|
37144
37148
|
}
|
|
37145
37149
|
const FBT_TAGS = new Set([
|
|
37146
37150
|
'fbt',
|
|
37147
37151
|
'fbt:param',
|
|
37152
|
+
'fbt:enum',
|
|
37153
|
+
'fbt:plural',
|
|
37148
37154
|
'fbs',
|
|
37149
37155
|
'fbs:param',
|
|
37156
|
+
'fbs:enum',
|
|
37157
|
+
'fbs:plural',
|
|
37150
37158
|
]);
|
|
37151
37159
|
const SINGLE_CHILD_FBT_TAGS = new Set([
|
|
37152
37160
|
'fbt:param',
|
|
37153
37161
|
'fbs:param',
|
|
37154
37162
|
]);
|
|
37155
|
-
function visit$1(fn, fbtMacroTags,
|
|
37163
|
+
function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
|
|
37156
37164
|
for (const [, block] of fn.body.blocks) {
|
|
37165
|
+
for (const phi of block.phis) {
|
|
37166
|
+
const macroOperands = [];
|
|
37167
|
+
for (const operand of phi.operands.values()) {
|
|
37168
|
+
if (macroValues.has(operand.identifier)) {
|
|
37169
|
+
macroOperands.push(operand.identifier);
|
|
37170
|
+
}
|
|
37171
|
+
}
|
|
37172
|
+
if (macroOperands.length !== 0) {
|
|
37173
|
+
macroValues.set(phi.place.identifier, macroOperands);
|
|
37174
|
+
}
|
|
37175
|
+
}
|
|
37157
37176
|
for (const instruction of block.instructions) {
|
|
37158
37177
|
const { lvalue, value } = instruction;
|
|
37159
37178
|
if (lvalue === null) {
|
|
@@ -37162,11 +37181,11 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37162
37181
|
if (value.kind === 'Primitive' &&
|
|
37163
37182
|
typeof value.value === 'string' &&
|
|
37164
37183
|
matchesExactTag(value.value, fbtMacroTags)) {
|
|
37165
|
-
|
|
37184
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37166
37185
|
}
|
|
37167
37186
|
else if (value.kind === 'LoadGlobal' &&
|
|
37168
37187
|
matchesExactTag(value.binding.name, fbtMacroTags)) {
|
|
37169
|
-
|
|
37188
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37170
37189
|
}
|
|
37171
37190
|
else if (value.kind === 'LoadGlobal' &&
|
|
37172
37191
|
matchTagRoot(value.binding.name, fbtMacroTags) !== null) {
|
|
@@ -37185,7 +37204,7 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37185
37204
|
newMethods.push(method.slice(1));
|
|
37186
37205
|
}
|
|
37187
37206
|
else {
|
|
37188
|
-
|
|
37207
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37189
37208
|
}
|
|
37190
37209
|
}
|
|
37191
37210
|
}
|
|
@@ -37193,46 +37212,40 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37193
37212
|
macroMethods.set(lvalue.identifier.id, newMethods);
|
|
37194
37213
|
}
|
|
37195
37214
|
}
|
|
37196
|
-
else if (
|
|
37197
|
-
|
|
37198
|
-
|
|
37199
|
-
continue;
|
|
37200
|
-
}
|
|
37201
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37202
|
-
operand.identifier.scope = fbtScope;
|
|
37203
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37204
|
-
fbtValues.add(operand.identifier.id);
|
|
37205
|
-
}
|
|
37215
|
+
else if (value.kind === 'PropertyLoad' &&
|
|
37216
|
+
macroTagsCalls.has(value.object.identifier.id)) {
|
|
37217
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37206
37218
|
}
|
|
37207
|
-
else if (isFbtJsxExpression(fbtMacroTags,
|
|
37208
|
-
isFbtJsxChild(
|
|
37209
|
-
|
|
37210
|
-
|
|
37211
|
-
|
|
37212
|
-
}
|
|
37213
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37214
|
-
operand.identifier.scope = fbtScope;
|
|
37215
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37216
|
-
fbtValues.add(operand.identifier.id);
|
|
37217
|
-
}
|
|
37219
|
+
else if (isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) ||
|
|
37220
|
+
isFbtJsxChild(macroTagsCalls, lvalue, value) ||
|
|
37221
|
+
isFbtCallExpression(macroTagsCalls, value)) {
|
|
37222
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37223
|
+
macroValues.set(lvalue.identifier, Array.from(eachInstructionValueOperand(value), operand => operand.identifier));
|
|
37218
37224
|
}
|
|
37219
|
-
else if (
|
|
37220
|
-
const
|
|
37221
|
-
|
|
37222
|
-
|
|
37223
|
-
|
|
37224
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37225
|
-
if (operand.identifier.name !== null &&
|
|
37226
|
-
operand.identifier.name.kind === 'named') {
|
|
37227
|
-
continue;
|
|
37225
|
+
else if (Iterable_some(eachInstructionValueOperand(value), operand => macroValues.has(operand.identifier))) {
|
|
37226
|
+
const macroOperands = [];
|
|
37227
|
+
for (const operand of eachInstructionValueOperand(value)) {
|
|
37228
|
+
if (macroValues.has(operand.identifier)) {
|
|
37229
|
+
macroOperands.push(operand.identifier);
|
|
37228
37230
|
}
|
|
37229
|
-
operand.identifier.scope = fbtScope;
|
|
37230
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37231
37231
|
}
|
|
37232
|
+
macroValues.set(lvalue.identifier, macroOperands);
|
|
37232
37233
|
}
|
|
37233
37234
|
}
|
|
37234
37235
|
}
|
|
37235
37236
|
}
|
|
37237
|
+
function mergeScopes(root, scope, macroValues, macroTagsCalls) {
|
|
37238
|
+
const operands = macroValues.get(root);
|
|
37239
|
+
if (operands == null) {
|
|
37240
|
+
return;
|
|
37241
|
+
}
|
|
37242
|
+
for (const operand of operands) {
|
|
37243
|
+
operand.scope = scope;
|
|
37244
|
+
expandFbtScopeRange(scope.range, operand.mutableRange);
|
|
37245
|
+
macroTagsCalls.add(operand.id);
|
|
37246
|
+
mergeScopes(operand, scope, macroValues, macroTagsCalls);
|
|
37247
|
+
}
|
|
37248
|
+
}
|
|
37236
37249
|
function matchesExactTag(s, tags) {
|
|
37237
37250
|
return Array.from(tags).some(macro => typeof macro === 'string'
|
|
37238
37251
|
? s === macro
|
|
@@ -37256,22 +37269,23 @@ function matchTagRoot(s, tags) {
|
|
|
37256
37269
|
return null;
|
|
37257
37270
|
}
|
|
37258
37271
|
}
|
|
37259
|
-
function isFbtCallExpression(
|
|
37272
|
+
function isFbtCallExpression(macroTagsCalls, value) {
|
|
37260
37273
|
return ((value.kind === 'CallExpression' &&
|
|
37261
|
-
|
|
37262
|
-
(value.kind === 'MethodCall' &&
|
|
37274
|
+
macroTagsCalls.has(value.callee.identifier.id)) ||
|
|
37275
|
+
(value.kind === 'MethodCall' &&
|
|
37276
|
+
macroTagsCalls.has(value.property.identifier.id)));
|
|
37263
37277
|
}
|
|
37264
|
-
function isFbtJsxExpression(fbtMacroTags,
|
|
37278
|
+
function isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) {
|
|
37265
37279
|
return (value.kind === 'JsxExpression' &&
|
|
37266
37280
|
((value.tag.kind === 'Identifier' &&
|
|
37267
|
-
|
|
37281
|
+
macroTagsCalls.has(value.tag.identifier.id)) ||
|
|
37268
37282
|
(value.tag.kind === 'BuiltinTag' &&
|
|
37269
37283
|
matchesExactTag(value.tag.name, fbtMacroTags))));
|
|
37270
37284
|
}
|
|
37271
|
-
function isFbtJsxChild(
|
|
37285
|
+
function isFbtJsxChild(macroTagsCalls, lvalue, value) {
|
|
37272
37286
|
return ((value.kind === 'JsxExpression' || value.kind === 'JsxFragment') &&
|
|
37273
37287
|
lvalue !== null &&
|
|
37274
|
-
|
|
37288
|
+
macroTagsCalls.has(lvalue.identifier.id));
|
|
37275
37289
|
}
|
|
37276
37290
|
function expandFbtScopeRange(fbtRange, extendWith) {
|
|
37277
37291
|
if (extendWith.start !== 0) {
|
|
@@ -48124,7 +48138,7 @@ function* generateInstructionTypes(env, names, instr) {
|
|
|
48124
48138
|
});
|
|
48125
48139
|
}
|
|
48126
48140
|
else {
|
|
48127
|
-
|
|
48141
|
+
continue;
|
|
48128
48142
|
}
|
|
48129
48143
|
}
|
|
48130
48144
|
}
|
|
@@ -36957,30 +36957,49 @@ function memoizeFbtAndMacroOperandsInSameScope(fn) {
|
|
|
36957
36957
|
...Array.from(FBT_TAGS).map((tag) => [tag, []]),
|
|
36958
36958
|
...((_a = fn.env.config.customMacros) !== null && _a !== void 0 ? _a : []),
|
|
36959
36959
|
]);
|
|
36960
|
-
const
|
|
36960
|
+
const macroTagsCalls = new Set();
|
|
36961
|
+
const macroValues = new Map();
|
|
36961
36962
|
const macroMethods = new Map();
|
|
36962
|
-
|
|
36963
|
-
|
|
36964
|
-
|
|
36965
|
-
|
|
36966
|
-
|
|
36967
|
-
break;
|
|
36963
|
+
visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues);
|
|
36964
|
+
for (const root of macroValues.keys()) {
|
|
36965
|
+
const scope = root.scope;
|
|
36966
|
+
if (scope == null) {
|
|
36967
|
+
continue;
|
|
36968
36968
|
}
|
|
36969
|
+
if (!macroTagsCalls.has(root.id)) {
|
|
36970
|
+
continue;
|
|
36971
|
+
}
|
|
36972
|
+
mergeScopes(root, scope, macroValues, macroTagsCalls);
|
|
36969
36973
|
}
|
|
36970
|
-
return
|
|
36974
|
+
return macroTagsCalls;
|
|
36971
36975
|
}
|
|
36972
36976
|
const FBT_TAGS = new Set([
|
|
36973
36977
|
'fbt',
|
|
36974
36978
|
'fbt:param',
|
|
36979
|
+
'fbt:enum',
|
|
36980
|
+
'fbt:plural',
|
|
36975
36981
|
'fbs',
|
|
36976
36982
|
'fbs:param',
|
|
36983
|
+
'fbs:enum',
|
|
36984
|
+
'fbs:plural',
|
|
36977
36985
|
]);
|
|
36978
36986
|
const SINGLE_CHILD_FBT_TAGS = new Set([
|
|
36979
36987
|
'fbt:param',
|
|
36980
36988
|
'fbs:param',
|
|
36981
36989
|
]);
|
|
36982
|
-
function visit$1(fn, fbtMacroTags,
|
|
36990
|
+
function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
|
|
36983
36991
|
for (const [, block] of fn.body.blocks) {
|
|
36992
|
+
for (const phi of block.phis) {
|
|
36993
|
+
const macroOperands = [];
|
|
36994
|
+
for (const operand of phi.operands.values()) {
|
|
36995
|
+
if (macroValues.has(operand.identifier)) {
|
|
36996
|
+
macroOperands.push(operand.identifier);
|
|
36997
|
+
}
|
|
36998
|
+
}
|
|
36999
|
+
if (macroOperands.length !== 0) {
|
|
37000
|
+
macroValues.set(phi.place.identifier, macroOperands);
|
|
37001
|
+
}
|
|
37002
|
+
}
|
|
36984
37003
|
for (const instruction of block.instructions) {
|
|
36985
37004
|
const { lvalue, value } = instruction;
|
|
36986
37005
|
if (lvalue === null) {
|
|
@@ -36989,11 +37008,11 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
36989
37008
|
if (value.kind === 'Primitive' &&
|
|
36990
37009
|
typeof value.value === 'string' &&
|
|
36991
37010
|
matchesExactTag(value.value, fbtMacroTags)) {
|
|
36992
|
-
|
|
37011
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
36993
37012
|
}
|
|
36994
37013
|
else if (value.kind === 'LoadGlobal' &&
|
|
36995
37014
|
matchesExactTag(value.binding.name, fbtMacroTags)) {
|
|
36996
|
-
|
|
37015
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
36997
37016
|
}
|
|
36998
37017
|
else if (value.kind === 'LoadGlobal' &&
|
|
36999
37018
|
matchTagRoot(value.binding.name, fbtMacroTags) !== null) {
|
|
@@ -37012,7 +37031,7 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37012
37031
|
newMethods.push(method.slice(1));
|
|
37013
37032
|
}
|
|
37014
37033
|
else {
|
|
37015
|
-
|
|
37034
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37016
37035
|
}
|
|
37017
37036
|
}
|
|
37018
37037
|
}
|
|
@@ -37020,46 +37039,40 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37020
37039
|
macroMethods.set(lvalue.identifier.id, newMethods);
|
|
37021
37040
|
}
|
|
37022
37041
|
}
|
|
37023
|
-
else if (
|
|
37024
|
-
|
|
37025
|
-
|
|
37026
|
-
continue;
|
|
37027
|
-
}
|
|
37028
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37029
|
-
operand.identifier.scope = fbtScope;
|
|
37030
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37031
|
-
fbtValues.add(operand.identifier.id);
|
|
37032
|
-
}
|
|
37042
|
+
else if (value.kind === 'PropertyLoad' &&
|
|
37043
|
+
macroTagsCalls.has(value.object.identifier.id)) {
|
|
37044
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37033
37045
|
}
|
|
37034
|
-
else if (isFbtJsxExpression(fbtMacroTags,
|
|
37035
|
-
isFbtJsxChild(
|
|
37036
|
-
|
|
37037
|
-
|
|
37038
|
-
|
|
37039
|
-
}
|
|
37040
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37041
|
-
operand.identifier.scope = fbtScope;
|
|
37042
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37043
|
-
fbtValues.add(operand.identifier.id);
|
|
37044
|
-
}
|
|
37046
|
+
else if (isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) ||
|
|
37047
|
+
isFbtJsxChild(macroTagsCalls, lvalue, value) ||
|
|
37048
|
+
isFbtCallExpression(macroTagsCalls, value)) {
|
|
37049
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37050
|
+
macroValues.set(lvalue.identifier, Array.from(eachInstructionValueOperand(value), operand => operand.identifier));
|
|
37045
37051
|
}
|
|
37046
|
-
else if (
|
|
37047
|
-
const
|
|
37048
|
-
|
|
37049
|
-
|
|
37050
|
-
|
|
37051
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37052
|
-
if (operand.identifier.name !== null &&
|
|
37053
|
-
operand.identifier.name.kind === 'named') {
|
|
37054
|
-
continue;
|
|
37052
|
+
else if (Iterable_some(eachInstructionValueOperand(value), operand => macroValues.has(operand.identifier))) {
|
|
37053
|
+
const macroOperands = [];
|
|
37054
|
+
for (const operand of eachInstructionValueOperand(value)) {
|
|
37055
|
+
if (macroValues.has(operand.identifier)) {
|
|
37056
|
+
macroOperands.push(operand.identifier);
|
|
37055
37057
|
}
|
|
37056
|
-
operand.identifier.scope = fbtScope;
|
|
37057
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37058
37058
|
}
|
|
37059
|
+
macroValues.set(lvalue.identifier, macroOperands);
|
|
37059
37060
|
}
|
|
37060
37061
|
}
|
|
37061
37062
|
}
|
|
37062
37063
|
}
|
|
37064
|
+
function mergeScopes(root, scope, macroValues, macroTagsCalls) {
|
|
37065
|
+
const operands = macroValues.get(root);
|
|
37066
|
+
if (operands == null) {
|
|
37067
|
+
return;
|
|
37068
|
+
}
|
|
37069
|
+
for (const operand of operands) {
|
|
37070
|
+
operand.scope = scope;
|
|
37071
|
+
expandFbtScopeRange(scope.range, operand.mutableRange);
|
|
37072
|
+
macroTagsCalls.add(operand.id);
|
|
37073
|
+
mergeScopes(operand, scope, macroValues, macroTagsCalls);
|
|
37074
|
+
}
|
|
37075
|
+
}
|
|
37063
37076
|
function matchesExactTag(s, tags) {
|
|
37064
37077
|
return Array.from(tags).some(macro => typeof macro === 'string'
|
|
37065
37078
|
? s === macro
|
|
@@ -37083,22 +37096,23 @@ function matchTagRoot(s, tags) {
|
|
|
37083
37096
|
return null;
|
|
37084
37097
|
}
|
|
37085
37098
|
}
|
|
37086
|
-
function isFbtCallExpression(
|
|
37099
|
+
function isFbtCallExpression(macroTagsCalls, value) {
|
|
37087
37100
|
return ((value.kind === 'CallExpression' &&
|
|
37088
|
-
|
|
37089
|
-
(value.kind === 'MethodCall' &&
|
|
37101
|
+
macroTagsCalls.has(value.callee.identifier.id)) ||
|
|
37102
|
+
(value.kind === 'MethodCall' &&
|
|
37103
|
+
macroTagsCalls.has(value.property.identifier.id)));
|
|
37090
37104
|
}
|
|
37091
|
-
function isFbtJsxExpression(fbtMacroTags,
|
|
37105
|
+
function isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) {
|
|
37092
37106
|
return (value.kind === 'JsxExpression' &&
|
|
37093
37107
|
((value.tag.kind === 'Identifier' &&
|
|
37094
|
-
|
|
37108
|
+
macroTagsCalls.has(value.tag.identifier.id)) ||
|
|
37095
37109
|
(value.tag.kind === 'BuiltinTag' &&
|
|
37096
37110
|
matchesExactTag(value.tag.name, fbtMacroTags))));
|
|
37097
37111
|
}
|
|
37098
|
-
function isFbtJsxChild(
|
|
37112
|
+
function isFbtJsxChild(macroTagsCalls, lvalue, value) {
|
|
37099
37113
|
return ((value.kind === 'JsxExpression' || value.kind === 'JsxFragment') &&
|
|
37100
37114
|
lvalue !== null &&
|
|
37101
|
-
|
|
37115
|
+
macroTagsCalls.has(lvalue.identifier.id));
|
|
37102
37116
|
}
|
|
37103
37117
|
function expandFbtScopeRange(fbtRange, extendWith) {
|
|
37104
37118
|
if (extendWith.start !== 0) {
|
|
@@ -47951,7 +47965,7 @@ function* generateInstructionTypes(env, names, instr) {
|
|
|
47951
47965
|
});
|
|
47952
47966
|
}
|
|
47953
47967
|
else {
|
|
47954
|
-
|
|
47968
|
+
continue;
|
|
47955
47969
|
}
|
|
47956
47970
|
}
|
|
47957
47971
|
}
|
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.0.0-canary-
|
|
4
|
+
"version": "7.0.0-canary-93f85932-20251016",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/facebook/react.git",
|