eslint-plugin-react-x 1.23.3-next.7 → 1.24.0-beta.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 +419 -481
  2. package/dist/index.mjs +419 -481
  3. package/package.json +11 -11
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { F, O, isString, not, or, isNullable } from '@eslint-react/eff';
2
1
  import * as JSX7 from '@eslint-react/jsx';
3
2
  import { createRuleForPlugin, getSettingsFromContext, unsafeDecodeSettings } from '@eslint-react/shared';
4
3
  import * as AST11 from '@eslint-react/ast';
5
4
  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';
5
+ import { _ } from '@eslint-react/eff';
6
6
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
7
7
  import { isMatching, match, P } from 'ts-pattern';
8
8
  import { compare } from 'compare-versions';
@@ -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.3-next.7";
18
+ var version = "1.24.0-beta.0";
19
19
  var createRule = createRuleForPlugin("x");
20
20
 
21
21
  // src/rules/avoid-shorthand-boolean.ts
@@ -38,18 +38,19 @@ var avoid_shorthand_boolean_default = createRule({
38
38
  },
39
39
  name: RULE_NAME,
40
40
  create(context) {
41
- function getReportDescriptor(node) {
42
- return node.value != null ? O.none() : O.some({
43
- messageId: "avoidShorthandBoolean",
44
- node,
45
- data: {
46
- propName: JSX7.getPropName(node)
47
- },
48
- fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
49
- });
50
- }
51
41
  return {
52
- JSXAttribute: F.flow(getReportDescriptor, O.map(context.report))
42
+ JSXAttribute(node) {
43
+ if (node.value === null) {
44
+ context.report({
45
+ messageId: "avoidShorthandBoolean",
46
+ node,
47
+ data: {
48
+ propName: JSX7.getPropName(node)
49
+ },
50
+ fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
51
+ });
52
+ }
53
+ }
53
54
  };
54
55
  },
55
56
  defaultOptions: []
@@ -112,7 +113,7 @@ var ensure_forward_ref_using_ref_default = createRule({
112
113
  if (component == null || !AST11.isFunction(component)) {
113
114
  return;
114
115
  }
115
- const [_, ref] = component.params;
116
+ const ref = component.params[1];
116
117
  if (ref != null) {
117
118
  return;
118
119
  }
@@ -134,15 +135,15 @@ function getName(node) {
134
135
  return getName(node.expression);
135
136
  }
136
137
  if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
137
- return O.some(node.name);
138
+ return node.name;
138
139
  }
139
140
  if (node.type === AST_NODE_TYPES.Literal) {
140
- return O.some(String(node.value));
141
+ return String(node.value);
141
142
  }
142
143
  if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
143
- return O.fromNullable(node.quasis[0]?.value.raw);
144
+ return node.quasis[0]?.value.raw;
144
145
  }
145
- return O.none();
146
+ return _;
146
147
  }
147
148
  var no_access_state_in_setstate_default = createRule({
148
149
  meta: {
@@ -161,89 +162,86 @@ var no_access_state_in_setstate_default = createRule({
161
162
  if (!context.sourceCode.text.includes("setState")) {
162
163
  return {};
163
164
  }
164
- const classStack = [];
165
- const methodStack = [];
166
- const setStateStack = [];
165
+ const classEntries = [];
166
+ const methodEntries = [];
167
+ const setStateEntries = [];
167
168
  return {
168
169
  CallExpression(node) {
169
170
  if (!isThisSetState(node)) {
170
171
  return;
171
172
  }
172
- setStateStack.push([node, false]);
173
+ setStateEntries.push([node, false]);
173
174
  },
174
175
  "CallExpression:exit"(node) {
175
176
  if (!isThisSetState(node)) {
176
177
  return;
177
178
  }
178
- setStateStack.pop();
179
+ setStateEntries.pop();
179
180
  },
180
181
  ClassDeclaration(node) {
181
- classStack.push([node, isClassComponent(node)]);
182
+ classEntries.push([node, isClassComponent(node)]);
182
183
  },
183
184
  "ClassDeclaration:exit"() {
184
- classStack.pop();
185
+ classEntries.pop();
185
186
  },
186
187
  ClassExpression(node) {
187
- classStack.push([node, isClassComponent(node)]);
188
+ classEntries.push([node, isClassComponent(node)]);
188
189
  },
189
190
  "ClassExpression:exit"() {
190
- classStack.pop();
191
+ classEntries.pop();
191
192
  },
192
193
  MemberExpression(node) {
193
194
  if (!AST11.isThisExpression(node.object)) {
194
195
  return;
195
196
  }
196
- const [currClass, isComponent] = classStack.at(-1) ?? [];
197
+ const [currClass, isComponent] = classEntries.at(-1) ?? [];
197
198
  if (currClass == null || !isComponent) {
198
199
  return;
199
200
  }
200
- const [currMethod, isStatic] = methodStack.at(-1) ?? [];
201
+ const [currMethod, isStatic] = methodEntries.at(-1) ?? [];
201
202
  if (currMethod == null || isStatic) {
202
203
  return;
203
204
  }
204
- const [setState, hasThisState] = setStateStack.at(-1) ?? [];
205
+ const [setState, hasThisState] = setStateEntries.at(-1) ?? [];
205
206
  if (setState == null || hasThisState) {
206
207
  return;
207
208
  }
208
- if (!O.exists(getName(node.property), (name2) => name2 === "state")) {
209
+ if (getName(node.property) !== "state") {
209
210
  return;
210
211
  }
211
212
  context.report({ messageId: "noAccessStateInSetstate", node });
212
213
  },
213
214
  MethodDefinition(node) {
214
- methodStack.push([node, node.static]);
215
+ methodEntries.push([node, node.static]);
215
216
  },
216
217
  "MethodDefinition:exit"() {
217
- methodStack.pop();
218
+ methodEntries.pop();
218
219
  },
219
220
  PropertyDefinition(node) {
220
- methodStack.push([node, node.static]);
221
+ methodEntries.push([node, node.static]);
221
222
  },
222
223
  "PropertyDefinition:exit"() {
223
- methodStack.pop();
224
+ methodEntries.pop();
224
225
  },
225
226
  VariableDeclarator(node) {
226
- const [currClass, isComponent] = classStack.at(-1) ?? [];
227
+ const [currClass, isComponent] = classEntries.at(-1) ?? [];
227
228
  if (currClass == null || !isComponent) {
228
229
  return;
229
230
  }
230
- const [currMethod, isStatic] = methodStack.at(-1) ?? [];
231
+ const [currMethod, isStatic] = methodEntries.at(-1) ?? [];
231
232
  if (currMethod == null || isStatic) {
232
233
  return;
233
234
  }
234
- const [setState, hasThisState] = setStateStack.at(-1) ?? [];
235
+ const [setState, hasThisState] = setStateEntries.at(-1) ?? [];
235
236
  if (setState == null || hasThisState) {
236
237
  return;
237
238
  }
238
239
  if (!(node.init != null && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern)) {
239
240
  return;
240
241
  }
241
- const hasState = node.id.properties.some((prop) => {
242
- if (prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key)) {
243
- return O.exists(getName(prop.key), (name2) => name2 === "state");
244
- }
245
- return false;
246
- });
242
+ const hasState = node.id.properties.some(
243
+ (prop) => prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key) && getName(prop.key) === "state"
244
+ );
247
245
  if (!hasState) {
248
246
  return;
249
247
  }
@@ -296,32 +294,32 @@ function isUsingReactChildren(node, context) {
296
294
  function getMapIndexParamName(node, context) {
297
295
  const { callee } = node;
298
296
  if (callee.type !== AST_NODE_TYPES.MemberExpression) {
299
- return O.none();
297
+ return _;
300
298
  }
301
299
  if (callee.property.type !== AST_NODE_TYPES.Identifier) {
302
- return O.none();
300
+ return _;
303
301
  }
304
302
  const { name: name2 } = callee.property;
305
303
  if (!iteratorFunctionIndexParamPosition.has(name2)) {
306
- return O.none();
304
+ return _;
307
305
  }
308
306
  const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
309
307
  if (callbackArg == null) {
310
- return O.none();
308
+ return _;
311
309
  }
312
310
  if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
313
- return O.none();
311
+ return _;
314
312
  }
315
313
  const { params } = callbackArg;
316
314
  const indexParamPosition = iteratorFunctionIndexParamPosition.get(name2);
317
- if (isNullable(indexParamPosition)) {
318
- return O.none();
315
+ if (indexParamPosition == null) {
316
+ return _;
319
317
  }
320
318
  if (params.length < indexParamPosition + 1) {
321
- return O.none();
319
+ return _;
322
320
  }
323
321
  const param = params.at(indexParamPosition);
324
- return param != null && "name" in param ? O.some(param.name) : O.none();
322
+ return param != null && "name" in param ? param.name : _;
325
323
  }
326
324
  var no_array_index_key_default = createRule({
327
325
  meta: {
@@ -339,7 +337,7 @@ var no_array_index_key_default = createRule({
339
337
  create(context) {
340
338
  const indexParamNames = [];
341
339
  function isArrayIndex(node) {
342
- return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some(O.exists((name2) => name2 === node.name));
340
+ return node.type === AST_NODE_TYPES.Identifier && indexParamNames.some((name2) => name2 != null && name2 === node.name);
343
341
  }
344
342
  function isCreateOrCloneElementCall(node) {
345
343
  return isCreateElementCall(node, context) || isCloneElementCall(node, context);
@@ -348,7 +346,7 @@ var no_array_index_key_default = createRule({
348
346
  switch (node.type) {
349
347
  // key={bar}
350
348
  case AST_NODE_TYPES.Identifier: {
351
- if (indexParamNames.some(O.exists((name2) => name2 === node.name))) {
349
+ if (indexParamNames.some((name2) => name2 != null && name2 === node.name)) {
352
350
  return [{
353
351
  messageId: "noArrayIndexKey",
354
352
  node
@@ -402,7 +400,7 @@ var no_array_index_key_default = createRule({
402
400
  if (!isCreateOrCloneElementCall(node)) {
403
401
  return;
404
402
  }
405
- const [_, props] = node.arguments;
403
+ const [, props] = node.arguments;
406
404
  if (props?.type !== AST_NODE_TYPES.ObjectExpression) {
407
405
  return;
408
406
  }
@@ -585,10 +583,17 @@ var no_children_prop_default = createRule({
585
583
  create(context) {
586
584
  return {
587
585
  JSXElement(node) {
588
- const initialScope = context.sourceCode.getScope(node);
589
- const prop = JSX7.getProp(node.openingElement.attributes, "children", initialScope);
590
- const reportDescriptor = O.map(prop, (prop2) => ({ messageId: "noChildrenProp", node: prop2 }));
591
- O.map(reportDescriptor, context.report);
586
+ const prop = JSX7.getProp(
587
+ "children",
588
+ context.sourceCode.getScope(node),
589
+ node.openingElement.attributes
590
+ );
591
+ if (prop) {
592
+ context.report({
593
+ messageId: "noChildrenProp",
594
+ node: prop
595
+ });
596
+ }
592
597
  }
593
598
  };
594
599
  },
@@ -657,7 +662,7 @@ var no_class_component_default = createRule({
657
662
  ...listeners,
658
663
  "Program:exit"(node) {
659
664
  const components = ctx.getAllComponents(node);
660
- for (const { name: name2, node: component } of components.values()) {
665
+ for (const { name: name2 = "anonymous", node: component } of components.values()) {
661
666
  if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
662
667
  continue;
663
668
  }
@@ -666,7 +671,7 @@ var no_class_component_default = createRule({
666
671
  node: component,
667
672
  data: {
668
673
  // eslint-disable-next-line eslint-plugin/no-unused-placeholders
669
- name: O.getOrElse(F.constant("anonymous"))(name2)
674
+ name: name2
670
675
  }
671
676
  });
672
677
  }
@@ -732,22 +737,21 @@ var no_comment_textnodes_default = createRule({
732
737
  const rawValue = context.sourceCode.getText(node);
733
738
  return /^\s*\/(?:\/|\*)/mu.test(rawValue);
734
739
  }
735
- const getReportDescriptor = (node) => {
740
+ const visitorFunction = (node) => {
736
741
  if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(node.parent)) {
737
- return O.none();
742
+ return;
738
743
  }
739
744
  if (!hasCommentLike(node)) {
740
- return O.none();
745
+ return;
741
746
  }
742
747
  if (!node.parent.type.includes("JSX")) {
743
- return O.none();
748
+ return;
744
749
  }
745
- return O.some({
750
+ context.report({
746
751
  messageId: "noCommentTextnodes",
747
752
  node
748
753
  });
749
754
  };
750
- const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
751
755
  return {
752
756
  JSXText: visitorFunction,
753
757
  Literal: visitorFunction
@@ -773,20 +777,22 @@ var no_complex_conditional_rendering_default = createRule({
773
777
  },
774
778
  name: RULE_NAME15,
775
779
  create(context) {
776
- function getReportDescriptor(node) {
780
+ const visitorFunction = (node) => {
777
781
  const jsxExpContainer = node.parent?.parent;
778
782
  if (!AST11.is(AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
779
- return O.none();
783
+ return;
780
784
  }
781
785
  if (!AST11.isOneOf([AST_NODE_TYPES.JSXElement, AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
782
- return O.none();
786
+ return;
783
787
  }
784
788
  if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
785
- return O.none();
789
+ return;
786
790
  }
787
- return O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer });
788
- }
789
- const visitorFunction = F.flow(getReportDescriptor, O.map(context.report), F.constVoid);
791
+ context.report({
792
+ messageId: "noComplexConditionalRendering",
793
+ node: jsxExpContainer
794
+ });
795
+ };
790
796
  return {
791
797
  "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": visitorFunction,
792
798
  "JSXExpressionContainer > ConditionalExpression > LogicalExpression": visitorFunction,
@@ -1030,13 +1036,9 @@ var no_create_ref_default = createRule({
1030
1036
  create(context) {
1031
1037
  return {
1032
1038
  CallExpression(node) {
1033
- if (!isCreateRefCall(node, context)) {
1034
- return;
1039
+ if (isCreateRefCall(node, context) && !AST11.findParentNode(node, isClassComponent)) {
1040
+ context.report({ messageId: "noCreateRef", node });
1035
1041
  }
1036
- if (O.isSome(AST11.findParentNode(node, isClassComponent))) {
1037
- return;
1038
- }
1039
- context.report({ messageId: "noCreateRef", node });
1040
1042
  }
1041
1043
  };
1042
1044
  },
@@ -1078,14 +1080,10 @@ var no_default_props_default = createRule({
1078
1080
  if (!isComponentName(object.name)) {
1079
1081
  return;
1080
1082
  }
1081
- const isComponent = F.pipe(
1082
- VAR.findVariable(object.name, context.sourceCode.getScope(node)),
1083
- O.flatMap(VAR.getVariableNode(0)),
1084
- O.exists((n) => AST11.isFunction(n) || isClassComponent(n))
1085
- );
1086
- if (!isComponent) {
1087
- return;
1088
- }
1083
+ const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
1084
+ const variableNode = VAR.getVariableNode(variable, 0);
1085
+ if (variableNode === _) return;
1086
+ if (!AST11.isFunction(variableNode) && !isClassComponent(variableNode)) return;
1089
1087
  context.report({ messageId: "noDefaultProps", node: property });
1090
1088
  },
1091
1089
  PropertyDefinition(node) {
@@ -1110,19 +1108,19 @@ function getName2(node) {
1110
1108
  return getName2(node.expression);
1111
1109
  }
1112
1110
  if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
1113
- return O.some(node.name);
1111
+ return node.name;
1114
1112
  }
1115
1113
  if (node.type === AST_NODE_TYPES.Literal) {
1116
- return O.some(String(node.value));
1114
+ return node.value?.toString();
1117
1115
  }
1118
1116
  if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
1119
- return O.fromNullable(node.quasis[0]?.value.raw);
1117
+ return node.quasis[0]?.value.raw;
1120
1118
  }
1121
- return O.none();
1119
+ return _;
1122
1120
  }
1123
1121
  function isAssignmentToThisState(node) {
1124
1122
  const { left } = node;
1125
- return left.type === AST_NODE_TYPES.MemberExpression && AST11.isThisExpression(left.object) && O.exists(getName2(left.property), (name2) => name2 === "state");
1123
+ return left.type === AST_NODE_TYPES.MemberExpression && AST11.isThisExpression(left.object) && getName2(left.property) === "state";
1126
1124
  }
1127
1125
  function isConstructorFunction(node) {
1128
1126
  return AST11.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && AST11.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
@@ -1141,31 +1139,26 @@ var no_direct_mutation_state_default = createRule({
1141
1139
  },
1142
1140
  name: RULE_NAME22,
1143
1141
  create(context) {
1144
- function getReportDescriptor(node) {
1145
- if (!isAssignmentToThisState(node)) {
1146
- return O.none();
1147
- }
1148
- return F.pipe(
1149
- O.Do,
1150
- O.bind("parentClass", () => AST11.findParentNodeGuard(
1142
+ return {
1143
+ AssignmentExpression(node) {
1144
+ if (!isAssignmentToThisState(node)) {
1145
+ return;
1146
+ }
1147
+ const parentClass = AST11.findParentNodeGuard(
1151
1148
  node,
1152
1149
  AST11.isOneOf([
1153
1150
  AST_NODE_TYPES.ClassDeclaration,
1154
1151
  AST_NODE_TYPES.ClassExpression
1155
1152
  ])
1156
- )),
1157
- O.bind("parentConstructor", () => AST11.findParentNodeGuard(node, isConstructorFunction)),
1158
- O.filter(
1159
- ({ parentClass, parentConstructor }) => isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== parentConstructor
1160
- ),
1161
- O.map(() => ({
1162
- messageId: "noDirectMutationState",
1163
- node
1164
- }))
1165
- );
1166
- }
1167
- return {
1168
- AssignmentExpression: F.flow(getReportDescriptor, O.map(context.report))
1153
+ );
1154
+ if (!parentClass) return;
1155
+ if (isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11.findParentNodeGuard(node, isConstructorFunction)) {
1156
+ context.report({
1157
+ messageId: "noDirectMutationState",
1158
+ node
1159
+ });
1160
+ }
1161
+ }
1169
1162
  };
1170
1163
  },
1171
1164
  defaultOptions: []
@@ -1196,7 +1189,7 @@ var no_duplicate_jsx_props_default = createRule({
1196
1189
  continue;
1197
1190
  }
1198
1191
  const name2 = attr.name.name;
1199
- if (!isString(name2)) {
1192
+ if (typeof name2 !== "string") {
1200
1193
  continue;
1201
1194
  }
1202
1195
  if (!props.includes(name2)) {
@@ -1260,16 +1253,10 @@ var no_duplicate_key_default = createRule({
1260
1253
  break;
1261
1254
  }
1262
1255
  default: {
1263
- const mbEntry = F.pipe(
1264
- O.Do,
1265
- O.bind("call", () => AST11.findParentNodeGuard(jsxElement, AST11.isMapCallLoose)),
1266
- O.bind("iter", ({ call: call2 }) => AST11.findParentNodeStop(jsxElement, call2, AST11.isFunction)),
1267
- O.bind("arg0", ({ call: call2 }) => O.fromNullable(call2.arguments[0]))
1268
- );
1269
- if (O.isNone(mbEntry)) {
1270
- return;
1271
- }
1272
- const { arg0, call, iter } = mbEntry.value;
1256
+ const call = AST11.findParentNodeGuard(jsxElement, AST11.isMapCallLoose);
1257
+ const iter = call && AST11.findParentNodeStop(jsxElement, call, AST11.isFunction);
1258
+ const arg0 = call?.arguments[0];
1259
+ if (!call || !iter || !arg0) return;
1273
1260
  if (AST11.unwrapTypeExpression(arg0) !== iter) {
1274
1261
  return;
1275
1262
  }
@@ -1370,21 +1357,19 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
1370
1357
  if (arg0 == null) {
1371
1358
  return [];
1372
1359
  }
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);
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);
1375
- if (O.isNone(fixedArg0Text) || O.isNone(fixedArg1Text)) {
1360
+ const fixedArg0Text = match(arg0).with({ type: AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() => _);
1361
+ const fixedArg1Text = match(arg1).with(P.nullish, () => "ref").with({ type: AST_NODE_TYPES.Identifier, name: "ref" }, () => "ref").with({ type: AST_NODE_TYPES.Identifier, name: P.not("ref") }, (n) => `ref: ${n.name}`).otherwise(() => _);
1362
+ if (fixedArg0Text == null || fixedArg1Text == null) {
1376
1363
  return [];
1377
1364
  }
1378
- const fixedPropsText = fixedArg0Text.value;
1379
- const fixedRefText = fixedArg1Text.value;
1380
1365
  if (typeArg0 == null || typeArg1 == null) {
1381
1366
  return [
1382
1367
  fixer.replaceText(
1383
1368
  arg0,
1384
1369
  [
1385
1370
  "{",
1386
- fixedRefText + ",",
1387
- fixedPropsText,
1371
+ fixedArg1Text + ",",
1372
+ fixedArg0Text,
1388
1373
  "}"
1389
1374
  ].join(" ")
1390
1375
  ),
@@ -1396,8 +1381,8 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
1396
1381
  arg0,
1397
1382
  [
1398
1383
  "{",
1399
- fixedRefText + ",",
1400
- fixedPropsText,
1384
+ fixedArg1Text + ",",
1385
+ fixedArg0Text,
1401
1386
  "}:",
1402
1387
  getText(typeArg1),
1403
1388
  "&",
@@ -1428,17 +1413,17 @@ var no_implicit_key_default = createRule({
1428
1413
  },
1429
1414
  name: RULE_NAME26,
1430
1415
  create(context) {
1431
- function getReportDescriptor(node) {
1432
- const initialScope = context.sourceCode.getScope(node);
1433
- const keyPropFound = JSX7.findPropInAttributes(node.attributes, initialScope)("key");
1434
- const keyPropOnElement = node.attributes.some((n) => AST11.is(AST_NODE_TYPES.JSXAttribute)(n) && n.name.name === "key");
1435
- if (O.isSome(keyPropFound) && !keyPropOnElement) {
1436
- return O.some({ messageId: "noImplicitKey", node: keyPropFound.value });
1437
- }
1438
- return O.none();
1439
- }
1440
1416
  return {
1441
- JSXOpeningElement: F.flow(getReportDescriptor, O.map(context.report))
1417
+ JSXOpeningElement(node) {
1418
+ const initialScope = context.sourceCode.getScope(node);
1419
+ const keyPropFound = JSX7.findPropInAttributes("key", initialScope, node.attributes);
1420
+ const keyPropOnElement = node.attributes.some(
1421
+ (n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
1422
+ );
1423
+ if (keyPropFound && !keyPropOnElement) {
1424
+ context.report({ messageId: "noImplicitKey", node: keyPropFound });
1425
+ }
1426
+ }
1442
1427
  };
1443
1428
  },
1444
1429
  defaultOptions: []
@@ -1484,11 +1469,12 @@ function inspectVariantTypes(types) {
1484
1469
  const booleans = types.filter(tsHelpers.isBooleanType);
1485
1470
  switch (true) {
1486
1471
  case (booleans.length === 1 && booleans[0] != null): {
1487
- const [first] = booleans;
1488
- const evaluated = F.pipe(
1489
- match(first).when(isTrueLiteralType, () => O.some("truthy boolean")).when(isFalseLiteralType, () => O.some("falsy boolean")).otherwise(O.none)
1490
- );
1491
- O.map(evaluated, (v) => variantTypes.add(v));
1472
+ const first = booleans[0];
1473
+ if (isTrueLiteralType(first)) {
1474
+ variantTypes.add("truthy boolean");
1475
+ } else if (isFalseLiteralType(first)) {
1476
+ variantTypes.add("falsy boolean");
1477
+ }
1492
1478
  break;
1493
1479
  }
1494
1480
  case booleans.length === 2: {
@@ -1498,17 +1484,17 @@ function inspectVariantTypes(types) {
1498
1484
  }
1499
1485
  const strings = types.filter(tsHelpers.isStringType);
1500
1486
  if (strings.length > 0) {
1501
- const evaluated = match(strings).when((types2) => types2.every(tsHelpers.isTruthyStringType), F.constant("truthy string")).when((types2) => types2.every(tsHelpers.isFalsyStringType), F.constant("falsy string")).otherwise(F.constant("string"));
1487
+ const evaluated = match(strings).when((types2) => types2.every(tsHelpers.isTruthyStringType), () => "truthy string").when((types2) => types2.every(tsHelpers.isFalsyStringType), () => "falsy string").otherwise(() => "string");
1502
1488
  variantTypes.add(evaluated);
1503
1489
  }
1504
1490
  const bigints = types.filter(tsHelpers.isBigIntType);
1505
1491
  if (bigints.length > 0) {
1506
- const evaluated = match(bigints).when((types2) => types2.every(tsHelpers.isTruthyBigIntType), F.constant("truthy bigint")).when((types2) => types2.every(tsHelpers.isFalsyBigIntType), F.constant("falsy bigint")).otherwise(F.constant("bigint"));
1492
+ const evaluated = match(bigints).when((types2) => types2.every(tsHelpers.isTruthyBigIntType), () => "truthy bigint").when((types2) => types2.every(tsHelpers.isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
1507
1493
  variantTypes.add(evaluated);
1508
1494
  }
1509
1495
  const numbers = types.filter(tsHelpers.isNumberType);
1510
1496
  if (numbers.length > 0) {
1511
- const evaluated = match(numbers).when((types2) => types2.every(tsHelpers.isTruthyNumberType), F.constant("truthy number")).when((types2) => types2.every(tsHelpers.isFalsyNumberType), F.constant("falsy number")).otherwise(F.constant("number"));
1497
+ const evaluated = match(numbers).when((types2) => types2.every(tsHelpers.isTruthyNumberType), () => "truthy number").when((types2) => types2.every(tsHelpers.isFalsyNumberType), () => "falsy number").otherwise(() => "number");
1512
1498
  variantTypes.add(evaluated);
1513
1499
  }
1514
1500
  if (types.some(tsHelpers.isEnumType)) {
@@ -1526,19 +1512,15 @@ function inspectVariantTypes(types) {
1526
1512
  return variantTypes;
1527
1513
  }
1528
1514
  function isInitExpression(node) {
1515
+ if (node == null) return false;
1529
1516
  return node.type !== AST_NODE_TYPES.VariableDeclaration;
1530
1517
  }
1531
- function getVariableInitExpression(at) {
1532
- return (variable) => {
1533
- return F.pipe(
1534
- O.some(variable),
1535
- O.flatMapNullable((v) => v.defs.at(at)),
1536
- O.flatMap(
1537
- (d) => "init" in d.node ? O.fromNullable(d.node.init) : O.none()
1538
- ),
1539
- O.filter(isInitExpression)
1540
- );
1541
- };
1518
+ function getVariableInitExpression(variable, at) {
1519
+ const def = variable?.defs[at];
1520
+ if (def?.node === _ || !("init" in def.node)) {
1521
+ return _;
1522
+ }
1523
+ return isInitExpression(def.node.init) ? def.node.init : _;
1542
1524
  }
1543
1525
  var no_leaked_conditional_rendering_default = createRule({
1544
1526
  meta: {
@@ -1572,19 +1554,20 @@ var no_leaked_conditional_rendering_default = createRule({
1572
1554
  ];
1573
1555
  const services = ESLintUtils.getParserServices(context, false);
1574
1556
  function getReportDescriptor(node) {
1575
- return match(node).when(AST11.isJSX, O.none).with({ type: AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1557
+ if (node === _) return _;
1558
+ return match(node).when(AST11.isJSX, () => _).with({ type: AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1576
1559
  const isLeftUnaryNot = left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!";
1577
1560
  if (isLeftUnaryNot) {
1578
1561
  return getReportDescriptor(right);
1579
1562
  }
1580
1563
  const initialScope = context.sourceCode.getScope(left);
1581
- const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || O.exists(VAR.getStaticValue(left, initialScope), (v) => v === "NaN");
1564
+ const isLeftNan = left.type === AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR.toResolved({ kind: "lazy", node: left, initialScope }).value === "NaN";
1582
1565
  if (isLeftNan) {
1583
- return O.some({
1566
+ return {
1584
1567
  messageId: "noLeakedConditionalRendering",
1585
1568
  node: left,
1586
1569
  data: { value: context.sourceCode.getText(left) }
1587
- });
1570
+ };
1588
1571
  }
1589
1572
  const leftType = getConstrainedTypeAtLocation(services, left);
1590
1573
  const leftTypeVariants = inspectVariantTypes(unionTypeParts(leftType));
@@ -1592,22 +1575,24 @@ var no_leaked_conditional_rendering_default = createRule({
1592
1575
  if (isLeftValid) {
1593
1576
  return getReportDescriptor(right);
1594
1577
  }
1595
- return O.some({
1578
+ return {
1596
1579
  messageId: "noLeakedConditionalRendering",
1597
1580
  node: left,
1598
1581
  data: { value: context.sourceCode.getText(left) }
1599
- });
1582
+ };
1600
1583
  }).with({ type: AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
1601
- return O.orElse(getReportDescriptor(consequent), () => getReportDescriptor(alternate));
1584
+ return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
1602
1585
  }).with({ type: AST_NODE_TYPES.Identifier }, (n) => {
1603
- return F.pipe(
1604
- VAR.findVariable(n.name, context.sourceCode.getScope(n)),
1605
- O.flatMap(getVariableInitExpression(0)),
1606
- O.flatMap(getReportDescriptor)
1607
- );
1608
- }).otherwise(O.none);
1586
+ const variable = VAR.findVariable(n.name, context.sourceCode.getScope(n));
1587
+ const initExpression = getVariableInitExpression(variable, 0);
1588
+ return getReportDescriptor(initExpression);
1589
+ }).otherwise(() => _);
1609
1590
  }
1610
- const visitorFunction = F.flow(getReportDescriptor, O.map(context.report));
1591
+ const visitorFunction = (node) => {
1592
+ const descriptor = getReportDescriptor(node);
1593
+ if (descriptor === _) return;
1594
+ context.report(descriptor);
1595
+ };
1611
1596
  return {
1612
1597
  "JSXExpressionContainer > ConditionalExpression": visitorFunction,
1613
1598
  "JSXExpressionContainer > LogicalExpression": visitorFunction
@@ -1643,13 +1628,13 @@ var no_missing_component_display_name_default = createRule({
1643
1628
  const components = ctx.getAllComponents(node);
1644
1629
  for (const { node: node2, displayName, flag } of components.values()) {
1645
1630
  const isMemoOrForwardRef = (flag & (ERFunctionComponentFlag.ForwardRef | ERFunctionComponentFlag.Memo)) > 0n;
1646
- if (O.isSome(AST11.getFunctionIdentifier(node2))) {
1631
+ if (AST11.getFunctionIdentifier(node2)) {
1647
1632
  continue;
1648
1633
  }
1649
1634
  if (!isMemoOrForwardRef) {
1650
1635
  continue;
1651
1636
  }
1652
- if (O.isNone(displayName)) {
1637
+ if (!displayName) {
1653
1638
  context.report({
1654
1639
  messageId: "noMissingComponentDisplayName",
1655
1640
  node: node2
@@ -1685,51 +1670,55 @@ var no_missing_key_default = createRule({
1685
1670
  switch (node.type) {
1686
1671
  case AST_NODE_TYPES.JSXElement: {
1687
1672
  const initialScope = context.sourceCode.getScope(node);
1688
- if (!JSX7.hasProp(node.openingElement.attributes, "key", initialScope)) {
1689
- return O.some({
1673
+ if (!JSX7.hasProp("key", initialScope, node.openingElement.attributes)) {
1674
+ return {
1690
1675
  messageId: "noMissingKey",
1691
1676
  node
1692
- });
1677
+ };
1693
1678
  }
1694
- return O.none();
1679
+ return null;
1695
1680
  }
1696
1681
  case AST_NODE_TYPES.JSXFragment: {
1697
- return O.some({
1682
+ return {
1698
1683
  messageId: "noMissingKeyWithFragment",
1699
1684
  node
1700
- });
1685
+ };
1701
1686
  }
1702
1687
  default:
1703
- return O.none();
1688
+ return null;
1704
1689
  }
1705
1690
  }
1706
1691
  function checkExpression(node) {
1707
1692
  switch (node.type) {
1708
1693
  case AST_NODE_TYPES.ConditionalExpression:
1709
- if (!("consequent" in node)) {
1710
- return O.none();
1694
+ if ("consequent" in node) {
1695
+ return checkIteratorElement(node.consequent) ?? checkIteratorElement(node.alternate);
1711
1696
  }
1712
- return O.orElse(checkIteratorElement(node.consequent), () => checkIteratorElement(node.alternate));
1697
+ return null;
1713
1698
  case AST_NODE_TYPES.JSXElement:
1714
1699
  case AST_NODE_TYPES.JSXFragment:
1715
1700
  return checkIteratorElement(node);
1716
1701
  case AST_NODE_TYPES.LogicalExpression:
1717
- if (!("left" in node)) {
1718
- return O.none();
1702
+ if ("left" in node) {
1703
+ return checkIteratorElement(node.left) ?? checkIteratorElement(node.right);
1719
1704
  }
1720
- return O.orElse(checkIteratorElement(node.left), () => checkIteratorElement(node.right));
1705
+ return null;
1721
1706
  default:
1722
- return O.none();
1707
+ return null;
1723
1708
  }
1724
1709
  }
1725
1710
  function checkBlockStatement(node) {
1726
- return AST11.getNestedReturnStatements(node).reduce((acc, statement) => {
1711
+ const descriptors = [];
1712
+ for (const statement of AST11.getNestedReturnStatements(node)) {
1727
1713
  if (statement.argument == null) {
1728
- return acc;
1714
+ continue;
1715
+ }
1716
+ const descriptor = checkIteratorElement(statement.argument);
1717
+ if (descriptor != null) {
1718
+ descriptors.push(descriptor);
1729
1719
  }
1730
- const mbDescriptor = checkIteratorElement(statement.argument);
1731
- return O.isNone(mbDescriptor) ? acc : [...acc, mbDescriptor.value];
1732
- }, []);
1720
+ }
1721
+ return descriptors;
1733
1722
  }
1734
1723
  return {
1735
1724
  ArrayExpression(node) {
@@ -1742,7 +1731,7 @@ var no_missing_key_default = createRule({
1742
1731
  }
1743
1732
  const initialScope = context.sourceCode.getScope(node);
1744
1733
  for (const element of elements) {
1745
- if (!JSX7.hasProp(element.openingElement.attributes, "key", initialScope)) {
1734
+ if (!JSX7.hasProp("key", initialScope, element.openingElement.attributes)) {
1746
1735
  context.report({
1747
1736
  messageId: "noMissingKey",
1748
1737
  node: element
@@ -1755,30 +1744,24 @@ var no_missing_key_default = createRule({
1755
1744
  if (state.isWithinChildrenToArray) {
1756
1745
  return;
1757
1746
  }
1758
- const isMapCall = AST11.isMapCallLoose(node);
1759
- const isArrayFromCall = isMatching({
1760
- type: AST_NODE_TYPES.CallExpression,
1761
- callee: {
1762
- type: AST_NODE_TYPES.MemberExpression,
1763
- property: {
1764
- name: "from"
1765
- }
1766
- }
1767
- }, node);
1768
- if (!isMapCall && !isArrayFromCall) {
1747
+ const isMapCallLike = AST11.isMapCallLoose(node);
1748
+ if (!isMapCallLike && !isArrayFromCall(node)) {
1769
1749
  return;
1770
1750
  }
1771
- const fn = node.arguments[isMapCall ? 0 : 1];
1772
- if (!AST11.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(fn)) {
1751
+ const fn = node.arguments[isMapCallLike ? 0 : 1];
1752
+ if (fn?.type !== AST_NODE_TYPES.ArrowFunctionExpression && fn?.type !== AST_NODE_TYPES.FunctionExpression) {
1773
1753
  return;
1774
1754
  }
1775
1755
  if (fn.body.type === AST_NODE_TYPES.BlockStatement) {
1776
- for (const descriptor of checkBlockStatement(fn.body)) {
1777
- context.report(descriptor);
1756
+ for (const descriptor2 of checkBlockStatement(fn.body)) {
1757
+ context.report(descriptor2);
1778
1758
  }
1779
1759
  return;
1780
1760
  }
1781
- O.map(checkExpression(fn.body), context.report);
1761
+ const descriptor = checkExpression(fn.body);
1762
+ if (descriptor != null) {
1763
+ context.report(descriptor);
1764
+ }
1782
1765
  },
1783
1766
  "CallExpression:exit"(node) {
1784
1767
  if (!isChildrenToArrayCall(node, context)) {
@@ -1801,6 +1784,9 @@ var no_missing_key_default = createRule({
1801
1784
  },
1802
1785
  defaultOptions: []
1803
1786
  });
1787
+ function isArrayFromCall(node) {
1788
+ return node.type === AST_NODE_TYPES.CallExpression && node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
1789
+ }
1804
1790
  var RULE_NAME30 = "no-nested-components";
1805
1791
  var RULE_FEATURES30 = [
1806
1792
  "CHK"
@@ -1827,24 +1813,27 @@ var no_nested_components_default = createRule({
1827
1813
  ...collector.listeners,
1828
1814
  ...collectorLegacy.listeners,
1829
1815
  "Program:exit"(node) {
1830
- const functionComponents = Array.from(collector.ctx.getAllComponents(node).values());
1831
- const classComponents = Array.from(collectorLegacy.ctx.getAllComponents(node).values());
1816
+ const functionComponents = [
1817
+ ...collector.ctx.getAllComponents(node).values()
1818
+ ];
1819
+ const classComponents = [
1820
+ ...collectorLegacy.ctx.getAllComponents(node).values()
1821
+ ];
1832
1822
  const isFunctionComponent = (node2) => {
1833
1823
  return AST11.isFunction(node2) && functionComponents.some((component) => component.node === node2);
1834
1824
  };
1835
1825
  const isClassComponent11 = (node2) => {
1836
1826
  return AST11.isClass(node2) && classComponents.some((component) => component.node === node2);
1837
1827
  };
1838
- for (const { name: componentName, node: component } of functionComponents) {
1828
+ for (const { name: name2, node: component } of functionComponents) {
1839
1829
  if (isDirectValueOfRenderPropertyLoose(component)) {
1840
1830
  continue;
1841
1831
  }
1842
- if (O.isNone(componentName)) {
1832
+ if (name2 === _) {
1843
1833
  continue;
1844
1834
  }
1845
- const name2 = componentName.value;
1846
1835
  const isInsideProperty = component.parent.type === AST_NODE_TYPES.Property;
1847
- const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || O.isSome(JSX7.findParentProp(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer));
1836
+ const isInsideJSXPropValue = component.parent.type === AST_NODE_TYPES.JSXAttribute || !!JSX7.findParentProp(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer);
1848
1837
  if (isInsideJSXPropValue) {
1849
1838
  if (!isDeclaredInRenderPropLoose(component)) {
1850
1839
  context.report({
@@ -1867,13 +1856,8 @@ var no_nested_components_default = createRule({
1867
1856
  });
1868
1857
  continue;
1869
1858
  }
1870
- const isParnetComponentNotDirectValueOfRenderProperty = O.exists(
1871
- AST11.findParentNodeGuard(
1872
- component,
1873
- isFunctionComponent
1874
- ),
1875
- not(isDirectValueOfRenderPropertyLoose)
1876
- );
1859
+ const parentComponent = AST11.findParentNodeGuard(component, isFunctionComponent);
1860
+ const isParnetComponentNotDirectValueOfRenderProperty = !!parentComponent && !isDirectValueOfRenderPropertyLoose(parentComponent);
1877
1861
  if (isParnetComponentNotDirectValueOfRenderProperty) {
1878
1862
  context.report({
1879
1863
  messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
@@ -1894,15 +1878,15 @@ var no_nested_components_default = createRule({
1894
1878
  });
1895
1879
  }
1896
1880
  }
1897
- for (const { name: name2, node: component } of classComponents) {
1898
- if (O.isNone(AST11.findParentNode(component, or(isClassComponent11, isFunctionComponent)))) {
1881
+ for (const { name: name2 = "unknown", node: component } of classComponents) {
1882
+ if (!AST11.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n))) {
1899
1883
  continue;
1900
1884
  }
1901
1885
  context.report({
1902
1886
  messageId: "nestedComponent",
1903
1887
  node: component,
1904
1888
  data: {
1905
- name: O.getOrElse(() => "unknown")(name2)
1889
+ name: name2
1906
1890
  }
1907
1891
  });
1908
1892
  }
@@ -1947,15 +1931,11 @@ var no_prop_types_default = createRule({
1947
1931
  if (!isComponentName(object.name)) {
1948
1932
  return;
1949
1933
  }
1950
- const isComponent = F.pipe(
1951
- VAR.findVariable(object.name, context.sourceCode.getScope(node)),
1952
- O.flatMap(VAR.getVariableNode(0)),
1953
- O.exists((n) => AST11.isFunction(n) || isClassComponent(n))
1954
- );
1955
- if (!isComponent) {
1956
- return;
1934
+ const variable = VAR.findVariable(object.name, context.sourceCode.getScope(node));
1935
+ const variableNode = variable && VAR.getVariableNode(variable, 0);
1936
+ if (variableNode && (AST11.isFunction(variableNode) || isClassComponent(variableNode))) {
1937
+ context.report({ messageId: "noPropTypes", node: property });
1957
1938
  }
1958
- context.report({ messageId: "noPropTypes", node: property });
1959
1939
  },
1960
1940
  PropertyDefinition(node) {
1961
1941
  if (!isClassComponent(node.parent.parent)) {
@@ -1999,7 +1979,7 @@ var no_redundant_should_component_update_default = createRule({
1999
1979
  ...listeners,
2000
1980
  "Program:exit"(node) {
2001
1981
  const components = ctx.getAllComponents(node);
2002
- for (const { name: name2, node: component, flag } of components.values()) {
1982
+ for (const { name: name2 = "PureComponent", node: component, flag } of components.values()) {
2003
1983
  if ((flag & ERClassComponentFlag.PureComponent) === 0n) {
2004
1984
  continue;
2005
1985
  }
@@ -2010,7 +1990,7 @@ var no_redundant_should_component_update_default = createRule({
2010
1990
  messageId: "noRedundantShouldComponentUpdate",
2011
1991
  node: member,
2012
1992
  data: {
2013
- componentName: O.getOrElse(() => "PureComponent")(name2)
1993
+ componentName: name2
2014
1994
  }
2015
1995
  });
2016
1996
  }
@@ -2045,32 +2025,22 @@ var no_set_state_in_component_did_mount_default = createRule({
2045
2025
  if (!context.sourceCode.text.includes("componentDidMount")) {
2046
2026
  return {};
2047
2027
  }
2048
- function getReportDescriptor(node) {
2049
- if (!isThisSetState(node)) {
2050
- return O.none();
2051
- }
2052
- return F.pipe(
2053
- O.Do,
2054
- O.bind("clazz", () => AST11.findParentNodeGuard(node, isClassComponent)),
2055
- O.bind("method", ({ clazz }) => AST11.findParentNodeStop(node, clazz, isComponentDidMount)),
2056
- O.bind("methodScope", ({ method }) => O.some(context.sourceCode.getScope(method))),
2057
- O.bind("upperScope", () => O.fromNullable(context.sourceCode.getScope(node).upper)),
2058
- O.filter(
2059
- ({
2060
- clazz,
2061
- method,
2062
- methodScope,
2063
- upperScope
2064
- }) => method.parent === clazz.body && upperScope === methodScope
2065
- ),
2066
- O.map(() => ({
2067
- messageId: "noSetStateInComponentDidMount",
2068
- node
2069
- }))
2070
- );
2071
- }
2072
2028
  return {
2073
- CallExpression: F.flow(getReportDescriptor, O.map(context.report))
2029
+ CallExpression(node) {
2030
+ if (!isThisSetState(node)) {
2031
+ return;
2032
+ }
2033
+ const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2034
+ const method = clazz && AST11.findParentNodeStop(node, clazz, isComponentDidMount);
2035
+ const methodScope = method && context.sourceCode.getScope(method);
2036
+ const upperScope = context.sourceCode.getScope(node).upper;
2037
+ if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2038
+ context.report({
2039
+ messageId: "noSetStateInComponentDidMount",
2040
+ node
2041
+ });
2042
+ }
2043
+ }
2074
2044
  };
2075
2045
  },
2076
2046
  defaultOptions: []
@@ -2099,32 +2069,22 @@ var no_set_state_in_component_did_update_default = createRule({
2099
2069
  if (!context.sourceCode.text.includes("componentDidUpdate")) {
2100
2070
  return {};
2101
2071
  }
2102
- function getReportDescriptor(node) {
2103
- if (!isThisSetState(node)) {
2104
- return O.none();
2105
- }
2106
- return F.pipe(
2107
- O.Do,
2108
- O.bind("clazz", () => AST11.findParentNodeGuard(node, isClassComponent)),
2109
- O.bind("method", ({ clazz }) => AST11.findParentNodeStop(node, clazz, isComponentDidUpdate)),
2110
- O.bind("methodScope", ({ method }) => O.some(context.sourceCode.getScope(method))),
2111
- O.bind("upperScope", () => O.fromNullable(context.sourceCode.getScope(node).upper)),
2112
- O.filter(
2113
- ({
2114
- clazz,
2115
- method,
2116
- methodScope,
2117
- upperScope
2118
- }) => method.parent === clazz.body && upperScope === methodScope
2119
- ),
2120
- O.map(() => ({
2121
- messageId: "noSetStateInComponentDidUpdate",
2122
- node
2123
- }))
2124
- );
2125
- }
2126
2072
  return {
2127
- CallExpression: F.flow(getReportDescriptor, O.map(context.report))
2073
+ CallExpression(node) {
2074
+ if (!isThisSetState(node)) {
2075
+ return;
2076
+ }
2077
+ const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2078
+ const method = clazz && AST11.findParentNodeStop(node, clazz, isComponentDidUpdate);
2079
+ const methodScope = method && context.sourceCode.getScope(method);
2080
+ const upperScope = context.sourceCode.getScope(node).upper;
2081
+ if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2082
+ context.report({
2083
+ messageId: "noSetStateInComponentDidUpdate",
2084
+ node
2085
+ });
2086
+ }
2087
+ }
2128
2088
  };
2129
2089
  },
2130
2090
  defaultOptions: []
@@ -2153,32 +2113,22 @@ var no_set_state_in_component_will_update_default = createRule({
2153
2113
  if (!context.sourceCode.text.includes("componentWillUpdate")) {
2154
2114
  return {};
2155
2115
  }
2156
- function getReportDescriptor(node) {
2157
- if (!isThisSetState(node)) {
2158
- return O.none();
2159
- }
2160
- return F.pipe(
2161
- O.Do,
2162
- O.bind("clazz", () => AST11.findParentNodeGuard(node, isClassComponent)),
2163
- O.bind("method", ({ clazz }) => AST11.findParentNodeStop(node, clazz, isComponentWillUpdate3)),
2164
- O.bind("methodScope", ({ method }) => O.some(context.sourceCode.getScope(method))),
2165
- O.bind("upperScope", () => O.fromNullable(context.sourceCode.getScope(node).upper)),
2166
- O.filter(
2167
- ({
2168
- clazz,
2169
- method,
2170
- methodScope,
2171
- upperScope
2172
- }) => method.parent === clazz.body && upperScope === methodScope
2173
- ),
2174
- O.map(() => ({
2175
- messageId: "noSetStateInComponentWillUpdate",
2176
- node
2177
- }))
2178
- );
2179
- }
2180
2116
  return {
2181
- CallExpression: F.flow(getReportDescriptor, O.map(context.report))
2117
+ CallExpression(node) {
2118
+ if (!isThisSetState(node)) {
2119
+ return;
2120
+ }
2121
+ const clazz = AST11.findParentNodeGuard(node, isClassComponent);
2122
+ const method = clazz && AST11.findParentNodeStop(node, clazz, isComponentWillUpdate3);
2123
+ const methodScope = method && context.sourceCode.getScope(method);
2124
+ const upperScope = context.sourceCode.getScope(node).upper;
2125
+ if (clazz && method && method.parent === clazz.body && upperScope === methodScope) {
2126
+ context.report({
2127
+ messageId: "noSetStateInComponentWillUpdate",
2128
+ node
2129
+ });
2130
+ }
2131
+ }
2182
2132
  };
2183
2133
  },
2184
2134
  defaultOptions: []
@@ -2188,14 +2138,14 @@ var RULE_FEATURES36 = [
2188
2138
  "CHK"
2189
2139
  ];
2190
2140
  function containsStringLiteral({ value }) {
2191
- return value?.type === AST_NODE_TYPES.Literal && isString(value.value);
2141
+ return value?.type === AST_NODE_TYPES.Literal && typeof value.value === "string";
2192
2142
  }
2193
2143
  function containsStringExpressionContainer({ value }) {
2194
2144
  if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) {
2195
2145
  return false;
2196
2146
  }
2197
2147
  if (value.expression.type === AST_NODE_TYPES.Literal) {
2198
- return isString(value.expression.value);
2148
+ return typeof value.expression.value === "string";
2199
2149
  }
2200
2150
  return value.expression.type === AST_NODE_TYPES.TemplateLiteral;
2201
2151
  }
@@ -2396,39 +2346,28 @@ var no_unstable_context_value_default = createRule({
2396
2346
  if (openingElementName.property.name !== "Provider") {
2397
2347
  return;
2398
2348
  }
2399
- F.pipe(
2400
- O.Do,
2401
- O.bind("function", ctx.getCurrentFunction),
2402
- O.bind("attribute", () => O.fromNullable(
2403
- node.attributes.find((attribute) => {
2404
- return attribute.type === AST_NODE_TYPES.JSXAttribute && attribute.name.name === "value";
2405
- })
2406
- )),
2407
- O.bind("value", ({ attribute }) => "value" in attribute ? O.some(attribute.value) : O.none()),
2408
- O.bind("valueExpression", ({ value }) => value?.type === AST_NODE_TYPES.JSXExpressionContainer ? O.some(value.expression) : O.none()),
2409
- O.bind("construction", ({ valueExpression }) => {
2410
- const initialScope = context.sourceCode.getScope(valueExpression);
2411
- return O.some(VAR.getValueConstruction(valueExpression, initialScope));
2412
- }),
2413
- O.map((vc) => {
2414
- if (vc.construction.kind === "None") {
2415
- return;
2416
- }
2417
- if (isReactHookCall(vc.construction.node)) {
2418
- return;
2419
- }
2420
- const prevs = constructions.get(vc.function.node) ?? [];
2421
- constructions.set(vc.function.node, [...prevs, vc.construction]);
2422
- })
2349
+ const functionEntry = ctx.getCurrentEntry();
2350
+ if (functionEntry === _) return;
2351
+ const attribute = node.attributes.find(
2352
+ (attribute2) => attribute2.type === AST_NODE_TYPES.JSXAttribute && attribute2.name.name === "value"
2423
2353
  );
2354
+ if (attribute === _ || !("value" in attribute)) return;
2355
+ const value = attribute.value;
2356
+ if (value?.type !== AST_NODE_TYPES.JSXExpressionContainer) return;
2357
+ const valueExpression = value.expression;
2358
+ const initialScope = context.sourceCode.getScope(valueExpression);
2359
+ const construction = VAR.getValueConstruction(valueExpression, initialScope);
2360
+ if (construction === _) return;
2361
+ if (isReactHookCall(construction.node)) {
2362
+ return;
2363
+ }
2364
+ const prevs = constructions.get(functionEntry.node) ?? [];
2365
+ constructions.set(functionEntry.node, [...prevs, construction]);
2424
2366
  },
2425
2367
  "Program:exit"(node) {
2426
2368
  const components = ctx.getAllComponents(node).values();
2427
2369
  for (const { node: component } of components) {
2428
2370
  for (const construction of constructions.get(component) ?? []) {
2429
- if (construction.kind === "None") {
2430
- continue;
2431
- }
2432
2371
  const { kind, node: constructionNode } = construction;
2433
2372
  const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
2434
2373
  context.report({
@@ -2490,7 +2429,7 @@ var no_unstable_default_props_default = createRule({
2490
2429
  initialScope,
2491
2430
  VAR.ValueConstructionHint.StrictCallExpression
2492
2431
  );
2493
- if (construction.kind === "None") {
2432
+ if (construction === _) {
2494
2433
  continue;
2495
2434
  }
2496
2435
  if (isReactHookCall(construction.node)) {
@@ -2508,13 +2447,10 @@ var no_unstable_default_props_default = createRule({
2508
2447
  }
2509
2448
  },
2510
2449
  "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node) {
2511
- const mbEntry = ctx.getCurrentFunction();
2512
- if (O.isNone(mbEntry)) {
2513
- return;
2514
- }
2515
- const entry = mbEntry.value;
2516
- const prevs = declarators.get(entry.node) ?? [];
2517
- declarators.set(entry.node, [...prevs, node]);
2450
+ const functionEntry = ctx.getCurrentEntry();
2451
+ if (!functionEntry) return;
2452
+ const prevs = declarators.get(functionEntry.node) ?? [];
2453
+ declarators.set(functionEntry.node, [...prevs, node]);
2518
2454
  }
2519
2455
  };
2520
2456
  },
@@ -2546,15 +2482,15 @@ function getName3(node) {
2546
2482
  return getName3(node.expression);
2547
2483
  }
2548
2484
  if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
2549
- return O.some(node.name);
2485
+ return node.name;
2550
2486
  }
2551
2487
  if (node.type === AST_NODE_TYPES.Literal) {
2552
- return O.some(String(node.value));
2488
+ return node.value?.toString();
2553
2489
  }
2554
2490
  if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
2555
- return O.fromNullable(node.quasis[0]?.value.raw);
2491
+ return node.quasis[0]?.value.raw;
2556
2492
  }
2557
- return O.none();
2493
+ return _;
2558
2494
  }
2559
2495
  var no_unused_class_component_members_default = createRule({
2560
2496
  meta: {
@@ -2570,12 +2506,12 @@ var no_unused_class_component_members_default = createRule({
2570
2506
  },
2571
2507
  name: RULE_NAME42,
2572
2508
  create(context) {
2573
- const classStack = [];
2574
- const methodStack = [];
2509
+ const classEntries = [];
2510
+ const methodEntries = [];
2575
2511
  const propertyDefs = /* @__PURE__ */ new WeakMap();
2576
2512
  const propertyUsages = /* @__PURE__ */ new WeakMap();
2577
2513
  function classEnter(node) {
2578
- classStack.push(node);
2514
+ classEntries.push(node);
2579
2515
  if (!isClassComponent(node)) {
2580
2516
  return;
2581
2517
  }
@@ -2583,37 +2519,37 @@ var no_unused_class_component_members_default = createRule({
2583
2519
  propertyUsages.set(node, /* @__PURE__ */ new Set());
2584
2520
  }
2585
2521
  function classExit() {
2586
- const currentClass = classStack.pop();
2522
+ const currentClass = classEntries.pop();
2587
2523
  if (currentClass == null || !isClassComponent(currentClass)) {
2588
2524
  return;
2589
2525
  }
2590
- const className = O.map(AST11.getClassIdentifier(currentClass), (id) => id.name);
2526
+ const className = AST11.getClassIdentifier(currentClass)?.name;
2591
2527
  const defs = propertyDefs.get(currentClass);
2592
2528
  const usages = propertyUsages.get(currentClass);
2593
2529
  if (defs == null) {
2594
2530
  return;
2595
2531
  }
2596
2532
  for (const def of defs) {
2597
- const name2 = getName3(def);
2598
- if (O.isNone(name2)) {
2533
+ const methodName = getName3(def);
2534
+ if (methodName == null) {
2599
2535
  continue;
2600
2536
  }
2601
- if (usages?.has(name2.value) || LIFECYCLE_METHODS.has(name2.value)) {
2537
+ if (usages?.has(methodName) || LIFECYCLE_METHODS.has(methodName)) {
2602
2538
  continue;
2603
2539
  }
2604
2540
  context.report({
2605
2541
  messageId: "noUnusedClassComponentMembers",
2606
2542
  node: def,
2607
2543
  data: {
2608
- className: O.getOrElse(className, () => "Component"),
2609
- methodName: name2.value
2544
+ className: className ?? "Component",
2545
+ methodName
2610
2546
  }
2611
2547
  });
2612
2548
  }
2613
2549
  }
2614
2550
  function methodEnter(node) {
2615
- methodStack.push(node);
2616
- const currentClass = classStack.at(-1);
2551
+ methodEntries.push(node);
2552
+ const currentClass = classEntries.at(-1);
2617
2553
  if (currentClass == null || !isClassComponent(currentClass)) {
2618
2554
  return;
2619
2555
  }
@@ -2625,7 +2561,7 @@ var no_unused_class_component_members_default = createRule({
2625
2561
  }
2626
2562
  }
2627
2563
  function methodExit() {
2628
- methodStack.pop();
2564
+ methodEntries.pop();
2629
2565
  }
2630
2566
  return {
2631
2567
  ClassDeclaration: classEnter,
@@ -2633,8 +2569,8 @@ var no_unused_class_component_members_default = createRule({
2633
2569
  ClassExpression: classEnter,
2634
2570
  "ClassExpression:exit": classExit,
2635
2571
  MemberExpression(node) {
2636
- const currentClass = classStack.at(-1);
2637
- const currentMethod = methodStack.at(-1);
2572
+ const currentClass = classEntries.at(-1);
2573
+ const currentMethod = methodEntries.at(-1);
2638
2574
  if (currentClass == null || currentMethod == null) {
2639
2575
  return;
2640
2576
  }
@@ -2648,15 +2584,18 @@ var no_unused_class_component_members_default = createRule({
2648
2584
  propertyDefs.get(currentClass)?.add(node.property);
2649
2585
  return;
2650
2586
  }
2651
- O.map(getName3(node.property), (name2) => propertyUsages.get(currentClass)?.add(name2));
2587
+ const propertyName = getName3(node.property);
2588
+ if (propertyName != null) {
2589
+ propertyUsages.get(currentClass)?.add(propertyName);
2590
+ }
2652
2591
  },
2653
2592
  MethodDefinition: methodEnter,
2654
2593
  "MethodDefinition:exit": methodExit,
2655
2594
  PropertyDefinition: methodEnter,
2656
2595
  "PropertyDefinition:exit": methodExit,
2657
2596
  VariableDeclarator(node) {
2658
- const currentClass = classStack.at(-1);
2659
- const currentMethod = methodStack.at(-1);
2597
+ const currentClass = classEntries.at(-1);
2598
+ const currentMethod = methodEntries.at(-1);
2660
2599
  if (currentClass == null || currentMethod == null) {
2661
2600
  return;
2662
2601
  }
@@ -2666,10 +2605,9 @@ var no_unused_class_component_members_default = createRule({
2666
2605
  if (node.init != null && AST11.isThisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
2667
2606
  for (const prop of node.id.properties) {
2668
2607
  if (prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key)) {
2669
- const mbName = getName3(prop.key);
2670
- if (O.isSome(mbName)) {
2671
- const name2 = mbName.value;
2672
- propertyUsages.get(currentClass)?.add(name2);
2608
+ const keyName = getName3(prop.key);
2609
+ if (keyName != null) {
2610
+ propertyUsages.get(currentClass)?.add(keyName);
2673
2611
  }
2674
2612
  }
2675
2613
  }
@@ -2688,19 +2626,19 @@ function getName4(node) {
2688
2626
  return getName4(node.expression);
2689
2627
  }
2690
2628
  if (node.type === AST_NODE_TYPES.Identifier || node.type === AST_NODE_TYPES.PrivateIdentifier) {
2691
- return O.some(node.name);
2629
+ return node.name;
2692
2630
  }
2693
2631
  if (node.type === AST_NODE_TYPES.Literal) {
2694
- return O.some(String(node.value));
2632
+ return String(node.value);
2695
2633
  }
2696
2634
  if (node.type === AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
2697
- return O.fromNullable(node.quasis[0]?.value.raw);
2635
+ return node.quasis[0]?.value.raw;
2698
2636
  }
2699
- return O.none();
2637
+ return _;
2700
2638
  }
2701
2639
  function isAssignmentToThisState2(node) {
2702
2640
  const { left } = node;
2703
- return left.type === AST_NODE_TYPES.MemberExpression && AST11.isThisExpression(left.object) && O.exists(getName4(left.property), (name2) => name2 === "state");
2641
+ return left.type === AST_NODE_TYPES.MemberExpression && AST11.isThisExpression(left.object) && getName4(left.property) === "state";
2704
2642
  }
2705
2643
  var isGetDerivedStateFromProps = isMatching({
2706
2644
  key: {
@@ -2725,72 +2663,72 @@ var no_unused_state_default = createRule({
2725
2663
  },
2726
2664
  name: RULE_NAME43,
2727
2665
  create(context) {
2728
- const classStack = [];
2729
- const methodStack = [];
2730
- const constructorStack = [];
2666
+ const classEntries = [];
2667
+ const methodEntries = [];
2668
+ const constructorEntries = [];
2731
2669
  const stateDefs = /* @__PURE__ */ new WeakMap();
2732
2670
  function classEnter(node) {
2733
- classStack.push(node);
2671
+ classEntries.push(node);
2734
2672
  }
2735
2673
  function classExit() {
2736
- const currentClass = classStack.pop();
2674
+ const currentClass = classEntries.pop();
2737
2675
  if (currentClass == null || !isClassComponent(currentClass)) {
2738
2676
  return;
2739
2677
  }
2740
- const className = O.map(AST11.getClassIdentifier(currentClass), (id) => id.name);
2741
- const [def, isUsed] = stateDefs.get(currentClass) ?? [O.none(), false];
2742
- if (O.isNone(def) || isUsed) {
2678
+ const className = AST11.getClassIdentifier(currentClass)?.name;
2679
+ const { node: defNode, isUsed } = stateDefs.get(currentClass) ?? {};
2680
+ if (!defNode || isUsed) {
2743
2681
  return;
2744
2682
  }
2745
2683
  context.report({
2746
2684
  messageId: "noUnusedState",
2747
- node: def.value,
2685
+ node: defNode,
2748
2686
  data: {
2749
- className: O.getOrElse(className, () => "Component")
2687
+ className: className ?? "Component"
2750
2688
  }
2751
2689
  });
2752
2690
  }
2753
2691
  function methodEnter(node) {
2754
- methodStack.push(node);
2755
- const currentClass = classStack.at(-1);
2692
+ methodEntries.push(node);
2693
+ const currentClass = classEntries.at(-1);
2756
2694
  if (currentClass == null || !isClassComponent(currentClass)) {
2757
2695
  return;
2758
2696
  }
2759
2697
  if (node.static) {
2760
2698
  if (isGetDerivedStateFromProps(node) && node.value.params.length > 1) {
2761
- const [def] = stateDefs.get(currentClass) ?? [O.none()];
2762
- stateDefs.set(currentClass, [def, true]);
2699
+ const defNode = stateDefs.get(currentClass)?.node;
2700
+ stateDefs.set(currentClass, { node: defNode, isUsed: true });
2763
2701
  }
2764
2702
  return;
2765
2703
  }
2766
- if (O.exists(getName4(node.key), (name2) => name2 === "state")) {
2767
- stateDefs.set(currentClass, [O.some(node.key), false]);
2704
+ if (getName4(node.key) === "state") {
2705
+ stateDefs.set(currentClass, { node: node.key, isUsed: false });
2768
2706
  }
2769
2707
  }
2770
2708
  function methodExit() {
2771
- methodStack.pop();
2709
+ methodEntries.pop();
2772
2710
  }
2773
2711
  function constructorEnter(node) {
2774
- constructorStack.push(node);
2712
+ constructorEntries.push(node);
2775
2713
  }
2776
2714
  function constructorExit() {
2777
- constructorStack.pop();
2715
+ constructorEntries.pop();
2778
2716
  }
2779
2717
  return {
2780
2718
  AssignmentExpression(node) {
2781
2719
  if (!isAssignmentToThisState2(node)) {
2782
2720
  return;
2783
2721
  }
2784
- const currentClass = classStack.at(-1);
2722
+ const currentClass = classEntries.at(-1);
2785
2723
  if (currentClass == null || !isClassComponent(currentClass)) {
2786
2724
  return;
2787
2725
  }
2788
- const currentConstructor = constructorStack.at(-1);
2726
+ const currentConstructor = constructorEntries.at(-1);
2789
2727
  if (currentConstructor == null || !currentClass.body.body.includes(currentConstructor)) {
2790
2728
  return;
2791
2729
  }
2792
- const [_, isUsed] = stateDefs.get(currentClass) ?? [O.none(), false];
2793
- stateDefs.set(currentClass, [O.some(node.left), isUsed]);
2730
+ const isUsed = stateDefs.get(currentClass)?.isUsed ?? false;
2731
+ stateDefs.set(currentClass, { node: node.left, isUsed });
2794
2732
  },
2795
2733
  ClassDeclaration: classEnter,
2796
2734
  "ClassDeclaration:exit": classExit,
@@ -2800,25 +2738,25 @@ var no_unused_state_default = createRule({
2800
2738
  if (!AST11.isThisExpression(node.object)) {
2801
2739
  return;
2802
2740
  }
2803
- if (!O.exists(getName4(node.property), (name2) => name2 === "state")) {
2741
+ if (getName4(node.property) !== "state") {
2804
2742
  return;
2805
2743
  }
2806
- const currentClass = classStack.at(-1);
2744
+ const currentClass = classEntries.at(-1);
2807
2745
  if (currentClass == null || !isClassComponent(currentClass)) {
2808
2746
  return;
2809
2747
  }
2810
- const currentMethod = methodStack.at(-1);
2748
+ const currentMethod = methodEntries.at(-1);
2811
2749
  if (currentMethod == null || currentMethod.static) {
2812
2750
  return;
2813
2751
  }
2814
- if (currentMethod === constructorStack.at(-1)) {
2752
+ if (currentMethod === constructorEntries.at(-1)) {
2815
2753
  return;
2816
2754
  }
2817
2755
  if (!currentClass.body.body.includes(currentMethod)) {
2818
2756
  return;
2819
2757
  }
2820
- const [def] = stateDefs.get(currentClass) ?? [O.none(), false];
2821
- stateDefs.set(currentClass, [def, true]);
2758
+ const defNode = stateDefs.get(currentClass)?.node;
2759
+ stateDefs.set(currentClass, { node: defNode, isUsed: true });
2822
2760
  },
2823
2761
  MethodDefinition: methodEnter,
2824
2762
  "MethodDefinition:exit": methodExit,
@@ -2827,15 +2765,15 @@ var no_unused_state_default = createRule({
2827
2765
  PropertyDefinition: methodEnter,
2828
2766
  "PropertyDefinition:exit": methodExit,
2829
2767
  VariableDeclarator(node) {
2830
- const currentClass = classStack.at(-1);
2768
+ const currentClass = classEntries.at(-1);
2831
2769
  if (currentClass == null || !isClassComponent(currentClass)) {
2832
2770
  return;
2833
2771
  }
2834
- const currentMethod = methodStack.at(-1);
2772
+ const currentMethod = methodEntries.at(-1);
2835
2773
  if (currentMethod == null || currentMethod.static) {
2836
2774
  return;
2837
2775
  }
2838
- if (currentMethod === constructorStack.at(-1)) {
2776
+ if (currentMethod === constructorEntries.at(-1)) {
2839
2777
  return;
2840
2778
  }
2841
2779
  if (!currentClass.body.body.includes(currentMethod)) {
@@ -2846,15 +2784,15 @@ var no_unused_state_default = createRule({
2846
2784
  }
2847
2785
  const hasState = node.id.properties.some((prop) => {
2848
2786
  if (prop.type === AST_NODE_TYPES.Property && AST11.isKeyLiteralLike(prop, prop.key)) {
2849
- return O.exists(getName4(prop.key), (name2) => name2 === "state");
2787
+ return getName4(prop.key) === "state";
2850
2788
  }
2851
2789
  return false;
2852
2790
  });
2853
2791
  if (!hasState) {
2854
2792
  return;
2855
2793
  }
2856
- const [def] = stateDefs.get(currentClass) ?? [O.none(), false];
2857
- stateDefs.set(currentClass, [def, true]);
2794
+ const defNode = stateDefs.get(currentClass)?.node;
2795
+ stateDefs.set(currentClass, { node: defNode, isUsed: true });
2858
2796
  }
2859
2797
  };
2860
2798
  },
@@ -2974,15 +2912,15 @@ var prefer_destructuring_assignment_default = createRule({
2974
2912
  }
2975
2913
  },
2976
2914
  "Program:exit"(node) {
2977
- const components = Array.from(ctx.getAllComponents(node).values());
2915
+ const components = [
2916
+ ...ctx.getAllComponents(node).values()
2917
+ ];
2978
2918
  function isFunctionComponent(block) {
2979
2919
  if (!AST11.isFunction(block)) {
2980
2920
  return false;
2981
2921
  }
2982
- return O.exists(
2983
- AST11.getFunctionIdentifier(block),
2984
- (id) => isComponentName(id.name) && components.some((component) => component.node === block)
2985
- );
2922
+ const id = AST11.getFunctionIdentifier(block);
2923
+ return !!id && isComponentName(id.name) && components.some((component) => component.node === block);
2986
2924
  }
2987
2925
  for (const [initialScope, memberExpression] of memberExpressionWithNames) {
2988
2926
  let scope = initialScope;
@@ -3111,7 +3049,7 @@ var prefer_read_only_props_default = createRule({
3111
3049
  ...listeners,
3112
3050
  "Program:exit"(node) {
3113
3051
  const components = ctx.getAllComponents(node);
3114
- for (const [_, component] of components) {
3052
+ for (const [, component] of components) {
3115
3053
  const [props] = component.node.params;
3116
3054
  if (props == null) {
3117
3055
  continue;
@@ -3147,24 +3085,23 @@ var prefer_shorthand_boolean_default = createRule({
3147
3085
  },
3148
3086
  name: RULE_NAME48,
3149
3087
  create(context) {
3150
- function getReportDescriptor(node) {
3151
- const { value } = node;
3152
- const propName = JSX7.getPropName(node);
3153
- const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
3154
- if (!hasValueTrue) {
3155
- return O.none();
3156
- }
3157
- return O.some({
3158
- messageId: "preferShorthandBoolean",
3159
- node,
3160
- data: {
3161
- propName
3162
- },
3163
- fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
3164
- });
3165
- }
3166
3088
  return {
3167
- JSXAttribute: F.flow(getReportDescriptor, O.map(context.report))
3089
+ JSXAttribute(node) {
3090
+ const { value } = node;
3091
+ const propName = JSX7.getPropName(node);
3092
+ const hasValueTrue = value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true;
3093
+ if (!hasValueTrue) {
3094
+ return;
3095
+ }
3096
+ context.report({
3097
+ messageId: "preferShorthandBoolean",
3098
+ node,
3099
+ data: {
3100
+ propName
3101
+ },
3102
+ fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
3103
+ });
3104
+ }
3168
3105
  };
3169
3106
  },
3170
3107
  defaultOptions: []
@@ -3189,31 +3126,32 @@ var prefer_shorthand_fragment_default = createRule({
3189
3126
  },
3190
3127
  name: RULE_NAME49,
3191
3128
  create(context) {
3192
- function getReportDescriptor(node) {
3193
- if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3194
- return O.none();
3195
- }
3196
- const hasAttributes = node.openingElement.attributes.length > 0;
3197
- if (hasAttributes) {
3198
- return O.none();
3199
- }
3200
- return O.some({
3201
- messageId: "preferShorthandFragment",
3202
- node,
3203
- fix: (fixer) => {
3204
- const { closingElement, openingElement } = node;
3205
- if (closingElement == null) {
3206
- return [];
3207
- }
3208
- return [
3209
- fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
3210
- fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
3211
- ];
3212
- }
3213
- });
3214
- }
3215
3129
  return {
3216
- JSXElement: F.flow(getReportDescriptor, O.map(context.report))
3130
+ JSXElement(node) {
3131
+ if (JSX7.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3132
+ return;
3133
+ }
3134
+ const hasAttributes = node.openingElement.attributes.length > 0;
3135
+ if (hasAttributes) {
3136
+ return;
3137
+ }
3138
+ context.report({
3139
+ messageId: "preferShorthandFragment",
3140
+ node,
3141
+ fix: (fixer) => {
3142
+ const { closingElement, openingElement } = node;
3143
+ if (closingElement == null) {
3144
+ return [];
3145
+ }
3146
+ return [
3147
+ // eslint-disable-next-line eslint-plugin/prefer-replace-text
3148
+ fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
3149
+ // eslint-disable-next-line eslint-plugin/prefer-replace-text
3150
+ fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
3151
+ ];
3152
+ }
3153
+ });
3154
+ }
3217
3155
  };
3218
3156
  },
3219
3157
  defaultOptions: []
@@ -3235,23 +3173,23 @@ var use_jsx_vars_default = createRule({
3235
3173
  },
3236
3174
  name: RULE_NAME50,
3237
3175
  create(context) {
3238
- function getName5(node) {
3239
- switch (node.type) {
3240
- case AST_NODE_TYPES.JSXIdentifier:
3241
- return O.some(node.name);
3242
- case AST_NODE_TYPES.JSXMemberExpression:
3243
- return getName5(node.object);
3244
- default:
3245
- return O.none();
3246
- }
3247
- }
3248
3176
  return {
3249
3177
  JSXOpeningElement(node) {
3250
- if (node.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) {
3251
- return;
3252
- }
3253
- for (const name2 of O.toArray(getName5(node.name))) {
3254
- context.sourceCode.markVariableAsUsed(name2, node);
3178
+ switch (node.name.type) {
3179
+ case AST_NODE_TYPES.JSXIdentifier: {
3180
+ if (/^[a-z]/u.test(node.name.name)) {
3181
+ return;
3182
+ }
3183
+ context.sourceCode.markVariableAsUsed(node.name.name, node);
3184
+ break;
3185
+ }
3186
+ case AST_NODE_TYPES.JSXMemberExpression: {
3187
+ const { object } = node.name;
3188
+ if (object.type === AST_NODE_TYPES.JSXIdentifier) {
3189
+ context.sourceCode.markVariableAsUsed(object.name, node);
3190
+ }
3191
+ break;
3192
+ }
3255
3193
  }
3256
3194
  }
3257
3195
  };