eslint-plugin-react-x 1.23.2-next.6 → 1.23.3-next.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.
Files changed (3) hide show
  1. package/dist/index.js +517 -173
  2. package/dist/index.mjs +517 -173
  3. package/package.json +10 -10
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
42
42
 
43
43
  // package.json
44
44
  var name = "eslint-plugin-react-x";
45
- var version = "1.23.2-next.6";
45
+ var version = "1.23.3-next.0";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -132,11 +132,17 @@ var ensure_forward_ref_using_ref_default = createRule({
132
132
  create(context) {
133
133
  return {
134
134
  CallExpression(node) {
135
- if (!core.isForwardRefCall(node, context)) return;
135
+ if (!core.isForwardRefCall(node, context)) {
136
+ return;
137
+ }
136
138
  const [component] = node.arguments;
137
- if (!component || !AST11__namespace.isFunction(component)) return;
139
+ if (!component || !AST11__namespace.isFunction(component)) {
140
+ return;
141
+ }
138
142
  const [_, ref] = component.params;
139
- if (ref) return;
143
+ if (ref) {
144
+ return;
145
+ }
140
146
  context.report({
141
147
  messageId: "ensureForwardRefUsingRef",
142
148
  node: component
@@ -179,17 +185,23 @@ var no_access_state_in_setstate_default = createRule({
179
185
  },
180
186
  name: RULE_NAME4,
181
187
  create(context) {
182
- if (!context.sourceCode.text.includes("setState")) return {};
188
+ if (!context.sourceCode.text.includes("setState")) {
189
+ return {};
190
+ }
183
191
  const classStack = [];
184
192
  const methodStack = [];
185
193
  const setStateStack = [];
186
194
  return {
187
195
  CallExpression(node) {
188
- if (!core.isThisSetState(node)) return;
196
+ if (!core.isThisSetState(node)) {
197
+ return;
198
+ }
189
199
  setStateStack.push([node, false]);
190
200
  },
191
201
  "CallExpression:exit"(node) {
192
- if (!core.isThisSetState(node)) return;
202
+ if (!core.isThisSetState(node)) {
203
+ return;
204
+ }
193
205
  setStateStack.pop();
194
206
  },
195
207
  ClassDeclaration(node) {
@@ -205,14 +217,24 @@ var no_access_state_in_setstate_default = createRule({
205
217
  classStack.pop();
206
218
  },
207
219
  MemberExpression(node) {
208
- if (!AST11__namespace.isThisExpression(node.object)) return;
220
+ if (!AST11__namespace.isThisExpression(node.object)) {
221
+ return;
222
+ }
209
223
  const [currClass, isComponent] = classStack.at(-1) ?? [];
210
- if (!currClass || !isComponent) return;
224
+ if (!currClass || !isComponent) {
225
+ return;
226
+ }
211
227
  const [currMethod, isStatic] = methodStack.at(-1) ?? [];
212
- if (!currMethod || isStatic) return;
228
+ if (!currMethod || isStatic) {
229
+ return;
230
+ }
213
231
  const [setState, hasThisState] = setStateStack.at(-1) ?? [];
214
- if (!setState || hasThisState) return;
215
- if (!eff.O.exists(getName(node.property), (name2) => name2 === "state")) return;
232
+ if (!setState || hasThisState) {
233
+ return;
234
+ }
235
+ if (!eff.O.exists(getName(node.property), (name2) => name2 === "state")) {
236
+ return;
237
+ }
216
238
  context.report({ messageId: "noAccessStateInSetstate", node });
217
239
  },
218
240
  MethodDefinition(node) {
@@ -229,19 +251,29 @@ var no_access_state_in_setstate_default = createRule({
229
251
  },
230
252
  VariableDeclarator(node) {
231
253
  const [currClass, isComponent] = classStack.at(-1) ?? [];
232
- if (!currClass || !isComponent) return;
254
+ if (!currClass || !isComponent) {
255
+ return;
256
+ }
233
257
  const [currMethod, isStatic] = methodStack.at(-1) ?? [];
234
- if (!currMethod || isStatic) return;
258
+ if (!currMethod || isStatic) {
259
+ return;
260
+ }
235
261
  const [setState, hasThisState] = setStateStack.at(-1) ?? [];
236
- if (!setState || hasThisState) return;
237
- if (!(node.init && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern)) return;
262
+ if (!setState || hasThisState) {
263
+ return;
264
+ }
265
+ if (!(node.init && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern)) {
266
+ return;
267
+ }
238
268
  const hasState = node.id.properties.some((prop) => {
239
269
  if (prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key)) {
240
270
  return eff.O.exists(getName(prop.key), (name2) => name2 === "state");
241
271
  }
242
272
  return false;
243
273
  });
244
- if (!hasState) return;
274
+ if (!hasState) {
275
+ return;
276
+ }
245
277
  context.report({ messageId: "noAccessStateInSetstate", node });
246
278
  }
247
279
  };
@@ -286,9 +318,13 @@ function isUsingReactChildren(node, context) {
286
318
  if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
287
319
  return false;
288
320
  }
289
- if (!isReactChildrenMethod(callee.property.name)) return false;
321
+ if (!isReactChildrenMethod(callee.property.name)) {
322
+ return false;
323
+ }
290
324
  const initialScope = context.sourceCode.getScope(node);
291
- if (callee.object.type === types.AST_NODE_TYPES.Identifier && callee.object.name === "Children") return true;
325
+ if (callee.object.type === types.AST_NODE_TYPES.Identifier && callee.object.name === "Children") {
326
+ return true;
327
+ }
292
328
  if (callee.object.type === types.AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
293
329
  return core.isInitializedFromReact(callee.object.object.name, initialScope, settings.importSource);
294
330
  }
@@ -296,19 +332,31 @@ function isUsingReactChildren(node, context) {
296
332
  }
297
333
  function getMapIndexParamName(node, context) {
298
334
  const { callee } = node;
299
- if (callee.type !== types.AST_NODE_TYPES.MemberExpression) return eff.O.none();
300
- if (callee.property.type !== types.AST_NODE_TYPES.Identifier) return eff.O.none();
335
+ if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
336
+ return eff.O.none();
337
+ }
338
+ if (callee.property.type !== types.AST_NODE_TYPES.Identifier) {
339
+ return eff.O.none();
340
+ }
301
341
  const { name: name2 } = callee.property;
302
- if (!iteratorFunctionIndexParamPosition.has(name2)) return eff.O.none();
342
+ if (!iteratorFunctionIndexParamPosition.has(name2)) {
343
+ return eff.O.none();
344
+ }
303
345
  const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
304
- if (!callbackArg) return eff.O.none();
346
+ if (!callbackArg) {
347
+ return eff.O.none();
348
+ }
305
349
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
306
350
  return eff.O.none();
307
351
  }
308
352
  const { params } = callbackArg;
309
353
  const indexParamPosition = iteratorFunctionIndexParamPosition.get(name2);
310
- if (eff.isNullable(indexParamPosition)) return eff.O.none();
311
- if (params.length < indexParamPosition + 1) return eff.O.none();
354
+ if (eff.isNullable(indexParamPosition)) {
355
+ return eff.O.none();
356
+ }
357
+ if (params.length < indexParamPosition + 1) {
358
+ return eff.O.none();
359
+ }
312
360
  const param = params.at(indexParamPosition);
313
361
  return param && "name" in param ? eff.O.some(param.name) : eff.O.none();
314
362
  }
@@ -332,16 +380,22 @@ var no_array_index_key_default = createRule({
332
380
  return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some(eff.O.exists((name2) => name2 === node.name));
333
381
  }
334
382
  function getReportDescriptor(node) {
335
- if (isArrayIndex(node)) return [{ messageId: "noArrayIndexKey", node }];
383
+ if (isArrayIndex(node)) {
384
+ return [{ messageId: "noArrayIndexKey", node }];
385
+ }
336
386
  if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.TemplateLiteral, types.AST_NODE_TYPES.BinaryExpression])(node)) {
337
387
  const exps = types.AST_NODE_TYPES.TemplateLiteral === node.type ? node.expressions : AST11__namespace.getIdentifiersFromBinaryExpression(node);
338
388
  return exps.reduce((acc, exp) => {
339
- if (isArrayIndex(exp)) return [...acc, { messageId: "noArrayIndexKey", node: exp }];
389
+ if (isArrayIndex(exp)) {
390
+ return [...acc, { messageId: "noArrayIndexKey", node: exp }];
391
+ }
340
392
  return acc;
341
393
  }, []);
342
394
  }
343
395
  if (isToStringCall(node)) {
344
- if (!("object" in node.callee && isArrayIndex(node.callee.object))) return [];
396
+ if (!("object" in node.callee && isArrayIndex(node.callee.object))) {
397
+ return [];
398
+ }
345
399
  return [{ messageId: "noArrayIndexKey", node: node.callee.object }];
346
400
  }
347
401
  const isStringCall = tsPattern.isMatching({
@@ -353,20 +407,32 @@ var no_array_index_key_default = createRule({
353
407
  }, node);
354
408
  if (isStringCall) {
355
409
  const [arg] = node.arguments;
356
- if (arg && isArrayIndex(arg)) return [{ messageId: "noArrayIndexKey", node: arg }];
410
+ if (arg && isArrayIndex(arg)) {
411
+ return [{ messageId: "noArrayIndexKey", node: arg }];
412
+ }
357
413
  }
358
414
  return [];
359
415
  }
360
416
  return {
361
417
  CallExpression(node) {
362
418
  indexParamNames.push(getMapIndexParamName(node, context));
363
- if (node.arguments.length === 0) return;
364
- if (!isCreateOrCloneElementCall(node)) return;
419
+ if (node.arguments.length === 0) {
420
+ return;
421
+ }
422
+ if (!isCreateOrCloneElementCall(node)) {
423
+ return;
424
+ }
365
425
  const [_, props] = node.arguments;
366
- if (props?.type !== types.AST_NODE_TYPES.ObjectExpression) return;
426
+ if (props?.type !== types.AST_NODE_TYPES.ObjectExpression) {
427
+ return;
428
+ }
367
429
  for (const prop of props.properties) {
368
- if (!tsPattern.isMatching({ key: { name: "key" } })(prop)) continue;
369
- if (!("value" in prop)) continue;
430
+ if (!tsPattern.isMatching({ key: { name: "key" } })(prop)) {
431
+ continue;
432
+ }
433
+ if (!("value" in prop)) {
434
+ continue;
435
+ }
370
436
  const descriptors = getReportDescriptor(prop.value);
371
437
  for (const descriptor of descriptors) {
372
438
  context.report(descriptor);
@@ -377,10 +443,16 @@ var no_array_index_key_default = createRule({
377
443
  indexParamNames.pop();
378
444
  },
379
445
  JSXAttribute(node) {
380
- if (node.name.name !== "key") return;
381
- if (indexParamNames.length === 0) return;
446
+ if (node.name.name !== "key") {
447
+ return;
448
+ }
449
+ if (indexParamNames.length === 0) {
450
+ return;
451
+ }
382
452
  const { value } = node;
383
- if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) return;
453
+ if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
454
+ return;
455
+ }
384
456
  const descriptors = getReportDescriptor(value.expression);
385
457
  for (const descriptor of descriptors) {
386
458
  context.report(descriptor);
@@ -608,14 +680,18 @@ var no_class_component_default = createRule({
608
680
  },
609
681
  name: RULE_NAME12,
610
682
  create(context) {
611
- if (!context.sourceCode.text.includes("Component")) return {};
683
+ if (!context.sourceCode.text.includes("Component")) {
684
+ return {};
685
+ }
612
686
  const { ctx, listeners } = core.useComponentCollectorLegacy();
613
687
  return {
614
688
  ...listeners,
615
689
  "Program:exit"(node) {
616
690
  const components = ctx.getAllComponents(node);
617
691
  for (const { name: name2, node: component } of components.values()) {
618
- if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) continue;
692
+ if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
693
+ continue;
694
+ }
619
695
  context.report({
620
696
  messageId: "noClassComponent",
621
697
  node: component,
@@ -650,7 +726,9 @@ var no_clone_element_default = createRule({
650
726
  create(context) {
651
727
  return {
652
728
  CallExpression(node) {
653
- if (!core.isCloneElementCall(node, context)) return;
729
+ if (!core.isCloneElementCall(node, context)) {
730
+ return;
731
+ }
654
732
  context.report({
655
733
  messageId: "noCloneElement",
656
734
  node
@@ -679,14 +757,22 @@ var no_comment_textnodes_default = createRule({
679
757
  name: RULE_NAME14,
680
758
  create(context) {
681
759
  function hasCommentLike(node) {
682
- if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
760
+ if (AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXAttribute, types.AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
761
+ return false;
762
+ }
683
763
  const rawValue = context.sourceCode.getText(node);
684
764
  return /^\s*\/(?:\/|\*)/mu.test(rawValue);
685
765
  }
686
766
  const getReportDescriptor = (node) => {
687
- if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent)) return eff.O.none();
688
- if (!hasCommentLike(node)) return eff.O.none();
689
- if (!node.parent.type.includes("JSX")) return eff.O.none();
767
+ if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent)) {
768
+ return eff.O.none();
769
+ }
770
+ if (!hasCommentLike(node)) {
771
+ return eff.O.none();
772
+ }
773
+ if (!node.parent.type.includes("JSX")) {
774
+ return eff.O.none();
775
+ }
690
776
  return eff.O.some({
691
777
  messageId: "noCommentTextnodes",
692
778
  node
@@ -720,11 +806,15 @@ var no_complex_conditional_rendering_default = createRule({
720
806
  create(context) {
721
807
  function getReportDescriptor(node) {
722
808
  const jsxExpContainer = node.parent?.parent;
723
- if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) return eff.O.none();
809
+ if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
810
+ return eff.O.none();
811
+ }
724
812
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
725
813
  return eff.O.none();
726
814
  }
727
- if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) return eff.O.none();
815
+ if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
816
+ return eff.O.none();
817
+ }
728
818
  return eff.O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer });
729
819
  }
730
820
  const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
@@ -761,7 +851,9 @@ var no_component_will_mount_default = createRule({
761
851
  },
762
852
  name: RULE_NAME16,
763
853
  create(context) {
764
- if (!context.sourceCode.text.includes("componentWillMount")) return {};
854
+ if (!context.sourceCode.text.includes("componentWillMount")) {
855
+ return {};
856
+ }
765
857
  const { ctx, listeners } = core.useComponentCollectorLegacy();
766
858
  return {
767
859
  ...listeners,
@@ -775,7 +867,9 @@ var no_component_will_mount_default = createRule({
775
867
  messageId: "noComponentWillMount",
776
868
  node: member,
777
869
  fix(fixer) {
778
- if (!("key" in member)) return null;
870
+ if (!("key" in member)) {
871
+ return null;
872
+ }
779
873
  return fixer.replaceText(member.key, "UNSAFE_componentWillMount");
780
874
  }
781
875
  });
@@ -810,7 +904,9 @@ var no_component_will_receive_props_default = createRule({
810
904
  },
811
905
  name: RULE_NAME17,
812
906
  create(context) {
813
- if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
907
+ if (!context.sourceCode.text.includes("componentWillReceiveProps")) {
908
+ return {};
909
+ }
814
910
  const { ctx, listeners } = core.useComponentCollectorLegacy();
815
911
  return {
816
912
  ...listeners,
@@ -824,7 +920,9 @@ var no_component_will_receive_props_default = createRule({
824
920
  messageId: "noComponentWillReceiveProps",
825
921
  node: member,
826
922
  fix(fixer) {
827
- if (!("key" in member)) return null;
923
+ if (!("key" in member)) {
924
+ return null;
925
+ }
828
926
  return fixer.replaceText(member.key, "UNSAFE_componentWillReceiveProps");
829
927
  }
830
928
  });
@@ -859,7 +957,9 @@ var no_component_will_update_default = createRule({
859
957
  },
860
958
  name: RULE_NAME18,
861
959
  create(context) {
862
- if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
960
+ if (!context.sourceCode.text.includes("componentWillUpdate")) {
961
+ return {};
962
+ }
863
963
  const { ctx, listeners } = core.useComponentCollectorLegacy();
864
964
  return {
865
965
  ...listeners,
@@ -873,7 +973,9 @@ var no_component_will_update_default = createRule({
873
973
  messageId: "noComponentWillUpdate",
874
974
  node: member,
875
975
  fix(fixer) {
876
- if (!("key" in member)) return null;
976
+ if (!("key" in member)) {
977
+ return null;
978
+ }
877
979
  return fixer.replaceText(member.key, "UNSAFE_componentWillUpdate");
878
980
  }
879
981
  });
@@ -905,13 +1007,19 @@ var no_context_provider_default = createRule({
905
1007
  },
906
1008
  name: RULE_NAME19,
907
1009
  create(context) {
908
- if (!context.sourceCode.text.includes(".Provider")) return {};
1010
+ if (!context.sourceCode.text.includes(".Provider")) {
1011
+ return {};
1012
+ }
909
1013
  const { version: version2 } = shared.getSettingsFromContext(context);
910
- if (compareVersions.compare(version2, "19.0.0", "<")) return {};
1014
+ if (compareVersions.compare(version2, "19.0.0", "<")) {
1015
+ return {};
1016
+ }
911
1017
  return {
912
1018
  JSXElement(node) {
913
1019
  const elementName = JSX7__namespace.getElementName(node.openingElement);
914
- if (!elementName.endsWith(".Provider")) return;
1020
+ if (!elementName.endsWith(".Provider")) {
1021
+ return;
1022
+ }
915
1023
  context.report({
916
1024
  messageId: "noContextProvider",
917
1025
  node,
@@ -919,7 +1027,9 @@ var no_context_provider_default = createRule({
919
1027
  const providerName = elementName.replace(/\.Provider$/, "");
920
1028
  const openingElement = node.openingElement;
921
1029
  const closingElement = node.closingElement;
922
- if (!closingElement) return fixer.replaceText(openingElement.name, providerName);
1030
+ if (!closingElement) {
1031
+ return fixer.replaceText(openingElement.name, providerName);
1032
+ }
923
1033
  return [
924
1034
  fixer.replaceText(openingElement.name, providerName),
925
1035
  fixer.replaceText(closingElement.name, providerName)
@@ -951,8 +1061,12 @@ var no_create_ref_default = createRule({
951
1061
  create(context) {
952
1062
  return {
953
1063
  CallExpression(node) {
954
- if (!core.isCreateRefCall(node, context)) return;
955
- if (eff.O.isSome(AST11__namespace.findParentNode(node, core.isClassComponent))) return;
1064
+ if (!core.isCreateRefCall(node, context)) {
1065
+ return;
1066
+ }
1067
+ if (eff.O.isSome(AST11__namespace.findParentNode(node, core.isClassComponent))) {
1068
+ return;
1069
+ }
956
1070
  context.report({ messageId: "noCreateRef", node });
957
1071
  }
958
1072
  };
@@ -977,25 +1091,41 @@ var no_default_props_default = createRule({
977
1091
  },
978
1092
  name: RULE_NAME21,
979
1093
  create(context) {
980
- if (!context.sourceCode.text.includes("defaultProps")) return {};
1094
+ if (!context.sourceCode.text.includes("defaultProps")) {
1095
+ return {};
1096
+ }
981
1097
  return {
982
1098
  AssignmentExpression(node) {
983
- if (node.operator !== "=" || node.left.type !== types.AST_NODE_TYPES.MemberExpression) return;
1099
+ if (node.operator !== "=" || node.left.type !== types.AST_NODE_TYPES.MemberExpression) {
1100
+ return;
1101
+ }
984
1102
  const { object, property } = node.left;
985
- if (object.type !== types.AST_NODE_TYPES.Identifier) return;
986
- if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "defaultProps") return;
987
- if (!core.isComponentName(object.name)) return;
1103
+ if (object.type !== types.AST_NODE_TYPES.Identifier) {
1104
+ return;
1105
+ }
1106
+ if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
1107
+ return;
1108
+ }
1109
+ if (!core.isComponentName(object.name)) {
1110
+ return;
1111
+ }
988
1112
  const isComponent = eff.F.pipe(
989
1113
  VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node)),
990
1114
  eff.O.flatMap(VAR__namespace.getVariableNode(0)),
991
1115
  eff.O.exists((n) => AST11__namespace.isFunction(n) || core.isClassComponent(n))
992
1116
  );
993
- if (!isComponent) return;
1117
+ if (!isComponent) {
1118
+ return;
1119
+ }
994
1120
  context.report({ messageId: "noDefaultProps", node: property });
995
1121
  },
996
1122
  PropertyDefinition(node) {
997
- if (!core.isClassComponent(node.parent.parent)) return;
998
- if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") return;
1123
+ if (!core.isClassComponent(node.parent.parent)) {
1124
+ return;
1125
+ }
1126
+ if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") {
1127
+ return;
1128
+ }
999
1129
  context.report({ messageId: "noDefaultProps", node });
1000
1130
  }
1001
1131
  };
@@ -1043,7 +1173,9 @@ var no_direct_mutation_state_default = createRule({
1043
1173
  name: RULE_NAME22,
1044
1174
  create(context) {
1045
1175
  function getReportDescriptor(node) {
1046
- if (!isAssignmentToThisState(node)) return eff.O.none();
1176
+ if (!isAssignmentToThisState(node)) {
1177
+ return eff.O.none();
1178
+ }
1047
1179
  return eff.F.pipe(
1048
1180
  eff.O.Do,
1049
1181
  eff.O.bind("parentClass", () => AST11__namespace.findParentNodeGuard(
@@ -1091,9 +1223,13 @@ var no_duplicate_jsx_props_default = createRule({
1091
1223
  JSXOpeningElement(node) {
1092
1224
  const props = [];
1093
1225
  for (const attr of node.attributes) {
1094
- if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) continue;
1226
+ if (attr.type === types.AST_NODE_TYPES.JSXSpreadAttribute) {
1227
+ continue;
1228
+ }
1095
1229
  const name2 = attr.name.name;
1096
- if (!eff.isString(name2)) continue;
1230
+ if (!eff.isString(name2)) {
1231
+ continue;
1232
+ }
1097
1233
  if (!props.includes(name2)) {
1098
1234
  props.push(name2);
1099
1235
  continue;
@@ -1126,12 +1262,16 @@ var no_duplicate_key_default = createRule({
1126
1262
  },
1127
1263
  name: RULE_NAME24,
1128
1264
  create(context) {
1129
- if (!context.sourceCode.getText().includes("key=")) return {};
1265
+ if (!context.sourceCode.getText().includes("key=")) {
1266
+ return {};
1267
+ }
1130
1268
  const keyedEntries = /* @__PURE__ */ new Map();
1131
1269
  function isKeyValueEqual(a, b) {
1132
1270
  const aValue = a.value;
1133
1271
  const bValue = b.value;
1134
- if (aValue === null || bValue === null) return false;
1272
+ if (aValue === null || bValue === null) {
1273
+ return false;
1274
+ }
1135
1275
  return AST11__namespace.isNodeEqual(aValue, bValue);
1136
1276
  }
1137
1277
  return {
@@ -1157,9 +1297,13 @@ var no_duplicate_key_default = createRule({
1157
1297
  eff.O.bind("iter", ({ call: call2 }) => AST11__namespace.findParentNodeStop(jsxElement, call2, AST11__namespace.isFunction)),
1158
1298
  eff.O.bind("arg0", ({ call: call2 }) => eff.O.fromNullable(call2.arguments[0]))
1159
1299
  );
1160
- if (eff.O.isNone(mbEntry)) return;
1300
+ if (eff.O.isNone(mbEntry)) {
1301
+ return;
1302
+ }
1161
1303
  const { arg0, call, iter } = mbEntry.value;
1162
- if (AST11__namespace.unwrapTypeExpression(arg0) !== iter) return;
1304
+ if (AST11__namespace.unwrapTypeExpression(arg0) !== iter) {
1305
+ return;
1306
+ }
1163
1307
  keyedEntries.set(call, {
1164
1308
  hasDuplicate: node.value?.type === types.AST_NODE_TYPES.Literal,
1165
1309
  keys: [node],
@@ -1170,7 +1314,9 @@ var no_duplicate_key_default = createRule({
1170
1314
  },
1171
1315
  "Program:exit"() {
1172
1316
  for (const { hasDuplicate, keys } of keyedEntries.values()) {
1173
- if (!hasDuplicate) continue;
1317
+ if (!hasDuplicate) {
1318
+ continue;
1319
+ }
1174
1320
  for (const key of keys) {
1175
1321
  context.report({
1176
1322
  messageId: "noDuplicateKey",
@@ -1206,12 +1352,18 @@ var no_forward_ref_default = createRule({
1206
1352
  },
1207
1353
  name: RULE_NAME25,
1208
1354
  create(context) {
1209
- if (!context.sourceCode.text.includes("forwardRef")) return {};
1355
+ if (!context.sourceCode.text.includes("forwardRef")) {
1356
+ return {};
1357
+ }
1210
1358
  const { version: version2 } = shared.getSettingsFromContext(context);
1211
- if (compareVersions.compare(version2, "19.0.0", "<")) return {};
1359
+ if (compareVersions.compare(version2, "19.0.0", "<")) {
1360
+ return {};
1361
+ }
1212
1362
  return {
1213
1363
  CallExpression(node) {
1214
- if (!core.isForwardRefCall(node, context)) return;
1364
+ if (!core.isForwardRefCall(node, context)) {
1365
+ return;
1366
+ }
1215
1367
  context.report({
1216
1368
  messageId: "noForwardRef",
1217
1369
  node,
@@ -1225,7 +1377,9 @@ var no_forward_ref_default = createRule({
1225
1377
  function getFix(node, context) {
1226
1378
  return (fixer) => {
1227
1379
  const [componentNode] = node.arguments;
1228
- if (!componentNode || !AST11__namespace.isFunction(componentNode)) return [];
1380
+ if (!componentNode || !AST11__namespace.isFunction(componentNode)) {
1381
+ return [];
1382
+ }
1229
1383
  return [
1230
1384
  // unwrap component from forwardRef call
1231
1385
  fixer.removeRange([node.range[0], componentNode.range[0]]),
@@ -1244,10 +1398,14 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
1244
1398
  const getText = (node2) => context.sourceCode.getText(node2);
1245
1399
  const [arg0, arg1] = node.params;
1246
1400
  const [typeArg0, typeArg1] = typeArguments;
1247
- if (!arg0) return [];
1401
+ if (!arg0) {
1402
+ return [];
1403
+ }
1248
1404
  const fixedArg0Text = tsPattern.match(arg0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => eff.O.some(`...${n.name}`)).with({ type: types.AST_NODE_TYPES.ObjectPattern }, (n) => eff.O.some(n.properties.map(getText).join(", "))).otherwise(eff.O.none);
1249
1405
  const fixedArg1Text = tsPattern.match(arg1).with(tsPattern.P.nullish, () => eff.O.some("ref")).with({ type: types.AST_NODE_TYPES.Identifier, name: "ref" }, () => eff.O.some("ref")).with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.not("ref") }, (n) => eff.O.some(`ref: ${n.name}`)).otherwise(eff.O.none);
1250
- if (eff.O.isNone(fixedArg0Text) || eff.O.isNone(fixedArg1Text)) return [];
1406
+ if (eff.O.isNone(fixedArg0Text) || eff.O.isNone(fixedArg1Text)) {
1407
+ return [];
1408
+ }
1251
1409
  const fixedPropsText = fixedArg0Text.value;
1252
1410
  const fixedRefText = fixedArg1Text.value;
1253
1411
  if (!typeArg0 || !typeArg1) {
@@ -1427,7 +1585,9 @@ var no_leaked_conditional_rendering_default = createRule({
1427
1585
  },
1428
1586
  name: RULE_NAME27,
1429
1587
  create(context) {
1430
- if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
1588
+ if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) {
1589
+ return {};
1590
+ }
1431
1591
  const { version: version2 } = shared.getSettingsFromContext(context);
1432
1592
  const allowedVariants = [
1433
1593
  "any",
@@ -1445,7 +1605,9 @@ var no_leaked_conditional_rendering_default = createRule({
1445
1605
  function getReportDescriptor(node) {
1446
1606
  return tsPattern.match(node).when(AST11__namespace.isJSX, eff.O.none).with({ type: types.AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1447
1607
  const isLeftUnaryNot = tsPattern.isMatching({ type: types.AST_NODE_TYPES.UnaryExpression, operator: "!" }, left);
1448
- if (isLeftUnaryNot) return getReportDescriptor(right);
1608
+ if (isLeftUnaryNot) {
1609
+ return getReportDescriptor(right);
1610
+ }
1449
1611
  const initialScope = context.sourceCode.getScope(left);
1450
1612
  const isLeftNan = tsPattern.isMatching({ type: types.AST_NODE_TYPES.Identifier, name: "NaN" }, left) || eff.O.exists(VAR__namespace.getStaticValue(left, initialScope), (v) => v === "NaN");
1451
1613
  if (isLeftNan) {
@@ -1458,7 +1620,9 @@ var no_leaked_conditional_rendering_default = createRule({
1458
1620
  const leftType = typeUtils.getConstrainedTypeAtLocation(services, left);
1459
1621
  const leftTypeVariants = inspectVariantTypes(tsApiUtils.unionTypeParts(leftType));
1460
1622
  const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
1461
- if (isLeftValid) return getReportDescriptor(right);
1623
+ if (isLeftValid) {
1624
+ return getReportDescriptor(right);
1625
+ }
1462
1626
  return eff.O.some({
1463
1627
  messageId: "noLeakedConditionalRendering",
1464
1628
  node: left,
@@ -1500,7 +1664,9 @@ var no_missing_component_display_name_default = createRule({
1500
1664
  },
1501
1665
  name: RULE_NAME28,
1502
1666
  create(context) {
1503
- if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
1667
+ if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) {
1668
+ return {};
1669
+ }
1504
1670
  const { ctx, listeners } = core.useComponentCollector(context);
1505
1671
  return {
1506
1672
  ...listeners,
@@ -1508,8 +1674,12 @@ var no_missing_component_display_name_default = createRule({
1508
1674
  const components = ctx.getAllComponents(node);
1509
1675
  for (const { node: node2, displayName, flag } of components.values()) {
1510
1676
  const isMemoOrForwardRef = Boolean(flag & core.ERFunctionComponentFlag.ForwardRef) || Boolean(flag & core.ERFunctionComponentFlag.Memo);
1511
- if (eff.O.isSome(AST11__namespace.getFunctionIdentifier(node2))) continue;
1512
- if (!isMemoOrForwardRef) continue;
1677
+ if (eff.O.isSome(AST11__namespace.getFunctionIdentifier(node2))) {
1678
+ continue;
1679
+ }
1680
+ if (!isMemoOrForwardRef) {
1681
+ continue;
1682
+ }
1513
1683
  if (eff.O.isNone(displayName)) {
1514
1684
  context.report({
1515
1685
  messageId: "noMissingComponentDisplayName",
@@ -1567,13 +1737,17 @@ var no_missing_key_default = createRule({
1567
1737
  function checkExpression(node) {
1568
1738
  switch (node.type) {
1569
1739
  case types.AST_NODE_TYPES.ConditionalExpression:
1570
- if (!("consequent" in node)) return eff.O.none();
1740
+ if (!("consequent" in node)) {
1741
+ return eff.O.none();
1742
+ }
1571
1743
  return eff.O.orElse(checkIteratorElement(node.consequent), () => checkIteratorElement(node.alternate));
1572
1744
  case types.AST_NODE_TYPES.JSXElement:
1573
1745
  case types.AST_NODE_TYPES.JSXFragment:
1574
1746
  return checkIteratorElement(node);
1575
1747
  case types.AST_NODE_TYPES.LogicalExpression:
1576
- if (!("left" in node)) return eff.O.none();
1748
+ if (!("left" in node)) {
1749
+ return eff.O.none();
1750
+ }
1577
1751
  return eff.O.orElse(checkIteratorElement(node.left), () => checkIteratorElement(node.right));
1578
1752
  default:
1579
1753
  return eff.O.none();
@@ -1581,16 +1755,22 @@ var no_missing_key_default = createRule({
1581
1755
  }
1582
1756
  function checkBlockStatement(node) {
1583
1757
  return AST11__namespace.getNestedReturnStatements(node).reduce((acc, statement) => {
1584
- if (!statement.argument) return acc;
1758
+ if (!statement.argument) {
1759
+ return acc;
1760
+ }
1585
1761
  const mbDescriptor = checkIteratorElement(statement.argument);
1586
1762
  return eff.O.isNone(mbDescriptor) ? acc : [...acc, mbDescriptor.value];
1587
1763
  }, []);
1588
1764
  }
1589
1765
  return {
1590
1766
  ArrayExpression(node) {
1591
- if (state.isWithinChildrenToArray) return;
1767
+ if (state.isWithinChildrenToArray) {
1768
+ return;
1769
+ }
1592
1770
  const elements = node.elements.filter(AST11__namespace.is(types.AST_NODE_TYPES.JSXElement));
1593
- if (elements.length === 0) return;
1771
+ if (elements.length === 0) {
1772
+ return;
1773
+ }
1594
1774
  const initialScope = context.sourceCode.getScope(node);
1595
1775
  for (const element of elements) {
1596
1776
  if (!JSX7__namespace.hasProp(element.openingElement.attributes, "key", initialScope)) {
@@ -1603,7 +1783,9 @@ var no_missing_key_default = createRule({
1603
1783
  },
1604
1784
  CallExpression(node) {
1605
1785
  state.isWithinChildrenToArray ||= core.isChildrenToArrayCall(node, context);
1606
- if (state.isWithinChildrenToArray) return;
1786
+ if (state.isWithinChildrenToArray) {
1787
+ return;
1788
+ }
1607
1789
  const isMapCall = AST11__namespace.isMapCallLoose(node);
1608
1790
  const isArrayFromCall = tsPattern.isMatching({
1609
1791
  type: types.AST_NODE_TYPES.CallExpression,
@@ -1614,9 +1796,13 @@ var no_missing_key_default = createRule({
1614
1796
  }
1615
1797
  }
1616
1798
  }, node);
1617
- if (!isMapCall && !isArrayFromCall) return;
1799
+ if (!isMapCall && !isArrayFromCall) {
1800
+ return;
1801
+ }
1618
1802
  const fn = node.arguments[isMapCall ? 0 : 1];
1619
- if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(fn)) return;
1803
+ if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(fn)) {
1804
+ return;
1805
+ }
1620
1806
  if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
1621
1807
  for (const descriptor of checkBlockStatement(fn.body)) {
1622
1808
  context.report(descriptor);
@@ -1626,11 +1812,15 @@ var no_missing_key_default = createRule({
1626
1812
  eff.O.map(checkExpression(fn.body), context.report);
1627
1813
  },
1628
1814
  "CallExpression:exit"(node) {
1629
- if (!core.isChildrenToArrayCall(node, context)) return;
1815
+ if (!core.isChildrenToArrayCall(node, context)) {
1816
+ return;
1817
+ }
1630
1818
  state.isWithinChildrenToArray = false;
1631
1819
  },
1632
1820
  JSXFragment(node) {
1633
- if (state.isWithinChildrenToArray) return;
1821
+ if (state.isWithinChildrenToArray) {
1822
+ return;
1823
+ }
1634
1824
  if (node.parent.type === types.AST_NODE_TYPES.ArrayExpression) {
1635
1825
  context.report({
1636
1826
  messageId: "noMissingKeyWithFragment",
@@ -1677,8 +1867,12 @@ var no_nested_components_default = createRule({
1677
1867
  return AST11__namespace.isClass(node2) && classComponents.some((component) => component.node === node2);
1678
1868
  };
1679
1869
  for (const { name: componentName, node: component } of functionComponents) {
1680
- if (core.isDirectValueOfRenderPropertyLoose(component)) continue;
1681
- if (eff.O.isNone(componentName)) continue;
1870
+ if (core.isDirectValueOfRenderPropertyLoose(component)) {
1871
+ continue;
1872
+ }
1873
+ if (eff.O.isNone(componentName)) {
1874
+ continue;
1875
+ }
1682
1876
  const name2 = componentName.value;
1683
1877
  const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
1684
1878
  const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || eff.O.isSome(JSX7__namespace.findParentProp(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer));
@@ -1766,25 +1960,41 @@ var no_prop_types_default = createRule({
1766
1960
  },
1767
1961
  name: RULE_NAME31,
1768
1962
  create(context) {
1769
- if (!context.sourceCode.text.includes("propTypes")) return {};
1963
+ if (!context.sourceCode.text.includes("propTypes")) {
1964
+ return {};
1965
+ }
1770
1966
  return {
1771
1967
  AssignmentExpression(node) {
1772
- if (node.operator !== "=" || node.left.type !== types.AST_NODE_TYPES.MemberExpression) return;
1968
+ if (node.operator !== "=" || node.left.type !== types.AST_NODE_TYPES.MemberExpression) {
1969
+ return;
1970
+ }
1773
1971
  const { object, property } = node.left;
1774
- if (object.type !== types.AST_NODE_TYPES.Identifier) return;
1775
- if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "propTypes") return;
1776
- if (!core.isComponentName(object.name)) return;
1972
+ if (object.type !== types.AST_NODE_TYPES.Identifier) {
1973
+ return;
1974
+ }
1975
+ if (property.type !== types.AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
1976
+ return;
1977
+ }
1978
+ if (!core.isComponentName(object.name)) {
1979
+ return;
1980
+ }
1777
1981
  const isComponent = eff.F.pipe(
1778
1982
  VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node)),
1779
1983
  eff.O.flatMap(VAR__namespace.getVariableNode(0)),
1780
1984
  eff.O.exists((n) => AST11__namespace.isFunction(n) || core.isClassComponent(n))
1781
1985
  );
1782
- if (!isComponent) return;
1986
+ if (!isComponent) {
1987
+ return;
1988
+ }
1783
1989
  context.report({ messageId: "noPropTypes", node: property });
1784
1990
  },
1785
1991
  PropertyDefinition(node) {
1786
- if (!core.isClassComponent(node.parent.parent)) return;
1787
- if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") return;
1992
+ if (!core.isClassComponent(node.parent.parent)) {
1993
+ return;
1994
+ }
1995
+ if (!node.static || node.key.type !== types.AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") {
1996
+ return;
1997
+ }
1788
1998
  context.report({ messageId: "noPropTypes", node });
1789
1999
  }
1790
2000
  };
@@ -1812,14 +2022,18 @@ var no_redundant_should_component_update_default = createRule({
1812
2022
  },
1813
2023
  name: RULE_NAME32,
1814
2024
  create(context) {
1815
- if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
2025
+ if (!context.sourceCode.text.includes("shouldComponentUpdate")) {
2026
+ return {};
2027
+ }
1816
2028
  const { ctx, listeners } = core.useComponentCollectorLegacy();
1817
2029
  return {
1818
2030
  ...listeners,
1819
2031
  "Program:exit"(node) {
1820
2032
  const components = ctx.getAllComponents(node);
1821
2033
  for (const { name: name2, node: component, flag } of components.values()) {
1822
- if (!(flag & core.ERClassComponentFlag.PureComponent)) continue;
2034
+ if (!(flag & core.ERClassComponentFlag.PureComponent)) {
2035
+ continue;
2036
+ }
1823
2037
  const { body } = component.body;
1824
2038
  for (const member of body) {
1825
2039
  if (isShouldComponentUpdate(member)) {
@@ -1859,9 +2073,13 @@ var no_set_state_in_component_did_mount_default = createRule({
1859
2073
  },
1860
2074
  name: RULE_NAME33,
1861
2075
  create(context) {
1862
- if (!context.sourceCode.text.includes("componentDidMount")) return {};
2076
+ if (!context.sourceCode.text.includes("componentDidMount")) {
2077
+ return {};
2078
+ }
1863
2079
  function getReportDescriptor(node) {
1864
- if (!core.isThisSetState(node)) return eff.O.none();
2080
+ if (!core.isThisSetState(node)) {
2081
+ return eff.O.none();
2082
+ }
1865
2083
  return eff.F.pipe(
1866
2084
  eff.O.Do,
1867
2085
  eff.O.bind("clazz", () => AST11__namespace.findParentNodeGuard(node, core.isClassComponent)),
@@ -1909,9 +2127,13 @@ var no_set_state_in_component_did_update_default = createRule({
1909
2127
  },
1910
2128
  name: RULE_NAME34,
1911
2129
  create(context) {
1912
- if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
2130
+ if (!context.sourceCode.text.includes("componentDidUpdate")) {
2131
+ return {};
2132
+ }
1913
2133
  function getReportDescriptor(node) {
1914
- if (!core.isThisSetState(node)) return eff.O.none();
2134
+ if (!core.isThisSetState(node)) {
2135
+ return eff.O.none();
2136
+ }
1915
2137
  return eff.F.pipe(
1916
2138
  eff.O.Do,
1917
2139
  eff.O.bind("clazz", () => AST11__namespace.findParentNodeGuard(node, core.isClassComponent)),
@@ -1959,9 +2181,13 @@ var no_set_state_in_component_will_update_default = createRule({
1959
2181
  },
1960
2182
  name: RULE_NAME35,
1961
2183
  create(context) {
1962
- if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
2184
+ if (!context.sourceCode.text.includes("componentWillUpdate")) {
2185
+ return {};
2186
+ }
1963
2187
  function getReportDescriptor(node) {
1964
- if (!core.isThisSetState(node)) return eff.O.none();
2188
+ if (!core.isThisSetState(node)) {
2189
+ return eff.O.none();
2190
+ }
1965
2191
  return eff.F.pipe(
1966
2192
  eff.O.Do,
1967
2193
  eff.O.bind("clazz", () => AST11__namespace.findParentNodeGuard(node, core.isClassComponent)),
@@ -1996,8 +2222,12 @@ function containsStringLiteral({ value }) {
1996
2222
  return value?.type === types.AST_NODE_TYPES.Literal && eff.isString(value.value);
1997
2223
  }
1998
2224
  function containsStringExpressionContainer({ value }) {
1999
- if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) return false;
2000
- if (value.expression.type === types.AST_NODE_TYPES.Literal) return eff.isString(value.expression.value);
2225
+ if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
2226
+ return false;
2227
+ }
2228
+ if (value.expression.type === types.AST_NODE_TYPES.Literal) {
2229
+ return eff.isString(value.expression.value);
2230
+ }
2001
2231
  return value.expression.type === types.AST_NODE_TYPES.TemplateLiteral;
2002
2232
  }
2003
2233
  var no_string_refs_default = createRule({
@@ -2016,7 +2246,9 @@ var no_string_refs_default = createRule({
2016
2246
  create(context) {
2017
2247
  return {
2018
2248
  JSXAttribute(node) {
2019
- if (node.name.name !== "ref") return;
2249
+ if (node.name.name !== "ref") {
2250
+ return;
2251
+ }
2020
2252
  if (containsStringLiteral(node) || containsStringExpressionContainer(node)) {
2021
2253
  context.report({
2022
2254
  messageId: "noStringRefs",
@@ -2049,7 +2281,9 @@ var no_unsafe_component_will_mount_default = createRule({
2049
2281
  },
2050
2282
  name: RULE_NAME37,
2051
2283
  create(context) {
2052
- if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
2284
+ if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) {
2285
+ return {};
2286
+ }
2053
2287
  const { ctx, listeners } = core.useComponentCollectorLegacy();
2054
2288
  return {
2055
2289
  ...listeners,
@@ -2092,7 +2326,9 @@ var no_unsafe_component_will_receive_props_default = createRule({
2092
2326
  },
2093
2327
  name: RULE_NAME38,
2094
2328
  create(context) {
2095
- if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
2329
+ if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
2330
+ return {};
2331
+ }
2096
2332
  const { ctx, listeners } = core.useComponentCollectorLegacy();
2097
2333
  return {
2098
2334
  ...listeners,
@@ -2135,7 +2371,9 @@ var no_unsafe_component_will_update_default = createRule({
2135
2371
  },
2136
2372
  name: RULE_NAME39,
2137
2373
  create(context) {
2138
- if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
2374
+ if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) {
2375
+ return {};
2376
+ }
2139
2377
  const { ctx, listeners } = core.useComponentCollectorLegacy();
2140
2378
  return {
2141
2379
  ...listeners,
@@ -2183,8 +2421,12 @@ var no_unstable_context_value_default = createRule({
2183
2421
  ...listeners,
2184
2422
  JSXOpeningElement(node) {
2185
2423
  const openingElementName = node.name;
2186
- if (openingElementName.type !== types.AST_NODE_TYPES.JSXMemberExpression) return;
2187
- if (openingElementName.property.name !== "Provider") return;
2424
+ if (openingElementName.type !== types.AST_NODE_TYPES.JSXMemberExpression) {
2425
+ return;
2426
+ }
2427
+ if (openingElementName.property.name !== "Provider") {
2428
+ return;
2429
+ }
2188
2430
  eff.F.pipe(
2189
2431
  eff.O.Do,
2190
2432
  eff.O.bind("function", ctx.getCurrentFunction),
@@ -2200,8 +2442,12 @@ var no_unstable_context_value_default = createRule({
2200
2442
  return eff.O.some(VAR__namespace.getValueConstruction(valueExpression, initialScope));
2201
2443
  }),
2202
2444
  eff.O.map((vc) => {
2203
- if (vc.construction.kind === "None") return;
2204
- if (core.isReactHookCall(vc.construction.node)) return;
2445
+ if (vc.construction.kind === "None") {
2446
+ return;
2447
+ }
2448
+ if (core.isReactHookCall(vc.construction.node)) {
2449
+ return;
2450
+ }
2205
2451
  const prevs = constructions.get(vc.function.node) ?? [];
2206
2452
  constructions.set(vc.function.node, [...prevs, vc.construction]);
2207
2453
  })
@@ -2211,7 +2457,9 @@ var no_unstable_context_value_default = createRule({
2211
2457
  const components = ctx.getAllComponents(node).values();
2212
2458
  for (const { node: component } of components) {
2213
2459
  for (const construction of constructions.get(component) ?? []) {
2214
- if (construction.kind === "None") continue;
2460
+ if (construction.kind === "None") {
2461
+ continue;
2462
+ }
2215
2463
  const { kind, node: constructionNode } = construction;
2216
2464
  const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
2217
2465
  context.report({
@@ -2255,12 +2503,16 @@ var no_unstable_default_props_default = createRule({
2255
2503
  for (const { node: component } of components.values()) {
2256
2504
  const { params } = component;
2257
2505
  const [props] = params;
2258
- if (!props) continue;
2506
+ if (!props) {
2507
+ continue;
2508
+ }
2259
2509
  const properties = tsPattern.match(props).with({ type: types.AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: types.AST_NODE_TYPES.Identifier }, ({ name: name2 }) => {
2260
2510
  return declarators.get(component)?.filter((d) => d.init.name === name2).flatMap((d) => d.id.properties) ?? [];
2261
2511
  }).otherwise(() => []);
2262
2512
  for (const prop of properties) {
2263
- if (prop.type !== types.AST_NODE_TYPES.Property || prop.value.type !== types.AST_NODE_TYPES.AssignmentPattern) continue;
2513
+ if (prop.type !== types.AST_NODE_TYPES.Property || prop.value.type !== types.AST_NODE_TYPES.AssignmentPattern) {
2514
+ continue;
2515
+ }
2264
2516
  const { value } = prop;
2265
2517
  const { right } = value;
2266
2518
  const initialScope = context.sourceCode.getScope(value);
@@ -2269,8 +2521,12 @@ var no_unstable_default_props_default = createRule({
2269
2521
  initialScope,
2270
2522
  VAR__namespace.ValueConstructionHint.StrictCallExpression
2271
2523
  );
2272
- if (construction.kind === "None") continue;
2273
- if (core.isReactHookCall(construction.node)) continue;
2524
+ if (construction.kind === "None") {
2525
+ continue;
2526
+ }
2527
+ if (core.isReactHookCall(construction.node)) {
2528
+ continue;
2529
+ }
2274
2530
  const forbiddenType = AST11__namespace.toReadableNodeType(right);
2275
2531
  context.report({
2276
2532
  messageId: "noUnstableDefaultProps",
@@ -2284,7 +2540,9 @@ var no_unstable_default_props_default = createRule({
2284
2540
  },
2285
2541
  "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node) {
2286
2542
  const mbEntry = ctx.getCurrentFunction();
2287
- if (eff.O.isNone(mbEntry)) return;
2543
+ if (eff.O.isNone(mbEntry)) {
2544
+ return;
2545
+ }
2288
2546
  const entry = mbEntry.value;
2289
2547
  const prevs = declarators.get(entry.node) ?? [];
2290
2548
  declarators.set(entry.node, [...prevs, node]);
@@ -2349,21 +2607,31 @@ var no_unused_class_component_members_default = createRule({
2349
2607
  const propertyUsages = /* @__PURE__ */ new WeakMap();
2350
2608
  function classEnter(node) {
2351
2609
  classStack.push(node);
2352
- if (!core.isClassComponent(node)) return;
2610
+ if (!core.isClassComponent(node)) {
2611
+ return;
2612
+ }
2353
2613
  propertyDefs.set(node, /* @__PURE__ */ new Set());
2354
2614
  propertyUsages.set(node, /* @__PURE__ */ new Set());
2355
2615
  }
2356
2616
  function classExit() {
2357
2617
  const currentClass = classStack.pop();
2358
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2618
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2619
+ return;
2620
+ }
2359
2621
  const className = eff.O.map(AST11__namespace.getClassIdentifier(currentClass), (id) => id.name);
2360
2622
  const defs = propertyDefs.get(currentClass);
2361
2623
  const usages = propertyUsages.get(currentClass);
2362
- if (!defs) return;
2624
+ if (!defs) {
2625
+ return;
2626
+ }
2363
2627
  for (const def of defs) {
2364
2628
  const name2 = getName3(def);
2365
- if (eff.O.isNone(name2)) continue;
2366
- if (usages?.has(name2.value) || LIFECYCLE_METHODS.has(name2.value)) continue;
2629
+ if (eff.O.isNone(name2)) {
2630
+ continue;
2631
+ }
2632
+ if (usages?.has(name2.value) || LIFECYCLE_METHODS.has(name2.value)) {
2633
+ continue;
2634
+ }
2367
2635
  context.report({
2368
2636
  messageId: "noUnusedClassComponentMembers",
2369
2637
  node: def,
@@ -2377,8 +2645,12 @@ var no_unused_class_component_members_default = createRule({
2377
2645
  function methodEnter(node) {
2378
2646
  methodStack.push(node);
2379
2647
  const currentClass = classStack.at(-1);
2380
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2381
- if (node.static) return;
2648
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2649
+ return;
2650
+ }
2651
+ if (node.static) {
2652
+ return;
2653
+ }
2382
2654
  if (AST11__namespace.isKeyLiteralLike(node, node.key)) {
2383
2655
  propertyDefs.get(currentClass)?.add(node.key);
2384
2656
  }
@@ -2394,9 +2666,15 @@ var no_unused_class_component_members_default = createRule({
2394
2666
  MemberExpression(node) {
2395
2667
  const currentClass = classStack.at(-1);
2396
2668
  const currentMethod = methodStack.at(-1);
2397
- if (!currentClass || !currentMethod) return;
2398
- if (!core.isClassComponent(currentClass) || currentMethod.static) return;
2399
- if (!AST11__namespace.isThisExpression(node.object) || !AST11__namespace.isKeyLiteralLike(node, node.property)) return;
2669
+ if (!currentClass || !currentMethod) {
2670
+ return;
2671
+ }
2672
+ if (!core.isClassComponent(currentClass) || currentMethod.static) {
2673
+ return;
2674
+ }
2675
+ if (!AST11__namespace.isThisExpression(node.object) || !AST11__namespace.isKeyLiteralLike(node, node.property)) {
2676
+ return;
2677
+ }
2400
2678
  if (node.parent.type === types.AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
2401
2679
  propertyDefs.get(currentClass)?.add(node.property);
2402
2680
  return;
@@ -2410,8 +2688,12 @@ var no_unused_class_component_members_default = createRule({
2410
2688
  VariableDeclarator(node) {
2411
2689
  const currentClass = classStack.at(-1);
2412
2690
  const currentMethod = methodStack.at(-1);
2413
- if (!currentClass || !currentMethod) return;
2414
- if (!core.isClassComponent(currentClass) || currentMethod.static) return;
2691
+ if (!currentClass || !currentMethod) {
2692
+ return;
2693
+ }
2694
+ if (!core.isClassComponent(currentClass) || currentMethod.static) {
2695
+ return;
2696
+ }
2415
2697
  if (node.init && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern) {
2416
2698
  for (const prop of node.id.properties) {
2417
2699
  if (prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key)) {
@@ -2483,10 +2765,14 @@ var no_unused_state_default = createRule({
2483
2765
  }
2484
2766
  function classExit() {
2485
2767
  const currentClass = classStack.pop();
2486
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2768
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2769
+ return;
2770
+ }
2487
2771
  const className = eff.O.map(AST11__namespace.getClassIdentifier(currentClass), (id) => id.name);
2488
2772
  const [def, isUsed] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2489
- if (eff.O.isNone(def) || isUsed) return;
2773
+ if (eff.O.isNone(def) || isUsed) {
2774
+ return;
2775
+ }
2490
2776
  context.report({
2491
2777
  messageId: "noUnusedState",
2492
2778
  node: def.value,
@@ -2498,7 +2784,9 @@ var no_unused_state_default = createRule({
2498
2784
  function methodEnter(node) {
2499
2785
  methodStack.push(node);
2500
2786
  const currentClass = classStack.at(-1);
2501
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2787
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2788
+ return;
2789
+ }
2502
2790
  if (node.static) {
2503
2791
  if (isGetDerivedStateFromProps(node) && node.value.params.length > 1) {
2504
2792
  const [def] = stateDefs.get(currentClass) ?? [eff.O.none()];
@@ -2521,11 +2809,17 @@ var no_unused_state_default = createRule({
2521
2809
  }
2522
2810
  return {
2523
2811
  AssignmentExpression(node) {
2524
- if (!isAssignmentToThisState2(node)) return;
2812
+ if (!isAssignmentToThisState2(node)) {
2813
+ return;
2814
+ }
2525
2815
  const currentClass = classStack.at(-1);
2526
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2816
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2817
+ return;
2818
+ }
2527
2819
  const currentConstructor = constructorStack.at(-1);
2528
- if (!currentConstructor || !currentClass.body.body.includes(currentConstructor)) return;
2820
+ if (!currentConstructor || !currentClass.body.body.includes(currentConstructor)) {
2821
+ return;
2822
+ }
2529
2823
  const [_, isUsed] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2530
2824
  stateDefs.set(currentClass, [eff.O.some(node.left), isUsed]);
2531
2825
  },
@@ -2534,14 +2828,26 @@ var no_unused_state_default = createRule({
2534
2828
  ClassExpression: classEnter,
2535
2829
  "ClassExpression:exit": classExit,
2536
2830
  MemberExpression(node) {
2537
- if (!AST11__namespace.isThisExpression(node.object)) return;
2538
- if (!eff.O.exists(getName4(node.property), (name2) => name2 === "state")) return;
2831
+ if (!AST11__namespace.isThisExpression(node.object)) {
2832
+ return;
2833
+ }
2834
+ if (!eff.O.exists(getName4(node.property), (name2) => name2 === "state")) {
2835
+ return;
2836
+ }
2539
2837
  const currentClass = classStack.at(-1);
2540
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2838
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2839
+ return;
2840
+ }
2541
2841
  const currentMethod = methodStack.at(-1);
2542
- if (!currentMethod || currentMethod.static) return;
2543
- if (currentMethod === constructorStack.at(-1)) return;
2544
- if (!currentClass.body.body.includes(currentMethod)) return;
2842
+ if (!currentMethod || currentMethod.static) {
2843
+ return;
2844
+ }
2845
+ if (currentMethod === constructorStack.at(-1)) {
2846
+ return;
2847
+ }
2848
+ if (!currentClass.body.body.includes(currentMethod)) {
2849
+ return;
2850
+ }
2545
2851
  const [def] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2546
2852
  stateDefs.set(currentClass, [def, true]);
2547
2853
  },
@@ -2553,19 +2859,31 @@ var no_unused_state_default = createRule({
2553
2859
  "PropertyDefinition:exit": methodExit,
2554
2860
  VariableDeclarator(node) {
2555
2861
  const currentClass = classStack.at(-1);
2556
- if (!currentClass || !core.isClassComponent(currentClass)) return;
2862
+ if (!currentClass || !core.isClassComponent(currentClass)) {
2863
+ return;
2864
+ }
2557
2865
  const currentMethod = methodStack.at(-1);
2558
- if (!currentMethod || currentMethod.static) return;
2559
- if (currentMethod === constructorStack.at(-1)) return;
2560
- if (!currentClass.body.body.includes(currentMethod)) return;
2561
- if (!(node.init && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern)) return;
2866
+ if (!currentMethod || currentMethod.static) {
2867
+ return;
2868
+ }
2869
+ if (currentMethod === constructorStack.at(-1)) {
2870
+ return;
2871
+ }
2872
+ if (!currentClass.body.body.includes(currentMethod)) {
2873
+ return;
2874
+ }
2875
+ if (!(node.init && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern)) {
2876
+ return;
2877
+ }
2562
2878
  const hasState = node.id.properties.some((prop) => {
2563
2879
  if (prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key)) {
2564
2880
  return eff.O.exists(getName4(prop.key), (name2) => name2 === "state");
2565
2881
  }
2566
2882
  return false;
2567
2883
  });
2568
- if (!hasState) return;
2884
+ if (!hasState) {
2885
+ return;
2886
+ }
2569
2887
  const [def] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2570
2888
  stateDefs.set(currentClass, [def, true]);
2571
2889
  }
@@ -2579,8 +2897,12 @@ var defaultOptions = [{
2579
2897
  }];
2580
2898
  function checkAndReport(node, context, allowExpressions) {
2581
2899
  const initialScope = context.sourceCode.getScope(node);
2582
- if (JSX7__namespace.isKeyedElement(node, initialScope)) return;
2583
- if (JSX7__namespace.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node });
2900
+ if (JSX7__namespace.isKeyedElement(node, initialScope)) {
2901
+ return;
2902
+ }
2903
+ if (JSX7__namespace.isBuiltInElement(node.parent)) {
2904
+ context.report({ messageId: "noUselessFragmentInBuiltIn", node });
2905
+ }
2584
2906
  if (node.children.length === 0) {
2585
2907
  context.report({ messageId: "noUselessFragment", node });
2586
2908
  return;
@@ -2639,7 +2961,9 @@ var no_useless_fragment_default = createRule({
2639
2961
  const { allowExpressions = true } = option;
2640
2962
  return {
2641
2963
  JSXElement(node) {
2642
- if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return;
2964
+ if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
2965
+ return;
2966
+ }
2643
2967
  checkAndReport(node, context, allowExpressions);
2644
2968
  },
2645
2969
  JSXFragment(node) {
@@ -2683,7 +3007,9 @@ var prefer_destructuring_assignment_default = createRule({
2683
3007
  "Program:exit"(node) {
2684
3008
  const components = Array.from(ctx.getAllComponents(node).values());
2685
3009
  function isFunctionComponent(block) {
2686
- if (!AST11__namespace.isFunction(block)) return false;
3010
+ if (!AST11__namespace.isFunction(block)) {
3011
+ return false;
3012
+ }
2687
3013
  return eff.O.exists(
2688
3014
  AST11__namespace.getFunctionIdentifier(block),
2689
3015
  (id) => core.isComponentName(id.name) && components.some((component) => component.node === block)
@@ -2696,9 +3022,13 @@ var prefer_destructuring_assignment_default = createRule({
2696
3022
  scope = scope.upper;
2697
3023
  isComponent = isFunctionComponent(scope.block);
2698
3024
  }
2699
- if (!isComponent) continue;
3025
+ if (!isComponent) {
3026
+ continue;
3027
+ }
2700
3028
  const component = scope.block;
2701
- if (!("params" in component)) continue;
3029
+ if (!("params" in component)) {
3030
+ continue;
3031
+ }
2702
3032
  const [props, ctx2] = component.params;
2703
3033
  const isMatch = tsPattern.isMatching({ name: memberExpression.object.name });
2704
3034
  if (isMatch(props)) {
@@ -2814,9 +3144,13 @@ var prefer_read_only_props_default = createRule({
2814
3144
  const components = ctx.getAllComponents(node);
2815
3145
  for (const [_, component] of components) {
2816
3146
  const [props] = component.node.params;
2817
- if (!props) continue;
3147
+ if (!props) {
3148
+ continue;
3149
+ }
2818
3150
  const propsType = typeUtils.getConstrainedTypeAtLocation(services, props);
2819
- if (typeUtils.isTypeReadonly(services.program, propsType) || isReadonlyType(propsType, services)) continue;
3151
+ if (typeUtils.isTypeReadonly(services.program, propsType) || isReadonlyType(propsType, services)) {
3152
+ continue;
3153
+ }
2820
3154
  context.report({ messageId: "preferReadOnlyProps", node: props });
2821
3155
  }
2822
3156
  }
@@ -2848,7 +3182,9 @@ var prefer_shorthand_boolean_default = createRule({
2848
3182
  const { value } = node;
2849
3183
  const propName = JSX7__namespace.getPropName(node);
2850
3184
  const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
2851
- if (!hasValueTrue) return eff.O.none();
3185
+ if (!hasValueTrue) {
3186
+ return eff.O.none();
3187
+ }
2852
3188
  return eff.O.some({
2853
3189
  messageId: "preferShorthandBoolean",
2854
3190
  node,
@@ -2885,15 +3221,21 @@ var prefer_shorthand_fragment_default = createRule({
2885
3221
  name: RULE_NAME49,
2886
3222
  create(context) {
2887
3223
  function getReportDescriptor(node) {
2888
- if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return eff.O.none();
3224
+ if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3225
+ return eff.O.none();
3226
+ }
2889
3227
  const hasAttributes = node.openingElement.attributes.length > 0;
2890
- if (hasAttributes) return eff.O.none();
3228
+ if (hasAttributes) {
3229
+ return eff.O.none();
3230
+ }
2891
3231
  return eff.O.some({
2892
3232
  messageId: "preferShorthandFragment",
2893
3233
  node,
2894
3234
  fix: (fixer) => {
2895
3235
  const { closingElement, openingElement } = node;
2896
- if (!closingElement) return [];
3236
+ if (!closingElement) {
3237
+ return [];
3238
+ }
2897
3239
  return [
2898
3240
  fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
2899
3241
  fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
@@ -2936,7 +3278,9 @@ var use_jsx_vars_default = createRule({
2936
3278
  }
2937
3279
  return {
2938
3280
  JSXOpeningElement(node) {
2939
- if (node.name.type === types.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) return;
3281
+ if (node.name.type === types.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) {
3282
+ return;
3283
+ }
2940
3284
  for (const name2 of eff.O.toArray(getName5(node.name))) {
2941
3285
  context.sourceCode.markVariableAsUsed(name2, node);
2942
3286
  }