eslint-plugin-react-x 1.23.2 → 1.23.3-beta.5

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 +562 -222
  2. package/dist/index.mjs +565 -225
  3. package/package.json +14 -10
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { F, O, or, isString, not, isNullable } from '@eslint-react/eff';
1
+ import { F, O, isString, not, or, isNullable } from '@eslint-react/eff';
2
2
  import * as JSX7 from '@eslint-react/jsx';
3
3
  import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings } from '@eslint-react/shared';
4
4
  import * as AST11 from '@eslint-react/ast';
5
- import { isForwardRefCall, isThisSetState, isClassComponent, isCreateElementCall, isCloneElementCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isCreateRefCall, isComponentName, useComponentCollector, ERFunctionComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, ERClassComponentFlag, isReactHookCall, isInitializedFromReact } from '@eslint-react/core';
5
+ import { isForwardRefCall, isThisSetState, isClassComponent, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, useComponentCollectorLegacy, isCloneElementCall, isCreateRefCall, isComponentName, useComponentCollector, ERFunctionComponentFlag, isChildrenToArrayCall, ERComponentHint, isDirectValueOfRenderPropertyLoose, isDeclaredInRenderPropLoose, isInsideCreateElementProps, isInsideRenderMethod, ERClassComponentFlag, isReactHookCall, isCreateElementCall, isInitializedFromReact } from '@eslint-react/core';
6
6
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
7
- import { isMatching, P, match } from 'ts-pattern';
7
+ import { isMatching, match, P } from 'ts-pattern';
8
8
  import { compare } from 'compare-versions';
9
9
  import * as VAR from '@eslint-react/var';
10
10
  import { getConstrainedTypeAtLocation, isTypeReadonly } from '@typescript-eslint/type-utils';
@@ -15,7 +15,7 @@ import { getTypeImmutability, isUnknown, isImmutable, isReadonlyShallow, isReado
15
15
 
16
16
  // package.json
17
17
  var name = "eslint-plugin-react-x";
18
- var version = "1.23.2";
18
+ var version = "1.23.3-beta.5";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -105,11 +105,17 @@ var ensure_forward_ref_using_ref_default = createRule({
105
105
  create(context) {
106
106
  return {
107
107
  CallExpression(node) {
108
- if (!isForwardRefCall(node, context)) return;
108
+ if (!isForwardRefCall(node, context)) {
109
+ return;
110
+ }
109
111
  const [component] = node.arguments;
110
- if (!component || !AST11.isFunction(component)) return;
112
+ if (!component || !AST11.isFunction(component)) {
113
+ return;
114
+ }
111
115
  const [_, ref] = component.params;
112
- if (ref) return;
116
+ if (ref) {
117
+ return;
118
+ }
113
119
  context.report({
114
120
  messageId: "ensureForwardRefUsingRef",
115
121
  node: component
@@ -152,17 +158,23 @@ var no_access_state_in_setstate_default = createRule({
152
158
  },
153
159
  name: RULE_NAME4,
154
160
  create(context) {
155
- if (!context.sourceCode.text.includes("setState")) return {};
161
+ if (!context.sourceCode.text.includes("setState")) {
162
+ return {};
163
+ }
156
164
  const classStack = [];
157
165
  const methodStack = [];
158
166
  const setStateStack = [];
159
167
  return {
160
168
  CallExpression(node) {
161
- if (!isThisSetState(node)) return;
169
+ if (!isThisSetState(node)) {
170
+ return;
171
+ }
162
172
  setStateStack.push([node, false]);
163
173
  },
164
174
  "CallExpression:exit"(node) {
165
- if (!isThisSetState(node)) return;
175
+ if (!isThisSetState(node)) {
176
+ return;
177
+ }
166
178
  setStateStack.pop();
167
179
  },
168
180
  ClassDeclaration(node) {
@@ -178,14 +190,24 @@ var no_access_state_in_setstate_default = createRule({
178
190
  classStack.pop();
179
191
  },
180
192
  MemberExpression(node) {
181
- if (!AST11.isThisExpression(node.object)) return;
193
+ if (!AST11.isThisExpression(node.object)) {
194
+ return;
195
+ }
182
196
  const [currClass, isComponent] = classStack.at(-1) ?? [];
183
- if (!currClass || !isComponent) return;
197
+ if (!currClass || !isComponent) {
198
+ return;
199
+ }
184
200
  const [currMethod, isStatic] = methodStack.at(-1) ?? [];
185
- if (!currMethod || isStatic) return;
201
+ if (!currMethod || isStatic) {
202
+ return;
203
+ }
186
204
  const [setState, hasThisState] = setStateStack.at(-1) ?? [];
187
- if (!setState || hasThisState) return;
188
- if (!O.exists(getName(node.property), (name2) => name2 === "state")) return;
205
+ if (!setState || hasThisState) {
206
+ return;
207
+ }
208
+ if (!O.exists(getName(node.property), (name2) => name2 === "state")) {
209
+ return;
210
+ }
189
211
  context.report({ messageId: "noAccessStateInSetstate", node });
190
212
  },
191
213
  MethodDefinition(node) {
@@ -202,19 +224,29 @@ var no_access_state_in_setstate_default = createRule({
202
224
  },
203
225
  VariableDeclarator(node) {
204
226
  const [currClass, isComponent] = classStack.at(-1) ?? [];
205
- if (!currClass || !isComponent) return;
227
+ if (!currClass || !isComponent) {
228
+ return;
229
+ }
206
230
  const [currMethod, isStatic] = methodStack.at(-1) ?? [];
207
- if (!currMethod || isStatic) return;
231
+ if (!currMethod || isStatic) {
232
+ return;
233
+ }
208
234
  const [setState, hasThisState] = setStateStack.at(-1) ?? [];
209
- if (!setState || hasThisState) return;
210
- if (!(node.init && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern)) return;
235
+ if (!setState || hasThisState) {
236
+ return;
237
+ }
238
+ if (!(node.init && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern)) {
239
+ return;
240
+ }
211
241
  const hasState = node.id.properties.some((prop) => {
212
242
  if (prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key)) {
213
243
  return O.exists(getName(prop.key), (name2) => name2 === "state");
214
244
  }
215
245
  return false;
216
246
  });
217
- if (!hasState) return;
247
+ if (!hasState) {
248
+ return;
249
+ }
218
250
  context.report({ messageId: "noAccessStateInSetstate", node });
219
251
  }
220
252
  };
@@ -240,16 +272,6 @@ var iteratorFunctionIndexParamPosition = /* @__PURE__ */ new Map([
240
272
  ["reduceRight", 2],
241
273
  ["some", 1]
242
274
  ]);
243
- var isToStringCall = isMatching({
244
- type: AST_NODE_TYPES.CallExpression,
245
- callee: {
246
- type: AST_NODE_TYPES.MemberExpression,
247
- property: {
248
- type: AST_NODE_TYPES.Identifier,
249
- name: "toString"
250
- }
251
- }
252
- });
253
275
  function isReactChildrenMethod(name2) {
254
276
  return reactChildrenMethod.some((method) => method === name2);
255
277
  }
@@ -259,9 +281,13 @@ function isUsingReactChildren(node, context) {
259
281
  if (!("property" in callee) || !("object" in callee) || !("name" in callee.property)) {
260
282
  return false;
261
283
  }
262
- if (!isReactChildrenMethod(callee.property.name)) return false;
284
+ if (!isReactChildrenMethod(callee.property.name)) {
285
+ return false;
286
+ }
263
287
  const initialScope = context.sourceCode.getScope(node);
264
- if (callee.object.type === AST_NODE_TYPES.Identifier && callee.object.name === "Children") return true;
288
+ if (callee.object.type === AST_NODE_TYPES.Identifier && callee.object.name === "Children") {
289
+ return true;
290
+ }
265
291
  if (callee.object.type === AST_NODE_TYPES.MemberExpression && "name" in callee.object.object) {
266
292
  return isInitializedFromReact(callee.object.object.name, initialScope, settings.importSource);
267
293
  }
@@ -269,19 +295,31 @@ function isUsingReactChildren(node, context) {
269
295
  }
270
296
  function getMapIndexParamName(node, context) {
271
297
  const { callee } = node;
272
- if (callee.type !== AST_NODE_TYPES.MemberExpression) return O.none();
273
- if (callee.property.type !== AST_NODE_TYPES.Identifier) return O.none();
298
+ if (callee.type !== AST_NODE_TYPES.MemberExpression) {
299
+ return O.none();
300
+ }
301
+ if (callee.property.type !== AST_NODE_TYPES.Identifier) {
302
+ return O.none();
303
+ }
274
304
  const { name: name2 } = callee.property;
275
- if (!iteratorFunctionIndexParamPosition.has(name2)) return O.none();
305
+ if (!iteratorFunctionIndexParamPosition.has(name2)) {
306
+ return O.none();
307
+ }
276
308
  const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
277
- if (!callbackArg) return O.none();
309
+ if (!callbackArg) {
310
+ return O.none();
311
+ }
278
312
  if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
279
313
  return O.none();
280
314
  }
281
315
  const { params } = callbackArg;
282
316
  const indexParamPosition = iteratorFunctionIndexParamPosition.get(name2);
283
- if (isNullable(indexParamPosition)) return O.none();
284
- if (params.length < indexParamPosition + 1) return O.none();
317
+ if (isNullable(indexParamPosition)) {
318
+ return O.none();
319
+ }
320
+ if (params.length < indexParamPosition + 1) {
321
+ return O.none();
322
+ }
285
323
  const param = params.at(indexParamPosition);
286
324
  return param && "name" in param ? O.some(param.name) : O.none();
287
325
  }
@@ -300,47 +338,82 @@ var no_array_index_key_default = createRule({
300
338
  name: RULE_NAME5,
301
339
  create(context) {
302
340
  const indexParamNames = [];
303
- const isCreateOrCloneElementCall = or(isCreateElementCall(context), isCloneElementCall(context));
304
341
  function isArrayIndex(node) {
305
342
  return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some(O.exists((name2) => name2 === node.name));
306
343
  }
307
- function getReportDescriptor(node) {
308
- if (isArrayIndex(node)) return [{ messageId: "noArrayIndexKey", node }];
309
- if (AST11.isOneOf([AST_NODE_TYPES.TemplateLiteral, AST_NODE_TYPES.BinaryExpression])(node)) {
310
- const exps = AST_NODE_TYPES.TemplateLiteral === node.type ? node.expressions : AST11.getIdentifiersFromBinaryExpression(node);
311
- return exps.reduce((acc, exp) => {
312
- if (isArrayIndex(exp)) return [...acc, { messageId: "noArrayIndexKey", node: exp }];
313
- return acc;
314
- }, []);
315
- }
316
- if (isToStringCall(node)) {
317
- if (!("object" in node.callee && isArrayIndex(node.callee.object))) return [];
318
- return [{ messageId: "noArrayIndexKey", node: node.callee.object }];
319
- }
320
- const isStringCall = isMatching({
321
- type: AST_NODE_TYPES.CallExpression,
322
- callee: {
323
- type: AST_NODE_TYPES.Identifier,
324
- name: "String"
344
+ function isCreateOrCloneElementCall(node) {
345
+ return isCreateElementCall(node, context) || isCloneElementCall(node, context);
346
+ }
347
+ function getReportDescriptors(node) {
348
+ switch (node.type) {
349
+ // key={bar}
350
+ case AST_NODE_TYPES.Identifier: {
351
+ if (indexParamNames.some(O.exists((name2) => name2 === node.name))) {
352
+ return [{
353
+ messageId: "noArrayIndexKey",
354
+ node
355
+ }];
356
+ }
357
+ return [];
358
+ }
359
+ // key={`foo-${bar}`} or key={'foo' + bar}
360
+ case AST_NODE_TYPES.TemplateLiteral:
361
+ case AST_NODE_TYPES.BinaryExpression: {
362
+ const descriptors = [];
363
+ const expressions = node.type === AST_NODE_TYPES.TemplateLiteral ? node.expressions : AST11.getIdentifiersFromBinaryExpression(node);
364
+ for (const expression of expressions) {
365
+ if (isArrayIndex(expression)) {
366
+ descriptors.push({
367
+ messageId: "noArrayIndexKey",
368
+ node: expression
369
+ });
370
+ }
371
+ }
372
+ return descriptors;
373
+ }
374
+ // key={bar.toString()} or key={String(bar)}
375
+ case AST_NODE_TYPES.CallExpression: {
376
+ switch (true) {
377
+ // key={bar.toString()}
378
+ case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "toString" && isArrayIndex(node.callee.object)): {
379
+ return [{
380
+ messageId: "noArrayIndexKey",
381
+ node: node.callee.object
382
+ }];
383
+ }
384
+ // key={String(bar)}
385
+ case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === "String" && node.arguments[0] && isArrayIndex(node.arguments[0])): {
386
+ return [{
387
+ messageId: "noArrayIndexKey",
388
+ node: node.arguments[0]
389
+ }];
390
+ }
391
+ }
325
392
  }
326
- }, node);
327
- if (isStringCall) {
328
- const [arg] = node.arguments;
329
- if (arg && isArrayIndex(arg)) return [{ messageId: "noArrayIndexKey", node: arg }];
330
393
  }
331
394
  return [];
332
395
  }
333
396
  return {
334
397
  CallExpression(node) {
335
398
  indexParamNames.push(getMapIndexParamName(node, context));
336
- if (node.arguments.length === 0) return;
337
- if (!isCreateOrCloneElementCall(node)) return;
399
+ if (node.arguments.length === 0) {
400
+ return;
401
+ }
402
+ if (!isCreateOrCloneElementCall(node)) {
403
+ return;
404
+ }
338
405
  const [_, props] = node.arguments;
339
- if (props?.type !== AST_NODE_TYPES.ObjectExpression) return;
406
+ if (props?.type !== AST_NODE_TYPES.ObjectExpression) {
407
+ return;
408
+ }
340
409
  for (const prop of props.properties) {
341
- if (!isMatching({ key: { name: "key" } })(prop)) continue;
342
- if (!("value" in prop)) continue;
343
- const descriptors = getReportDescriptor(prop.value);
410
+ if (!isMatching({ key: { name: "key" } })(prop)) {
411
+ continue;
412
+ }
413
+ if (!("value" in prop)) {
414
+ continue;
415
+ }
416
+ const descriptors = getReportDescriptors(prop.value);
344
417
  for (const descriptor of descriptors) {
345
418
  context.report(descriptor);
346
419
  }
@@ -350,11 +423,16 @@ var no_array_index_key_default = createRule({
350
423
  indexParamNames.pop();
351
424
  },
352
425
  JSXAttribute(node) {
353
- if (node.name.name !== "key") return;
354
- if (indexParamNames.length === 0) return;
355
- const { value } = node;
356
- if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
357
- const descriptors = getReportDescriptor(value.expression);
426
+ if (node.name.name !== "key") {
427
+ return;
428
+ }
429
+ if (indexParamNames.length === 0) {
430
+ return;
431
+ }
432
+ if (node.value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
433
+ return;
434
+ }
435
+ const descriptors = getReportDescriptors(node.value.expression);
358
436
  for (const descriptor of descriptors) {
359
437
  context.report(descriptor);
360
438
  }
@@ -551,22 +629,12 @@ var RULE_NAME12 = "no-class-component";
551
629
  var RULE_FEATURES12 = [
552
630
  "CHK"
553
631
  ];
554
- var isComponentDidCatch = isMatching({
555
- key: {
556
- type: AST_NODE_TYPES.Identifier,
557
- name: "componentDidCatch"
558
- },
559
- type: P.union(AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition),
560
- static: false
561
- });
562
- var isGetDerivedStateFromError = isMatching({
563
- key: {
564
- type: AST_NODE_TYPES.Identifier,
565
- name: "getDerivedStateFromError"
566
- },
567
- type: P.union(AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition),
568
- static: true
569
- });
632
+ function isComponentDidCatch(node) {
633
+ return (node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.PropertyDefinition) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
634
+ }
635
+ function isGetDerivedStateFromError(node) {
636
+ return (node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.PropertyDefinition) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
637
+ }
570
638
  var no_class_component_default = createRule({
571
639
  meta: {
572
640
  type: "problem",
@@ -581,14 +649,18 @@ var no_class_component_default = createRule({
581
649
  },
582
650
  name: RULE_NAME12,
583
651
  create(context) {
584
- if (!context.sourceCode.text.includes("Component")) return {};
652
+ if (!context.sourceCode.text.includes("Component")) {
653
+ return {};
654
+ }
585
655
  const { ctx, listeners } = useComponentCollectorLegacy();
586
656
  return {
587
657
  ...listeners,
588
658
  "Program:exit"(node) {
589
659
  const components = ctx.getAllComponents(node);
590
660
  for (const { name: name2, node: component } of components.values()) {
591
- if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) continue;
661
+ if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
662
+ continue;
663
+ }
592
664
  context.report({
593
665
  messageId: "noClassComponent",
594
666
  node: component,
@@ -623,7 +695,9 @@ var no_clone_element_default = createRule({
623
695
  create(context) {
624
696
  return {
625
697
  CallExpression(node) {
626
- if (!isCloneElementCall(node, context)) return;
698
+ if (!isCloneElementCall(node, context)) {
699
+ return;
700
+ }
627
701
  context.report({
628
702
  messageId: "noCloneElement",
629
703
  node
@@ -652,14 +726,22 @@ var no_comment_textnodes_default = createRule({
652
726
  name: RULE_NAME14,
653
727
  create(context) {
654
728
  function hasCommentLike(node) {
655
- if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) return false;
729
+ if (AST11.isOneOf([AST_NODE_TYPES.JSXAttribute, AST_NODE_TYPES.JSXExpressionContainer])(node.parent)) {
730
+ return false;
731
+ }
656
732
  const rawValue = context.sourceCode.getText(node);
657
733
  return /^\s*\/(?:\/|\*)/mu.test(rawValue);
658
734
  }
659
735
  const getReportDescriptor = (node) => {
660
- if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) return O.none();
661
- if (!hasCommentLike(node)) return O.none();
662
- if (!node.parent.type.includes("JSX")) return O.none();
736
+ if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) {
737
+ return O.none();
738
+ }
739
+ if (!hasCommentLike(node)) {
740
+ return O.none();
741
+ }
742
+ if (!node.parent.type.includes("JSX")) {
743
+ return O.none();
744
+ }
663
745
  return O.some({
664
746
  messageId: "noCommentTextnodes",
665
747
  node
@@ -693,11 +775,15 @@ var no_complex_conditional_rendering_default = createRule({
693
775
  create(context) {
694
776
  function getReportDescriptor(node) {
695
777
  const jsxExpContainer = node.parent?.parent;
696
- if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) return O.none();
778
+ if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
779
+ return O.none();
780
+ }
697
781
  if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
698
782
  return O.none();
699
783
  }
700
- if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) return O.none();
784
+ if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
785
+ return O.none();
786
+ }
701
787
  return O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer });
702
788
  }
703
789
  const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
@@ -734,7 +820,9 @@ var no_component_will_mount_default = createRule({
734
820
  },
735
821
  name: RULE_NAME16,
736
822
  create(context) {
737
- if (!context.sourceCode.text.includes("componentWillMount")) return {};
823
+ if (!context.sourceCode.text.includes("componentWillMount")) {
824
+ return {};
825
+ }
738
826
  const { ctx, listeners } = useComponentCollectorLegacy();
739
827
  return {
740
828
  ...listeners,
@@ -748,7 +836,9 @@ var no_component_will_mount_default = createRule({
748
836
  messageId: "noComponentWillMount",
749
837
  node: member,
750
838
  fix(fixer) {
751
- if (!("key" in member)) return null;
839
+ if (!("key" in member)) {
840
+ return null;
841
+ }
752
842
  return fixer.replaceText(member.key, "UNSAFE_componentWillMount");
753
843
  }
754
844
  });
@@ -783,7 +873,9 @@ var no_component_will_receive_props_default = createRule({
783
873
  },
784
874
  name: RULE_NAME17,
785
875
  create(context) {
786
- if (!context.sourceCode.text.includes("componentWillReceiveProps")) return {};
876
+ if (!context.sourceCode.text.includes("componentWillReceiveProps")) {
877
+ return {};
878
+ }
787
879
  const { ctx, listeners } = useComponentCollectorLegacy();
788
880
  return {
789
881
  ...listeners,
@@ -797,7 +889,9 @@ var no_component_will_receive_props_default = createRule({
797
889
  messageId: "noComponentWillReceiveProps",
798
890
  node: member,
799
891
  fix(fixer) {
800
- if (!("key" in member)) return null;
892
+ if (!("key" in member)) {
893
+ return null;
894
+ }
801
895
  return fixer.replaceText(member.key, "UNSAFE_componentWillReceiveProps");
802
896
  }
803
897
  });
@@ -832,7 +926,9 @@ var no_component_will_update_default = createRule({
832
926
  },
833
927
  name: RULE_NAME18,
834
928
  create(context) {
835
- if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
929
+ if (!context.sourceCode.text.includes("componentWillUpdate")) {
930
+ return {};
931
+ }
836
932
  const { ctx, listeners } = useComponentCollectorLegacy();
837
933
  return {
838
934
  ...listeners,
@@ -846,7 +942,9 @@ var no_component_will_update_default = createRule({
846
942
  messageId: "noComponentWillUpdate",
847
943
  node: member,
848
944
  fix(fixer) {
849
- if (!("key" in member)) return null;
945
+ if (!("key" in member)) {
946
+ return null;
947
+ }
850
948
  return fixer.replaceText(member.key, "UNSAFE_componentWillUpdate");
851
949
  }
852
950
  });
@@ -878,13 +976,19 @@ var no_context_provider_default = createRule({
878
976
  },
879
977
  name: RULE_NAME19,
880
978
  create(context) {
881
- if (!context.sourceCode.text.includes(".Provider")) return {};
979
+ if (!context.sourceCode.text.includes(".Provider")) {
980
+ return {};
981
+ }
882
982
  const { version: version2 } = getSettingsFromContext(context);
883
- if (compare(version2, "19.0.0", "<")) return {};
983
+ if (compare(version2, "19.0.0", "<")) {
984
+ return {};
985
+ }
884
986
  return {
885
987
  JSXElement(node) {
886
988
  const elementName = JSX7.getElementName(node.openingElement);
887
- if (!elementName.endsWith(".Provider")) return;
989
+ if (!elementName.endsWith(".Provider")) {
990
+ return;
991
+ }
888
992
  context.report({
889
993
  messageId: "noContextProvider",
890
994
  node,
@@ -892,7 +996,9 @@ var no_context_provider_default = createRule({
892
996
  const providerName = elementName.replace(/\.Provider$/, "");
893
997
  const openingElement = node.openingElement;
894
998
  const closingElement = node.closingElement;
895
- if (!closingElement) return fixer.replaceText(openingElement.name, providerName);
999
+ if (!closingElement) {
1000
+ return fixer.replaceText(openingElement.name, providerName);
1001
+ }
896
1002
  return [
897
1003
  fixer.replaceText(openingElement.name, providerName),
898
1004
  fixer.replaceText(closingElement.name, providerName)
@@ -924,8 +1030,12 @@ var no_create_ref_default = createRule({
924
1030
  create(context) {
925
1031
  return {
926
1032
  CallExpression(node) {
927
- if (!isCreateRefCall(node, context)) return;
928
- if (O.isSome(AST11.findParentNode(node, isClassComponent))) return;
1033
+ if (!isCreateRefCall(node, context)) {
1034
+ return;
1035
+ }
1036
+ if (O.isSome(AST11.findParentNode(node, isClassComponent))) {
1037
+ return;
1038
+ }
929
1039
  context.report({ messageId: "noCreateRef", node });
930
1040
  }
931
1041
  };
@@ -950,25 +1060,41 @@ var no_default_props_default = createRule({
950
1060
  },
951
1061
  name: RULE_NAME21,
952
1062
  create(context) {
953
- if (!context.sourceCode.text.includes("defaultProps")) return {};
1063
+ if (!context.sourceCode.text.includes("defaultProps")) {
1064
+ return {};
1065
+ }
954
1066
  return {
955
1067
  AssignmentExpression(node) {
956
- if (node.operator !== "=" || node.left.type !== AST_NODE_TYPES.MemberExpression) return;
1068
+ if (node.operator !== "=" || node.left.type !== AST_NODE_TYPES.MemberExpression) {
1069
+ return;
1070
+ }
957
1071
  const { object, property } = node.left;
958
- if (object.type !== AST_NODE_TYPES.Identifier) return;
959
- if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "defaultProps") return;
960
- if (!isComponentName(object.name)) return;
1072
+ if (object.type !== AST_NODE_TYPES.Identifier) {
1073
+ return;
1074
+ }
1075
+ if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "defaultProps") {
1076
+ return;
1077
+ }
1078
+ if (!isComponentName(object.name)) {
1079
+ return;
1080
+ }
961
1081
  const isComponent = F.pipe(
962
1082
  VAR.findVariable(object.name, context.sourceCode.getScope(node)),
963
1083
  O.flatMap(VAR.getVariableNode(0)),
964
1084
  O.exists((n) => AST11.isFunction(n) || isClassComponent(n))
965
1085
  );
966
- if (!isComponent) return;
1086
+ if (!isComponent) {
1087
+ return;
1088
+ }
967
1089
  context.report({ messageId: "noDefaultProps", node: property });
968
1090
  },
969
1091
  PropertyDefinition(node) {
970
- if (!isClassComponent(node.parent.parent)) return;
971
- if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") return;
1092
+ if (!isClassComponent(node.parent.parent)) {
1093
+ return;
1094
+ }
1095
+ if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "defaultProps") {
1096
+ return;
1097
+ }
972
1098
  context.report({ messageId: "noDefaultProps", node });
973
1099
  }
974
1100
  };
@@ -1016,7 +1142,9 @@ var no_direct_mutation_state_default = createRule({
1016
1142
  name: RULE_NAME22,
1017
1143
  create(context) {
1018
1144
  function getReportDescriptor(node) {
1019
- if (!isAssignmentToThisState(node)) return O.none();
1145
+ if (!isAssignmentToThisState(node)) {
1146
+ return O.none();
1147
+ }
1020
1148
  return F.pipe(
1021
1149
  O.Do,
1022
1150
  O.bind("parentClass", () => AST11.findParentNodeGuard(
@@ -1064,9 +1192,13 @@ var no_duplicate_jsx_props_default = createRule({
1064
1192
  JSXOpeningElement(node) {
1065
1193
  const props = [];
1066
1194
  for (const attr of node.attributes) {
1067
- if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) continue;
1195
+ if (attr.type === AST_NODE_TYPES.JSXSpreadAttribute) {
1196
+ continue;
1197
+ }
1068
1198
  const name2 = attr.name.name;
1069
- if (!isString(name2)) continue;
1199
+ if (!isString(name2)) {
1200
+ continue;
1201
+ }
1070
1202
  if (!props.includes(name2)) {
1071
1203
  props.push(name2);
1072
1204
  continue;
@@ -1099,12 +1231,16 @@ var no_duplicate_key_default = createRule({
1099
1231
  },
1100
1232
  name: RULE_NAME24,
1101
1233
  create(context) {
1102
- if (!context.sourceCode.getText().includes("key=")) return {};
1234
+ if (!context.sourceCode.getText().includes("key=")) {
1235
+ return {};
1236
+ }
1103
1237
  const keyedEntries = /* @__PURE__ */ new Map();
1104
1238
  function isKeyValueEqual(a, b) {
1105
1239
  const aValue = a.value;
1106
1240
  const bValue = b.value;
1107
- if (aValue === null || bValue === null) return false;
1241
+ if (aValue === null || bValue === null) {
1242
+ return false;
1243
+ }
1108
1244
  return AST11.isNodeEqual(aValue, bValue);
1109
1245
  }
1110
1246
  return {
@@ -1130,9 +1266,13 @@ var no_duplicate_key_default = createRule({
1130
1266
  O.bind("iter", ({ call: call2 }) => AST11.findParentNodeStop(jsxElement, call2, AST11.isFunction)),
1131
1267
  O.bind("arg0", ({ call: call2 }) => O.fromNullable(call2.arguments[0]))
1132
1268
  );
1133
- if (O.isNone(mbEntry)) return;
1269
+ if (O.isNone(mbEntry)) {
1270
+ return;
1271
+ }
1134
1272
  const { arg0, call, iter } = mbEntry.value;
1135
- if (AST11.unwrapTypeExpression(arg0) !== iter) return;
1273
+ if (AST11.unwrapTypeExpression(arg0) !== iter) {
1274
+ return;
1275
+ }
1136
1276
  keyedEntries.set(call, {
1137
1277
  hasDuplicate: node.value?.type === AST_NODE_TYPES.Literal,
1138
1278
  keys: [node],
@@ -1143,7 +1283,9 @@ var no_duplicate_key_default = createRule({
1143
1283
  },
1144
1284
  "Program:exit"() {
1145
1285
  for (const { hasDuplicate, keys } of keyedEntries.values()) {
1146
- if (!hasDuplicate) continue;
1286
+ if (!hasDuplicate) {
1287
+ continue;
1288
+ }
1147
1289
  for (const key of keys) {
1148
1290
  context.report({
1149
1291
  messageId: "noDuplicateKey",
@@ -1179,12 +1321,18 @@ var no_forward_ref_default = createRule({
1179
1321
  },
1180
1322
  name: RULE_NAME25,
1181
1323
  create(context) {
1182
- if (!context.sourceCode.text.includes("forwardRef")) return {};
1324
+ if (!context.sourceCode.text.includes("forwardRef")) {
1325
+ return {};
1326
+ }
1183
1327
  const { version: version2 } = getSettingsFromContext(context);
1184
- if (compare(version2, "19.0.0", "<")) return {};
1328
+ if (compare(version2, "19.0.0", "<")) {
1329
+ return {};
1330
+ }
1185
1331
  return {
1186
1332
  CallExpression(node) {
1187
- if (!isForwardRefCall(node, context)) return;
1333
+ if (!isForwardRefCall(node, context)) {
1334
+ return;
1335
+ }
1188
1336
  context.report({
1189
1337
  messageId: "noForwardRef",
1190
1338
  node,
@@ -1198,7 +1346,9 @@ var no_forward_ref_default = createRule({
1198
1346
  function getFix(node, context) {
1199
1347
  return (fixer) => {
1200
1348
  const [componentNode] = node.arguments;
1201
- if (!componentNode || !AST11.isFunction(componentNode)) return [];
1349
+ if (!componentNode || !AST11.isFunction(componentNode)) {
1350
+ return [];
1351
+ }
1202
1352
  return [
1203
1353
  // unwrap component from forwardRef call
1204
1354
  fixer.removeRange([node.range[0], componentNode.range[0]]),
@@ -1217,10 +1367,14 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
1217
1367
  const getText = (node2) => context.sourceCode.getText(node2);
1218
1368
  const [arg0, arg1] = node.params;
1219
1369
  const [typeArg0, typeArg1] = typeArguments;
1220
- if (!arg0) return [];
1370
+ if (!arg0) {
1371
+ return [];
1372
+ }
1221
1373
  const fixedArg0Text = match(arg0).with({ type: AST_NODE_TYPES.Identifier }, (n) => O.some(`...${n.name}`)).with({ type: AST_NODE_TYPES.ObjectPattern }, (n) => O.some(n.properties.map(getText).join(", "))).otherwise(O.none);
1222
1374
  const fixedArg1Text = match(arg1).with(P.nullish, () => O.some("ref")).with({ type: AST_NODE_TYPES.Identifier, name: "ref" }, () => O.some("ref")).with({ type: AST_NODE_TYPES.Identifier, name: P.not("ref") }, (n) => O.some(`ref: ${n.name}`)).otherwise(O.none);
1223
- if (O.isNone(fixedArg0Text) || O.isNone(fixedArg1Text)) return [];
1375
+ if (O.isNone(fixedArg0Text) || O.isNone(fixedArg1Text)) {
1376
+ return [];
1377
+ }
1224
1378
  const fixedPropsText = fixedArg0Text.value;
1225
1379
  const fixedRefText = fixedArg1Text.value;
1226
1380
  if (!typeArg0 || !typeArg1) {
@@ -1400,7 +1554,9 @@ var no_leaked_conditional_rendering_default = createRule({
1400
1554
  },
1401
1555
  name: RULE_NAME27,
1402
1556
  create(context) {
1403
- if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) return {};
1557
+ if (!context.sourceCode.text.includes("&&") && !context.sourceCode.text.includes("?")) {
1558
+ return {};
1559
+ }
1404
1560
  const { version: version2 } = getSettingsFromContext(context);
1405
1561
  const allowedVariants = [
1406
1562
  "any",
@@ -1418,7 +1574,9 @@ var no_leaked_conditional_rendering_default = createRule({
1418
1574
  function getReportDescriptor(node) {
1419
1575
  return match(node).when(AST11.isJSX, O.none).with({ type: AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1420
1576
  const isLeftUnaryNot = isMatching({ type: AST_NODE_TYPES.UnaryExpression, operator: "!" }, left);
1421
- if (isLeftUnaryNot) return getReportDescriptor(right);
1577
+ if (isLeftUnaryNot) {
1578
+ return getReportDescriptor(right);
1579
+ }
1422
1580
  const initialScope = context.sourceCode.getScope(left);
1423
1581
  const isLeftNan = isMatching({ type: AST_NODE_TYPES.Identifier, name: "NaN" }, left) || O.exists(VAR.getStaticValue(left, initialScope), (v) => v === "NaN");
1424
1582
  if (isLeftNan) {
@@ -1431,7 +1589,9 @@ var no_leaked_conditional_rendering_default = createRule({
1431
1589
  const leftType = getConstrainedTypeAtLocation(services, left);
1432
1590
  const leftTypeVariants = inspectVariantTypes(unionTypeParts(leftType));
1433
1591
  const isLeftValid = Array.from(leftTypeVariants.values()).every((type) => allowedVariants.some((allowed) => allowed === type));
1434
- if (isLeftValid) return getReportDescriptor(right);
1592
+ if (isLeftValid) {
1593
+ return getReportDescriptor(right);
1594
+ }
1435
1595
  return O.some({
1436
1596
  messageId: "noLeakedConditionalRendering",
1437
1597
  node: left,
@@ -1473,7 +1633,9 @@ var no_missing_component_display_name_default = createRule({
1473
1633
  },
1474
1634
  name: RULE_NAME28,
1475
1635
  create(context) {
1476
- if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) return {};
1636
+ if (!context.sourceCode.text.includes("memo") && !context.sourceCode.text.includes("forwardRef")) {
1637
+ return {};
1638
+ }
1477
1639
  const { ctx, listeners } = useComponentCollector(context);
1478
1640
  return {
1479
1641
  ...listeners,
@@ -1481,8 +1643,12 @@ var no_missing_component_display_name_default = createRule({
1481
1643
  const components = ctx.getAllComponents(node);
1482
1644
  for (const { node: node2, displayName, flag } of components.values()) {
1483
1645
  const isMemoOrForwardRef = Boolean(flag & ERFunctionComponentFlag.ForwardRef) || Boolean(flag & ERFunctionComponentFlag.Memo);
1484
- if (O.isSome(AST11.getFunctionIdentifier(node2))) continue;
1485
- if (!isMemoOrForwardRef) continue;
1646
+ if (O.isSome(AST11.getFunctionIdentifier(node2))) {
1647
+ continue;
1648
+ }
1649
+ if (!isMemoOrForwardRef) {
1650
+ continue;
1651
+ }
1486
1652
  if (O.isNone(displayName)) {
1487
1653
  context.report({
1488
1654
  messageId: "noMissingComponentDisplayName",
@@ -1540,13 +1706,17 @@ var no_missing_key_default = createRule({
1540
1706
  function checkExpression(node) {
1541
1707
  switch (node.type) {
1542
1708
  case AST_NODE_TYPES.ConditionalExpression:
1543
- if (!("consequent" in node)) return O.none();
1709
+ if (!("consequent" in node)) {
1710
+ return O.none();
1711
+ }
1544
1712
  return O.orElse(checkIteratorElement(node.consequent), () => checkIteratorElement(node.alternate));
1545
1713
  case AST_NODE_TYPES.JSXElement:
1546
1714
  case AST_NODE_TYPES.JSXFragment:
1547
1715
  return checkIteratorElement(node);
1548
1716
  case AST_NODE_TYPES.LogicalExpression:
1549
- if (!("left" in node)) return O.none();
1717
+ if (!("left" in node)) {
1718
+ return O.none();
1719
+ }
1550
1720
  return O.orElse(checkIteratorElement(node.left), () => checkIteratorElement(node.right));
1551
1721
  default:
1552
1722
  return O.none();
@@ -1554,16 +1724,22 @@ var no_missing_key_default = createRule({
1554
1724
  }
1555
1725
  function checkBlockStatement(node) {
1556
1726
  return AST11.getNestedReturnStatements(node).reduce((acc, statement) => {
1557
- if (!statement.argument) return acc;
1727
+ if (!statement.argument) {
1728
+ return acc;
1729
+ }
1558
1730
  const mbDescriptor = checkIteratorElement(statement.argument);
1559
1731
  return O.isNone(mbDescriptor) ? acc : [...acc, mbDescriptor.value];
1560
1732
  }, []);
1561
1733
  }
1562
1734
  return {
1563
1735
  ArrayExpression(node) {
1564
- if (state.isWithinChildrenToArray) return;
1736
+ if (state.isWithinChildrenToArray) {
1737
+ return;
1738
+ }
1565
1739
  const elements = node.elements.filter(AST11.is(AST_NODE_TYPES.JSXElement));
1566
- if (elements.length === 0) return;
1740
+ if (elements.length === 0) {
1741
+ return;
1742
+ }
1567
1743
  const initialScope = context.sourceCode.getScope(node);
1568
1744
  for (const element of elements) {
1569
1745
  if (!JSX7.hasProp(element.openingElement.attributes, "key", initialScope)) {
@@ -1576,7 +1752,9 @@ var no_missing_key_default = createRule({
1576
1752
  },
1577
1753
  CallExpression(node) {
1578
1754
  state.isWithinChildrenToArray ||= isChildrenToArrayCall(node, context);
1579
- if (state.isWithinChildrenToArray) return;
1755
+ if (state.isWithinChildrenToArray) {
1756
+ return;
1757
+ }
1580
1758
  const isMapCall = AST11.isMapCallLoose(node);
1581
1759
  const isArrayFromCall = isMatching({
1582
1760
  type: AST_NODE_TYPES.CallExpression,
@@ -1587,9 +1765,13 @@ var no_missing_key_default = createRule({
1587
1765
  }
1588
1766
  }
1589
1767
  }, node);
1590
- if (!isMapCall && !isArrayFromCall) return;
1768
+ if (!isMapCall && !isArrayFromCall) {
1769
+ return;
1770
+ }
1591
1771
  const fn = node.arguments[isMapCall ? 0 : 1];
1592
- if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(fn)) return;
1772
+ if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(fn)) {
1773
+ return;
1774
+ }
1593
1775
  if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
1594
1776
  for (const descriptor of checkBlockStatement(fn.body)) {
1595
1777
  context.report(descriptor);
@@ -1599,11 +1781,15 @@ var no_missing_key_default = createRule({
1599
1781
  O.map(checkExpression(fn.body), context.report);
1600
1782
  },
1601
1783
  "CallExpression:exit"(node) {
1602
- if (!isChildrenToArrayCall(node, context)) return;
1784
+ if (!isChildrenToArrayCall(node, context)) {
1785
+ return;
1786
+ }
1603
1787
  state.isWithinChildrenToArray = false;
1604
1788
  },
1605
1789
  JSXFragment(node) {
1606
- if (state.isWithinChildrenToArray) return;
1790
+ if (state.isWithinChildrenToArray) {
1791
+ return;
1792
+ }
1607
1793
  if (node.parent.type === AST_NODE_TYPES.ArrayExpression) {
1608
1794
  context.report({
1609
1795
  messageId: "noMissingKeyWithFragment",
@@ -1634,7 +1820,7 @@ var no_nested_components_default = createRule({
1634
1820
  },
1635
1821
  name: RULE_NAME30,
1636
1822
  create(context) {
1637
- const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefinedLiteral | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
1823
+ const hint = ERComponentHint.SkipMapCallback | ERComponentHint.SkipNullLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipNumberLiteral | ERComponentHint.StrictLogical | ERComponentHint.StrictConditional;
1638
1824
  const collector = useComponentCollector(context, hint);
1639
1825
  const collectorLegacy = useComponentCollectorLegacy();
1640
1826
  return {
@@ -1650,8 +1836,12 @@ var no_nested_components_default = createRule({
1650
1836
  return AST11.isClass(node2) && classComponents.some((component) => component.node === node2);
1651
1837
  };
1652
1838
  for (const { name: componentName, node: component } of functionComponents) {
1653
- if (isDirectValueOfRenderPropertyLoose(component)) continue;
1654
- if (O.isNone(componentName)) continue;
1839
+ if (isDirectValueOfRenderPropertyLoose(component)) {
1840
+ continue;
1841
+ }
1842
+ if (O.isNone(componentName)) {
1843
+ continue;
1844
+ }
1655
1845
  const name2 = componentName.value;
1656
1846
  const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
1657
1847
  const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || O.isSome(JSX7.findParentProp(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer));
@@ -1739,25 +1929,41 @@ var no_prop_types_default = createRule({
1739
1929
  },
1740
1930
  name: RULE_NAME31,
1741
1931
  create(context) {
1742
- if (!context.sourceCode.text.includes("propTypes")) return {};
1932
+ if (!context.sourceCode.text.includes("propTypes")) {
1933
+ return {};
1934
+ }
1743
1935
  return {
1744
1936
  AssignmentExpression(node) {
1745
- if (node.operator !== "=" || node.left.type !== AST_NODE_TYPES.MemberExpression) return;
1937
+ if (node.operator !== "=" || node.left.type !== AST_NODE_TYPES.MemberExpression) {
1938
+ return;
1939
+ }
1746
1940
  const { object, property } = node.left;
1747
- if (object.type !== AST_NODE_TYPES.Identifier) return;
1748
- if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "propTypes") return;
1749
- if (!isComponentName(object.name)) return;
1941
+ if (object.type !== AST_NODE_TYPES.Identifier) {
1942
+ return;
1943
+ }
1944
+ if (property.type !== AST_NODE_TYPES.Identifier || property.name !== "propTypes") {
1945
+ return;
1946
+ }
1947
+ if (!isComponentName(object.name)) {
1948
+ return;
1949
+ }
1750
1950
  const isComponent = F.pipe(
1751
1951
  VAR.findVariable(object.name, context.sourceCode.getScope(node)),
1752
1952
  O.flatMap(VAR.getVariableNode(0)),
1753
1953
  O.exists((n) => AST11.isFunction(n) || isClassComponent(n))
1754
1954
  );
1755
- if (!isComponent) return;
1955
+ if (!isComponent) {
1956
+ return;
1957
+ }
1756
1958
  context.report({ messageId: "noPropTypes", node: property });
1757
1959
  },
1758
1960
  PropertyDefinition(node) {
1759
- if (!isClassComponent(node.parent.parent)) return;
1760
- if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") return;
1961
+ if (!isClassComponent(node.parent.parent)) {
1962
+ return;
1963
+ }
1964
+ if (!node.static || node.key.type !== AST_NODE_TYPES.Identifier || node.key.name !== "propTypes") {
1965
+ return;
1966
+ }
1761
1967
  context.report({ messageId: "noPropTypes", node });
1762
1968
  }
1763
1969
  };
@@ -1785,14 +1991,18 @@ var no_redundant_should_component_update_default = createRule({
1785
1991
  },
1786
1992
  name: RULE_NAME32,
1787
1993
  create(context) {
1788
- if (!context.sourceCode.text.includes("shouldComponentUpdate")) return {};
1994
+ if (!context.sourceCode.text.includes("shouldComponentUpdate")) {
1995
+ return {};
1996
+ }
1789
1997
  const { ctx, listeners } = useComponentCollectorLegacy();
1790
1998
  return {
1791
1999
  ...listeners,
1792
2000
  "Program:exit"(node) {
1793
2001
  const components = ctx.getAllComponents(node);
1794
2002
  for (const { name: name2, node: component, flag } of components.values()) {
1795
- if (!(flag & ERClassComponentFlag.PureComponent)) continue;
2003
+ if (!(flag & ERClassComponentFlag.PureComponent)) {
2004
+ continue;
2005
+ }
1796
2006
  const { body } = component.body;
1797
2007
  for (const member of body) {
1798
2008
  if (isShouldComponentUpdate(member)) {
@@ -1832,9 +2042,13 @@ var no_set_state_in_component_did_mount_default = createRule({
1832
2042
  },
1833
2043
  name: RULE_NAME33,
1834
2044
  create(context) {
1835
- if (!context.sourceCode.text.includes("componentDidMount")) return {};
2045
+ if (!context.sourceCode.text.includes("componentDidMount")) {
2046
+ return {};
2047
+ }
1836
2048
  function getReportDescriptor(node) {
1837
- if (!isThisSetState(node)) return O.none();
2049
+ if (!isThisSetState(node)) {
2050
+ return O.none();
2051
+ }
1838
2052
  return F.pipe(
1839
2053
  O.Do,
1840
2054
  O.bind("clazz", () => AST11.findParentNodeGuard(node, isClassComponent)),
@@ -1882,9 +2096,13 @@ var no_set_state_in_component_did_update_default = createRule({
1882
2096
  },
1883
2097
  name: RULE_NAME34,
1884
2098
  create(context) {
1885
- if (!context.sourceCode.text.includes("componentDidUpdate")) return {};
2099
+ if (!context.sourceCode.text.includes("componentDidUpdate")) {
2100
+ return {};
2101
+ }
1886
2102
  function getReportDescriptor(node) {
1887
- if (!isThisSetState(node)) return O.none();
2103
+ if (!isThisSetState(node)) {
2104
+ return O.none();
2105
+ }
1888
2106
  return F.pipe(
1889
2107
  O.Do,
1890
2108
  O.bind("clazz", () => AST11.findParentNodeGuard(node, isClassComponent)),
@@ -1932,9 +2150,13 @@ var no_set_state_in_component_will_update_default = createRule({
1932
2150
  },
1933
2151
  name: RULE_NAME35,
1934
2152
  create(context) {
1935
- if (!context.sourceCode.text.includes("componentWillUpdate")) return {};
2153
+ if (!context.sourceCode.text.includes("componentWillUpdate")) {
2154
+ return {};
2155
+ }
1936
2156
  function getReportDescriptor(node) {
1937
- if (!isThisSetState(node)) return O.none();
2157
+ if (!isThisSetState(node)) {
2158
+ return O.none();
2159
+ }
1938
2160
  return F.pipe(
1939
2161
  O.Do,
1940
2162
  O.bind("clazz", () => AST11.findParentNodeGuard(node, isClassComponent)),
@@ -1969,8 +2191,12 @@ function containsStringLiteral({ value }) {
1969
2191
  return value?.type === AST_NODE_TYPES.Literal && isString(value.value);
1970
2192
  }
1971
2193
  function containsStringExpressionContainer({ value }) {
1972
- if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return false;
1973
- if (value.expression.type === AST_NODE_TYPES.Literal) return isString(value.expression.value);
2194
+ if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
2195
+ return false;
2196
+ }
2197
+ if (value.expression.type === AST_NODE_TYPES.Literal) {
2198
+ return isString(value.expression.value);
2199
+ }
1974
2200
  return value.expression.type === AST_NODE_TYPES.TemplateLiteral;
1975
2201
  }
1976
2202
  var no_string_refs_default = createRule({
@@ -1989,7 +2215,9 @@ var no_string_refs_default = createRule({
1989
2215
  create(context) {
1990
2216
  return {
1991
2217
  JSXAttribute(node) {
1992
- if (node.name.name !== "ref") return;
2218
+ if (node.name.name !== "ref") {
2219
+ return;
2220
+ }
1993
2221
  if (containsStringLiteral(node) || containsStringExpressionContainer(node)) {
1994
2222
  context.report({
1995
2223
  messageId: "noStringRefs",
@@ -2022,7 +2250,9 @@ var no_unsafe_component_will_mount_default = createRule({
2022
2250
  },
2023
2251
  name: RULE_NAME37,
2024
2252
  create(context) {
2025
- if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) return {};
2253
+ if (!context.sourceCode.text.includes("UNSAFE_componentWillMount")) {
2254
+ return {};
2255
+ }
2026
2256
  const { ctx, listeners } = useComponentCollectorLegacy();
2027
2257
  return {
2028
2258
  ...listeners,
@@ -2065,7 +2295,9 @@ var no_unsafe_component_will_receive_props_default = createRule({
2065
2295
  },
2066
2296
  name: RULE_NAME38,
2067
2297
  create(context) {
2068
- if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) return {};
2298
+ if (!context.sourceCode.text.includes("UNSAFE_componentWillReceiveProps")) {
2299
+ return {};
2300
+ }
2069
2301
  const { ctx, listeners } = useComponentCollectorLegacy();
2070
2302
  return {
2071
2303
  ...listeners,
@@ -2108,7 +2340,9 @@ var no_unsafe_component_will_update_default = createRule({
2108
2340
  },
2109
2341
  name: RULE_NAME39,
2110
2342
  create(context) {
2111
- if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) return {};
2343
+ if (!context.sourceCode.text.includes("UNSAFE_componentWillUpdate")) {
2344
+ return {};
2345
+ }
2112
2346
  const { ctx, listeners } = useComponentCollectorLegacy();
2113
2347
  return {
2114
2348
  ...listeners,
@@ -2156,8 +2390,12 @@ var no_unstable_context_value_default = createRule({
2156
2390
  ...listeners,
2157
2391
  JSXOpeningElement(node) {
2158
2392
  const openingElementName = node.name;
2159
- if (openingElementName.type !== AST_NODE_TYPES.JSXMemberExpression) return;
2160
- if (openingElementName.property.name !== "Provider") return;
2393
+ if (openingElementName.type !== AST_NODE_TYPES.JSXMemberExpression) {
2394
+ return;
2395
+ }
2396
+ if (openingElementName.property.name !== "Provider") {
2397
+ return;
2398
+ }
2161
2399
  F.pipe(
2162
2400
  O.Do,
2163
2401
  O.bind("function", ctx.getCurrentFunction),
@@ -2173,8 +2411,12 @@ var no_unstable_context_value_default = createRule({
2173
2411
  return O.some(VAR.getValueConstruction(valueExpression, initialScope));
2174
2412
  }),
2175
2413
  O.map((vc) => {
2176
- if (vc.construction.kind === "None") return;
2177
- if (isReactHookCall(vc.construction.node)) return;
2414
+ if (vc.construction.kind === "None") {
2415
+ return;
2416
+ }
2417
+ if (isReactHookCall(vc.construction.node)) {
2418
+ return;
2419
+ }
2178
2420
  const prevs = constructions.get(vc.function.node) ?? [];
2179
2421
  constructions.set(vc.function.node, [...prevs, vc.construction]);
2180
2422
  })
@@ -2184,7 +2426,9 @@ var no_unstable_context_value_default = createRule({
2184
2426
  const components = ctx.getAllComponents(node).values();
2185
2427
  for (const { node: component } of components) {
2186
2428
  for (const construction of constructions.get(component) ?? []) {
2187
- if (construction.kind === "None") continue;
2429
+ if (construction.kind === "None") {
2430
+ continue;
2431
+ }
2188
2432
  const { kind, node: constructionNode } = construction;
2189
2433
  const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
2190
2434
  context.report({
@@ -2228,12 +2472,16 @@ var no_unstable_default_props_default = createRule({
2228
2472
  for (const { node: component } of components.values()) {
2229
2473
  const { params } = component;
2230
2474
  const [props] = params;
2231
- if (!props) continue;
2475
+ if (!props) {
2476
+ continue;
2477
+ }
2232
2478
  const properties = match(props).with({ type: AST_NODE_TYPES.ObjectPattern }, ({ properties: properties2 }) => properties2).with({ type: AST_NODE_TYPES.Identifier }, ({ name: name2 }) => {
2233
2479
  return declarators.get(component)?.filter((d) => d.init.name === name2).flatMap((d) => d.id.properties) ?? [];
2234
2480
  }).otherwise(() => []);
2235
2481
  for (const prop of properties) {
2236
- if (prop.type !== AST_NODE_TYPES.Property || prop.value.type !== AST_NODE_TYPES.AssignmentPattern) continue;
2482
+ if (prop.type !== AST_NODE_TYPES.Property || prop.value.type !== AST_NODE_TYPES.AssignmentPattern) {
2483
+ continue;
2484
+ }
2237
2485
  const { value } = prop;
2238
2486
  const { right } = value;
2239
2487
  const initialScope = context.sourceCode.getScope(value);
@@ -2242,8 +2490,12 @@ var no_unstable_default_props_default = createRule({
2242
2490
  initialScope,
2243
2491
  VAR.ValueConstructionHint.StrictCallExpression
2244
2492
  );
2245
- if (construction.kind === "None") continue;
2246
- if (isReactHookCall(construction.node)) continue;
2493
+ if (construction.kind === "None") {
2494
+ continue;
2495
+ }
2496
+ if (isReactHookCall(construction.node)) {
2497
+ continue;
2498
+ }
2247
2499
  const forbiddenType = AST11.toReadableNodeType(right);
2248
2500
  context.report({
2249
2501
  messageId: "noUnstableDefaultProps",
@@ -2257,7 +2509,9 @@ var no_unstable_default_props_default = createRule({
2257
2509
  },
2258
2510
  "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node) {
2259
2511
  const mbEntry = ctx.getCurrentFunction();
2260
- if (O.isNone(mbEntry)) return;
2512
+ if (O.isNone(mbEntry)) {
2513
+ return;
2514
+ }
2261
2515
  const entry = mbEntry.value;
2262
2516
  const prevs = declarators.get(entry.node) ?? [];
2263
2517
  declarators.set(entry.node, [...prevs, node]);
@@ -2322,21 +2576,31 @@ var no_unused_class_component_members_default = createRule({
2322
2576
  const propertyUsages = /* @__PURE__ */ new WeakMap();
2323
2577
  function classEnter(node) {
2324
2578
  classStack.push(node);
2325
- if (!isClassComponent(node)) return;
2579
+ if (!isClassComponent(node)) {
2580
+ return;
2581
+ }
2326
2582
  propertyDefs.set(node, /* @__PURE__ */ new Set());
2327
2583
  propertyUsages.set(node, /* @__PURE__ */ new Set());
2328
2584
  }
2329
2585
  function classExit() {
2330
2586
  const currentClass = classStack.pop();
2331
- if (!currentClass || !isClassComponent(currentClass)) return;
2587
+ if (!currentClass || !isClassComponent(currentClass)) {
2588
+ return;
2589
+ }
2332
2590
  const className = O.map(AST11.getClassIdentifier(currentClass), (id) => id.name);
2333
2591
  const defs = propertyDefs.get(currentClass);
2334
2592
  const usages = propertyUsages.get(currentClass);
2335
- if (!defs) return;
2593
+ if (!defs) {
2594
+ return;
2595
+ }
2336
2596
  for (const def of defs) {
2337
2597
  const name2 = getName3(def);
2338
- if (O.isNone(name2)) continue;
2339
- if (usages?.has(name2.value) || LIFECYCLE_METHODS.has(name2.value)) continue;
2598
+ if (O.isNone(name2)) {
2599
+ continue;
2600
+ }
2601
+ if (usages?.has(name2.value) || LIFECYCLE_METHODS.has(name2.value)) {
2602
+ continue;
2603
+ }
2340
2604
  context.report({
2341
2605
  messageId: "noUnusedClassComponentMembers",
2342
2606
  node: def,
@@ -2350,8 +2614,12 @@ var no_unused_class_component_members_default = createRule({
2350
2614
  function methodEnter(node) {
2351
2615
  methodStack.push(node);
2352
2616
  const currentClass = classStack.at(-1);
2353
- if (!currentClass || !isClassComponent(currentClass)) return;
2354
- if (node.static) return;
2617
+ if (!currentClass || !isClassComponent(currentClass)) {
2618
+ return;
2619
+ }
2620
+ if (node.static) {
2621
+ return;
2622
+ }
2355
2623
  if (AST11.isKeyLiteralLike(node, node.key)) {
2356
2624
  propertyDefs.get(currentClass)?.add(node.key);
2357
2625
  }
@@ -2367,9 +2635,15 @@ var no_unused_class_component_members_default = createRule({
2367
2635
  MemberExpression(node) {
2368
2636
  const currentClass = classStack.at(-1);
2369
2637
  const currentMethod = methodStack.at(-1);
2370
- if (!currentClass || !currentMethod) return;
2371
- if (!isClassComponent(currentClass) || currentMethod.static) return;
2372
- if (!AST11.isThisExpression(node.object) || !AST11.isKeyLiteralLike(node, node.property)) return;
2638
+ if (!currentClass || !currentMethod) {
2639
+ return;
2640
+ }
2641
+ if (!isClassComponent(currentClass) || currentMethod.static) {
2642
+ return;
2643
+ }
2644
+ if (!AST11.isThisExpression(node.object) || !AST11.isKeyLiteralLike(node, node.property)) {
2645
+ return;
2646
+ }
2373
2647
  if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
2374
2648
  propertyDefs.get(currentClass)?.add(node.property);
2375
2649
  return;
@@ -2383,8 +2657,12 @@ var no_unused_class_component_members_default = createRule({
2383
2657
  VariableDeclarator(node) {
2384
2658
  const currentClass = classStack.at(-1);
2385
2659
  const currentMethod = methodStack.at(-1);
2386
- if (!currentClass || !currentMethod) return;
2387
- if (!isClassComponent(currentClass) || currentMethod.static) return;
2660
+ if (!currentClass || !currentMethod) {
2661
+ return;
2662
+ }
2663
+ if (!isClassComponent(currentClass) || currentMethod.static) {
2664
+ return;
2665
+ }
2388
2666
  if (node.init && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
2389
2667
  for (const prop of node.id.properties) {
2390
2668
  if (prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key)) {
@@ -2456,10 +2734,14 @@ var no_unused_state_default = createRule({
2456
2734
  }
2457
2735
  function classExit() {
2458
2736
  const currentClass = classStack.pop();
2459
- if (!currentClass || !isClassComponent(currentClass)) return;
2737
+ if (!currentClass || !isClassComponent(currentClass)) {
2738
+ return;
2739
+ }
2460
2740
  const className = O.map(AST11.getClassIdentifier(currentClass), (id) => id.name);
2461
2741
  const [def, isUsed] = stateDefs.get(currentClass) ?? [O.none(), false];
2462
- if (O.isNone(def) || isUsed) return;
2742
+ if (O.isNone(def) || isUsed) {
2743
+ return;
2744
+ }
2463
2745
  context.report({
2464
2746
  messageId: "noUnusedState",
2465
2747
  node: def.value,
@@ -2471,7 +2753,9 @@ var no_unused_state_default = createRule({
2471
2753
  function methodEnter(node) {
2472
2754
  methodStack.push(node);
2473
2755
  const currentClass = classStack.at(-1);
2474
- if (!currentClass || !isClassComponent(currentClass)) return;
2756
+ if (!currentClass || !isClassComponent(currentClass)) {
2757
+ return;
2758
+ }
2475
2759
  if (node.static) {
2476
2760
  if (isGetDerivedStateFromProps(node) && node.value.params.length > 1) {
2477
2761
  const [def] = stateDefs.get(currentClass) ?? [O.none()];
@@ -2494,11 +2778,17 @@ var no_unused_state_default = createRule({
2494
2778
  }
2495
2779
  return {
2496
2780
  AssignmentExpression(node) {
2497
- if (!isAssignmentToThisState2(node)) return;
2781
+ if (!isAssignmentToThisState2(node)) {
2782
+ return;
2783
+ }
2498
2784
  const currentClass = classStack.at(-1);
2499
- if (!currentClass || !isClassComponent(currentClass)) return;
2785
+ if (!currentClass || !isClassComponent(currentClass)) {
2786
+ return;
2787
+ }
2500
2788
  const currentConstructor = constructorStack.at(-1);
2501
- if (!currentConstructor || !currentClass.body.body.includes(currentConstructor)) return;
2789
+ if (!currentConstructor || !currentClass.body.body.includes(currentConstructor)) {
2790
+ return;
2791
+ }
2502
2792
  const [_, isUsed] = stateDefs.get(currentClass) ?? [O.none(), false];
2503
2793
  stateDefs.set(currentClass, [O.some(node.left), isUsed]);
2504
2794
  },
@@ -2507,14 +2797,26 @@ var no_unused_state_default = createRule({
2507
2797
  ClassExpression: classEnter,
2508
2798
  "ClassExpression:exit": classExit,
2509
2799
  MemberExpression(node) {
2510
- if (!AST11.isThisExpression(node.object)) return;
2511
- if (!O.exists(getName4(node.property), (name2) => name2 === "state")) return;
2800
+ if (!AST11.isThisExpression(node.object)) {
2801
+ return;
2802
+ }
2803
+ if (!O.exists(getName4(node.property), (name2) => name2 === "state")) {
2804
+ return;
2805
+ }
2512
2806
  const currentClass = classStack.at(-1);
2513
- if (!currentClass || !isClassComponent(currentClass)) return;
2807
+ if (!currentClass || !isClassComponent(currentClass)) {
2808
+ return;
2809
+ }
2514
2810
  const currentMethod = methodStack.at(-1);
2515
- if (!currentMethod || currentMethod.static) return;
2516
- if (currentMethod === constructorStack.at(-1)) return;
2517
- if (!currentClass.body.body.includes(currentMethod)) return;
2811
+ if (!currentMethod || currentMethod.static) {
2812
+ return;
2813
+ }
2814
+ if (currentMethod === constructorStack.at(-1)) {
2815
+ return;
2816
+ }
2817
+ if (!currentClass.body.body.includes(currentMethod)) {
2818
+ return;
2819
+ }
2518
2820
  const [def] = stateDefs.get(currentClass) ?? [O.none(), false];
2519
2821
  stateDefs.set(currentClass, [def, true]);
2520
2822
  },
@@ -2526,19 +2828,31 @@ var no_unused_state_default = createRule({
2526
2828
  "PropertyDefinition:exit": methodExit,
2527
2829
  VariableDeclarator(node) {
2528
2830
  const currentClass = classStack.at(-1);
2529
- if (!currentClass || !isClassComponent(currentClass)) return;
2831
+ if (!currentClass || !isClassComponent(currentClass)) {
2832
+ return;
2833
+ }
2530
2834
  const currentMethod = methodStack.at(-1);
2531
- if (!currentMethod || currentMethod.static) return;
2532
- if (currentMethod === constructorStack.at(-1)) return;
2533
- if (!currentClass.body.body.includes(currentMethod)) return;
2534
- if (!(node.init && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern)) return;
2835
+ if (!currentMethod || currentMethod.static) {
2836
+ return;
2837
+ }
2838
+ if (currentMethod === constructorStack.at(-1)) {
2839
+ return;
2840
+ }
2841
+ if (!currentClass.body.body.includes(currentMethod)) {
2842
+ return;
2843
+ }
2844
+ if (!(node.init && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern)) {
2845
+ return;
2846
+ }
2535
2847
  const hasState = node.id.properties.some((prop) => {
2536
2848
  if (prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key)) {
2537
2849
  return O.exists(getName4(prop.key), (name2) => name2 === "state");
2538
2850
  }
2539
2851
  return false;
2540
2852
  });
2541
- if (!hasState) return;
2853
+ if (!hasState) {
2854
+ return;
2855
+ }
2542
2856
  const [def] = stateDefs.get(currentClass) ?? [O.none(), false];
2543
2857
  stateDefs.set(currentClass, [def, true]);
2544
2858
  }
@@ -2552,8 +2866,12 @@ var defaultOptions = [{
2552
2866
  }];
2553
2867
  function checkAndReport(node, context, allowExpressions) {
2554
2868
  const initialScope = context.sourceCode.getScope(node);
2555
- if (JSX7.isKeyedElement(node, initialScope)) return;
2556
- if (JSX7.isBuiltInElement(node.parent)) context.report({ messageId: "noUselessFragmentInBuiltIn", node });
2869
+ if (JSX7.isKeyedElement(node, initialScope)) {
2870
+ return;
2871
+ }
2872
+ if (JSX7.isBuiltInElement(node.parent)) {
2873
+ context.report({ messageId: "noUselessFragmentInBuiltIn", node });
2874
+ }
2557
2875
  if (node.children.length === 0) {
2558
2876
  context.report({ messageId: "noUselessFragment", node });
2559
2877
  return;
@@ -2612,7 +2930,9 @@ var no_useless_fragment_default = createRule({
2612
2930
  const { allowExpressions = true } = option;
2613
2931
  return {
2614
2932
  JSXElement(node) {
2615
- if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return;
2933
+ if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
2934
+ return;
2935
+ }
2616
2936
  checkAndReport(node, context, allowExpressions);
2617
2937
  },
2618
2938
  JSXFragment(node) {
@@ -2656,7 +2976,9 @@ var prefer_destructuring_assignment_default = createRule({
2656
2976
  "Program:exit"(node) {
2657
2977
  const components = Array.from(ctx.getAllComponents(node).values());
2658
2978
  function isFunctionComponent(block) {
2659
- if (!AST11.isFunction(block)) return false;
2979
+ if (!AST11.isFunction(block)) {
2980
+ return false;
2981
+ }
2660
2982
  return O.exists(
2661
2983
  AST11.getFunctionIdentifier(block),
2662
2984
  (id) => isComponentName(id.name) && components.some((component) => component.node === block)
@@ -2669,9 +2991,13 @@ var prefer_destructuring_assignment_default = createRule({
2669
2991
  scope = scope.upper;
2670
2992
  isComponent = isFunctionComponent(scope.block);
2671
2993
  }
2672
- if (!isComponent) continue;
2994
+ if (!isComponent) {
2995
+ continue;
2996
+ }
2673
2997
  const component = scope.block;
2674
- if (!("params" in component)) continue;
2998
+ if (!("params" in component)) {
2999
+ continue;
3000
+ }
2675
3001
  const [props, ctx2] = component.params;
2676
3002
  const isMatch = isMatching({ name: memberExpression.object.name });
2677
3003
  if (isMatch(props)) {
@@ -2787,9 +3113,13 @@ var prefer_read_only_props_default = createRule({
2787
3113
  const components = ctx.getAllComponents(node);
2788
3114
  for (const [_, component] of components) {
2789
3115
  const [props] = component.node.params;
2790
- if (!props) continue;
3116
+ if (!props) {
3117
+ continue;
3118
+ }
2791
3119
  const propsType = getConstrainedTypeAtLocation(services, props);
2792
- if (isTypeReadonly(services.program, propsType) || isReadonlyType(propsType, services)) continue;
3120
+ if (isTypeReadonly(services.program, propsType) || isReadonlyType(propsType, services)) {
3121
+ continue;
3122
+ }
2793
3123
  context.report({ messageId: "preferReadOnlyProps", node: props });
2794
3124
  }
2795
3125
  }
@@ -2821,7 +3151,9 @@ var prefer_shorthand_boolean_default = createRule({
2821
3151
  const { value } = node;
2822
3152
  const propName = JSX7.getPropName(node);
2823
3153
  const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
2824
- if (!hasValueTrue) return O.none();
3154
+ if (!hasValueTrue) {
3155
+ return O.none();
3156
+ }
2825
3157
  return O.some({
2826
3158
  messageId: "preferShorthandBoolean",
2827
3159
  node,
@@ -2858,15 +3190,21 @@ var prefer_shorthand_fragment_default = createRule({
2858
3190
  name: RULE_NAME49,
2859
3191
  create(context) {
2860
3192
  function getReportDescriptor(node) {
2861
- if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") return O.none();
3193
+ if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3194
+ return O.none();
3195
+ }
2862
3196
  const hasAttributes = node.openingElement.attributes.length > 0;
2863
- if (hasAttributes) return O.none();
3197
+ if (hasAttributes) {
3198
+ return O.none();
3199
+ }
2864
3200
  return O.some({
2865
3201
  messageId: "preferShorthandFragment",
2866
3202
  node,
2867
3203
  fix: (fixer) => {
2868
3204
  const { closingElement, openingElement } = node;
2869
- if (!closingElement) return [];
3205
+ if (!closingElement) {
3206
+ return [];
3207
+ }
2870
3208
  return [
2871
3209
  fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
2872
3210
  fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
@@ -2909,7 +3247,9 @@ var use_jsx_vars_default = createRule({
2909
3247
  }
2910
3248
  return {
2911
3249
  JSXOpeningElement(node) {
2912
- if (node.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) return;
3250
+ if (node.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) {
3251
+ return;
3252
+ }
2913
3253
  for (const name2 of O.toArray(getName5(node.name))) {
2914
3254
  context.sourceCode.markVariableAsUsed(name2, node);
2915
3255
  }