eslint-plugin-react-x 1.23.3-next.8 → 1.24.0-beta.1

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 +414 -478
  2. package/dist/index.mjs +414 -478
  3. package/package.json +13 -13
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var eff = require('@eslint-react/eff');
4
3
  var JSX7 = require('@eslint-react/jsx');
5
4
  var shared = require('@eslint-react/shared');
6
5
  var AST11 = require('@eslint-react/ast');
7
6
  var core = require('@eslint-react/core');
7
+ var eff = require('@eslint-react/eff');
8
8
  var types = require('@typescript-eslint/types');
9
9
  var tsPattern = require('ts-pattern');
10
10
  var compareVersions = require('compare-versions');
@@ -42,7 +42,7 @@ var ts__default = /*#__PURE__*/_interopDefault(ts);
42
42
 
43
43
  // package.json
44
44
  var name = "eslint-plugin-react-x";
45
- var version = "1.23.3-next.8";
45
+ var version = "1.24.0-beta.1";
46
46
  var createRule = shared.createRuleForPlugin("x");
47
47
 
48
48
  // src/rules/avoid-shorthand-boolean.ts
@@ -65,18 +65,19 @@ var avoid_shorthand_boolean_default = createRule({
65
65
  },
66
66
  name: RULE_NAME,
67
67
  create(context) {
68
- function getReportDescriptor(node) {
69
- return node.value != null ? eff.O.none() : eff.O.some({
70
- messageId: "avoidShorthandBoolean",
71
- node,
72
- data: {
73
- propName: JSX7__namespace.getPropName(node)
74
- },
75
- fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
76
- });
77
- }
78
68
  return {
79
- JSXAttribute: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
69
+ JSXAttribute(node) {
70
+ if (node.value === null) {
71
+ context.report({
72
+ messageId: "avoidShorthandBoolean",
73
+ node,
74
+ data: {
75
+ propName: JSX7__namespace.getPropName(node)
76
+ },
77
+ fix: (fixer) => fixer.insertTextAfter(node.name, `={true}`)
78
+ });
79
+ }
80
+ }
80
81
  };
81
82
  },
82
83
  defaultOptions: []
@@ -139,7 +140,7 @@ var ensure_forward_ref_using_ref_default = createRule({
139
140
  if (component == null || !AST11__namespace.isFunction(component)) {
140
141
  return;
141
142
  }
142
- const [_, ref] = component.params;
143
+ const ref = component.params[1];
143
144
  if (ref != null) {
144
145
  return;
145
146
  }
@@ -161,15 +162,15 @@ function getName(node) {
161
162
  return getName(node.expression);
162
163
  }
163
164
  if (node.type === types.AST_NODE_TYPES.Identifier || node.type === types.AST_NODE_TYPES.PrivateIdentifier) {
164
- return eff.O.some(node.name);
165
+ return node.name;
165
166
  }
166
167
  if (node.type === types.AST_NODE_TYPES.Literal) {
167
- return eff.O.some(String(node.value));
168
+ return String(node.value);
168
169
  }
169
170
  if (node.type === types.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
170
- return eff.O.fromNullable(node.quasis[0]?.value.raw);
171
+ return node.quasis[0]?.value.raw;
171
172
  }
172
- return eff.O.none();
173
+ return eff._;
173
174
  }
174
175
  var no_access_state_in_setstate_default = createRule({
175
176
  meta: {
@@ -188,89 +189,86 @@ var no_access_state_in_setstate_default = createRule({
188
189
  if (!context.sourceCode.text.includes("setState")) {
189
190
  return {};
190
191
  }
191
- const classStack = [];
192
- const methodStack = [];
193
- const setStateStack = [];
192
+ const classEntries = [];
193
+ const methodEntries = [];
194
+ const setStateEntries = [];
194
195
  return {
195
196
  CallExpression(node) {
196
197
  if (!core.isThisSetState(node)) {
197
198
  return;
198
199
  }
199
- setStateStack.push([node, false]);
200
+ setStateEntries.push([node, false]);
200
201
  },
201
202
  "CallExpression:exit"(node) {
202
203
  if (!core.isThisSetState(node)) {
203
204
  return;
204
205
  }
205
- setStateStack.pop();
206
+ setStateEntries.pop();
206
207
  },
207
208
  ClassDeclaration(node) {
208
- classStack.push([node, core.isClassComponent(node)]);
209
+ classEntries.push([node, core.isClassComponent(node)]);
209
210
  },
210
211
  "ClassDeclaration:exit"() {
211
- classStack.pop();
212
+ classEntries.pop();
212
213
  },
213
214
  ClassExpression(node) {
214
- classStack.push([node, core.isClassComponent(node)]);
215
+ classEntries.push([node, core.isClassComponent(node)]);
215
216
  },
216
217
  "ClassExpression:exit"() {
217
- classStack.pop();
218
+ classEntries.pop();
218
219
  },
219
220
  MemberExpression(node) {
220
221
  if (!AST11__namespace.isThisExpression(node.object)) {
221
222
  return;
222
223
  }
223
- const [currClass, isComponent] = classStack.at(-1) ?? [];
224
+ const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
224
225
  if (currClass == null || !isComponent) {
225
226
  return;
226
227
  }
227
- const [currMethod, isStatic] = methodStack.at(-1) ?? [];
228
+ const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
228
229
  if (currMethod == null || isStatic) {
229
230
  return;
230
231
  }
231
- const [setState, hasThisState] = setStateStack.at(-1) ?? [];
232
+ const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
232
233
  if (setState == null || hasThisState) {
233
234
  return;
234
235
  }
235
- if (!eff.O.exists(getName(node.property), (name2) => name2 === "state")) {
236
+ if (getName(node.property) !== "state") {
236
237
  return;
237
238
  }
238
239
  context.report({ messageId: "noAccessStateInSetstate", node });
239
240
  },
240
241
  MethodDefinition(node) {
241
- methodStack.push([node, node.static]);
242
+ methodEntries.push([node, node.static]);
242
243
  },
243
244
  "MethodDefinition:exit"() {
244
- methodStack.pop();
245
+ methodEntries.pop();
245
246
  },
246
247
  PropertyDefinition(node) {
247
- methodStack.push([node, node.static]);
248
+ methodEntries.push([node, node.static]);
248
249
  },
249
250
  "PropertyDefinition:exit"() {
250
- methodStack.pop();
251
+ methodEntries.pop();
251
252
  },
252
253
  VariableDeclarator(node) {
253
- const [currClass, isComponent] = classStack.at(-1) ?? [];
254
+ const [currClass, isComponent = false] = classEntries.at(-1) ?? [];
254
255
  if (currClass == null || !isComponent) {
255
256
  return;
256
257
  }
257
- const [currMethod, isStatic] = methodStack.at(-1) ?? [];
258
+ const [currMethod, isStatic = false] = methodEntries.at(-1) ?? [];
258
259
  if (currMethod == null || isStatic) {
259
260
  return;
260
261
  }
261
- const [setState, hasThisState] = setStateStack.at(-1) ?? [];
262
+ const [setState, hasThisState = false] = setStateEntries.at(-1) ?? [];
262
263
  if (setState == null || hasThisState) {
263
264
  return;
264
265
  }
265
266
  if (!(node.init != null && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern)) {
266
267
  return;
267
268
  }
268
- const hasState = node.id.properties.some((prop) => {
269
- if (prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key)) {
270
- return eff.O.exists(getName(prop.key), (name2) => name2 === "state");
271
- }
272
- return false;
273
- });
269
+ const hasState = node.id.properties.some(
270
+ (prop) => prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key) && getName(prop.key) === "state"
271
+ );
274
272
  if (!hasState) {
275
273
  return;
276
274
  }
@@ -323,32 +321,32 @@ function isUsingReactChildren(node, context) {
323
321
  function getMapIndexParamName(node, context) {
324
322
  const { callee } = node;
325
323
  if (callee.type !== types.AST_NODE_TYPES.MemberExpression) {
326
- return eff.O.none();
324
+ return eff._;
327
325
  }
328
326
  if (callee.property.type !== types.AST_NODE_TYPES.Identifier) {
329
- return eff.O.none();
327
+ return eff._;
330
328
  }
331
329
  const { name: name2 } = callee.property;
332
330
  if (!iteratorFunctionIndexParamPosition.has(name2)) {
333
- return eff.O.none();
331
+ return eff._;
334
332
  }
335
333
  const callbackArg = node.arguments[isUsingReactChildren(node, context) ? 1 : 0];
336
334
  if (callbackArg == null) {
337
- return eff.O.none();
335
+ return eff._;
338
336
  }
339
337
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(callbackArg)) {
340
- return eff.O.none();
338
+ return eff._;
341
339
  }
342
340
  const { params } = callbackArg;
343
341
  const indexParamPosition = iteratorFunctionIndexParamPosition.get(name2);
344
- if (eff.isNullable(indexParamPosition)) {
345
- return eff.O.none();
342
+ if (indexParamPosition == null) {
343
+ return eff._;
346
344
  }
347
345
  if (params.length < indexParamPosition + 1) {
348
- return eff.O.none();
346
+ return eff._;
349
347
  }
350
348
  const param = params.at(indexParamPosition);
351
- return param != null && "name" in param ? eff.O.some(param.name) : eff.O.none();
349
+ return param != null && "name" in param ? param.name : eff._;
352
350
  }
353
351
  var no_array_index_key_default = createRule({
354
352
  meta: {
@@ -366,7 +364,7 @@ var no_array_index_key_default = createRule({
366
364
  create(context) {
367
365
  const indexParamNames = [];
368
366
  function isArrayIndex(node) {
369
- return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some(eff.O.exists((name2) => name2 === node.name));
367
+ return node.type === types.AST_NODE_TYPES.Identifier && indexParamNames.some((name2) => name2 != null && name2 === node.name);
370
368
  }
371
369
  function isCreateOrCloneElementCall(node) {
372
370
  return core.isCreateElementCall(node, context) || core.isCloneElementCall(node, context);
@@ -375,7 +373,7 @@ var no_array_index_key_default = createRule({
375
373
  switch (node.type) {
376
374
  // key={bar}
377
375
  case types.AST_NODE_TYPES.Identifier: {
378
- if (indexParamNames.some(eff.O.exists((name2) => name2 === node.name))) {
376
+ if (indexParamNames.some((name2) => name2 != null && name2 === node.name)) {
379
377
  return [{
380
378
  messageId: "noArrayIndexKey",
381
379
  node
@@ -429,7 +427,7 @@ var no_array_index_key_default = createRule({
429
427
  if (!isCreateOrCloneElementCall(node)) {
430
428
  return;
431
429
  }
432
- const [_, props] = node.arguments;
430
+ const [, props] = node.arguments;
433
431
  if (props?.type !== types.AST_NODE_TYPES.ObjectExpression) {
434
432
  return;
435
433
  }
@@ -612,10 +610,17 @@ var no_children_prop_default = createRule({
612
610
  create(context) {
613
611
  return {
614
612
  JSXElement(node) {
615
- const initialScope = context.sourceCode.getScope(node);
616
- const prop = JSX7__namespace.getProp(node.openingElement.attributes, "children", initialScope);
617
- const reportDescriptor = eff.O.map(prop, (prop2) => ({ messageId: "noChildrenProp", node: prop2 }));
618
- eff.O.map(reportDescriptor, context.report);
613
+ const prop = JSX7__namespace.getProp(
614
+ "children",
615
+ context.sourceCode.getScope(node),
616
+ node.openingElement.attributes
617
+ );
618
+ if (prop != null) {
619
+ context.report({
620
+ messageId: "noChildrenProp",
621
+ node: prop
622
+ });
623
+ }
619
624
  }
620
625
  };
621
626
  },
@@ -684,7 +689,7 @@ var no_class_component_default = createRule({
684
689
  ...listeners,
685
690
  "Program:exit"(node) {
686
691
  const components = ctx.getAllComponents(node);
687
- for (const { name: name2, node: component } of components.values()) {
692
+ for (const { name: name2 = "anonymous", node: component } of components.values()) {
688
693
  if (component.body.body.some((m) => isComponentDidCatch(m) || isGetDerivedStateFromError(m))) {
689
694
  continue;
690
695
  }
@@ -693,7 +698,7 @@ var no_class_component_default = createRule({
693
698
  node: component,
694
699
  data: {
695
700
  // eslint-disable-next-line eslint-plugin/no-unused-placeholders
696
- name: eff.O.getOrElse(eff.F.constant("anonymous"))(name2)
701
+ name: name2
697
702
  }
698
703
  });
699
704
  }
@@ -759,22 +764,21 @@ var no_comment_textnodes_default = createRule({
759
764
  const rawValue = context.sourceCode.getText(node);
760
765
  return /^\s*\/(?:\/|\*)/mu.test(rawValue);
761
766
  }
762
- const getReportDescriptor = (node) => {
767
+ const visitorFunction = (node) => {
763
768
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(node.parent)) {
764
- return eff.O.none();
769
+ return;
765
770
  }
766
771
  if (!hasCommentLike(node)) {
767
- return eff.O.none();
772
+ return;
768
773
  }
769
774
  if (!node.parent.type.includes("JSX")) {
770
- return eff.O.none();
775
+ return;
771
776
  }
772
- return eff.O.some({
777
+ context.report({
773
778
  messageId: "noCommentTextnodes",
774
779
  node
775
780
  });
776
781
  };
777
- const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
778
782
  return {
779
783
  JSXText: visitorFunction,
780
784
  Literal: visitorFunction
@@ -800,20 +804,22 @@ var no_complex_conditional_rendering_default = createRule({
800
804
  },
801
805
  name: RULE_NAME15,
802
806
  create(context) {
803
- function getReportDescriptor(node) {
807
+ const visitorFunction = (node) => {
804
808
  const jsxExpContainer = node.parent?.parent;
805
809
  if (!AST11__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer)(jsxExpContainer)) {
806
- return eff.O.none();
810
+ return;
807
811
  }
808
812
  if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.JSXElement, types.AST_NODE_TYPES.JSXFragment])(jsxExpContainer.parent)) {
809
- return eff.O.none();
813
+ return;
810
814
  }
811
815
  if (!jsxExpContainer.parent.children.includes(jsxExpContainer)) {
812
- return eff.O.none();
816
+ return;
813
817
  }
814
- return eff.O.some({ messageId: "noComplexConditionalRendering", node: jsxExpContainer });
815
- }
816
- const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report), eff.F.constVoid);
818
+ context.report({
819
+ messageId: "noComplexConditionalRendering",
820
+ node: jsxExpContainer
821
+ });
822
+ };
817
823
  return {
818
824
  "JSXExpressionContainer > ConditionalExpression > ConditionalExpression": visitorFunction,
819
825
  "JSXExpressionContainer > ConditionalExpression > LogicalExpression": visitorFunction,
@@ -1057,13 +1063,9 @@ var no_create_ref_default = createRule({
1057
1063
  create(context) {
1058
1064
  return {
1059
1065
  CallExpression(node) {
1060
- if (!core.isCreateRefCall(node, context)) {
1061
- return;
1062
- }
1063
- if (eff.O.isSome(AST11__namespace.findParentNode(node, core.isClassComponent))) {
1064
- return;
1066
+ if (core.isCreateRefCall(node, context) && AST11__namespace.findParentNode(node, core.isClassComponent) == null) {
1067
+ context.report({ messageId: "noCreateRef", node });
1065
1068
  }
1066
- context.report({ messageId: "noCreateRef", node });
1067
1069
  }
1068
1070
  };
1069
1071
  },
@@ -1105,14 +1107,10 @@ var no_default_props_default = createRule({
1105
1107
  if (!core.isComponentName(object.name)) {
1106
1108
  return;
1107
1109
  }
1108
- const isComponent = eff.F.pipe(
1109
- VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node)),
1110
- eff.O.flatMap(VAR__namespace.getVariableNode(0)),
1111
- eff.O.exists((n) => AST11__namespace.isFunction(n) || core.isClassComponent(n))
1112
- );
1113
- if (!isComponent) {
1114
- return;
1115
- }
1110
+ const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
1111
+ const variableNode = VAR__namespace.getVariableNode(variable, 0);
1112
+ if (variableNode == null) return;
1113
+ if (!AST11__namespace.isFunction(variableNode) && !core.isClassComponent(variableNode)) return;
1116
1114
  context.report({ messageId: "noDefaultProps", node: property });
1117
1115
  },
1118
1116
  PropertyDefinition(node) {
@@ -1137,19 +1135,19 @@ function getName2(node) {
1137
1135
  return getName2(node.expression);
1138
1136
  }
1139
1137
  if (node.type === types.AST_NODE_TYPES.Identifier || node.type === types.AST_NODE_TYPES.PrivateIdentifier) {
1140
- return eff.O.some(node.name);
1138
+ return node.name;
1141
1139
  }
1142
1140
  if (node.type === types.AST_NODE_TYPES.Literal) {
1143
- return eff.O.some(String(node.value));
1141
+ return node.value?.toString();
1144
1142
  }
1145
1143
  if (node.type === types.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
1146
- return eff.O.fromNullable(node.quasis[0]?.value.raw);
1144
+ return node.quasis[0]?.value.raw;
1147
1145
  }
1148
- return eff.O.none();
1146
+ return eff._;
1149
1147
  }
1150
1148
  function isAssignmentToThisState(node) {
1151
1149
  const { left } = node;
1152
- return left.type === types.AST_NODE_TYPES.MemberExpression && AST11__namespace.isThisExpression(left.object) && eff.O.exists(getName2(left.property), (name2) => name2 === "state");
1150
+ return left.type === types.AST_NODE_TYPES.MemberExpression && AST11__namespace.isThisExpression(left.object) && getName2(left.property) === "state";
1153
1151
  }
1154
1152
  function isConstructorFunction(node) {
1155
1153
  return AST11__namespace.isOneOf([types.AST_NODE_TYPES.FunctionDeclaration, types.AST_NODE_TYPES.FunctionExpression])(node) && AST11__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node.parent) && node.parent.key.type === types.AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
@@ -1168,31 +1166,26 @@ var no_direct_mutation_state_default = createRule({
1168
1166
  },
1169
1167
  name: RULE_NAME22,
1170
1168
  create(context) {
1171
- function getReportDescriptor(node) {
1172
- if (!isAssignmentToThisState(node)) {
1173
- return eff.O.none();
1174
- }
1175
- return eff.F.pipe(
1176
- eff.O.Do,
1177
- eff.O.bind("parentClass", () => AST11__namespace.findParentNodeGuard(
1169
+ return {
1170
+ AssignmentExpression(node) {
1171
+ if (!isAssignmentToThisState(node)) {
1172
+ return;
1173
+ }
1174
+ const parentClass = AST11__namespace.findParentNodeGuard(
1178
1175
  node,
1179
1176
  AST11__namespace.isOneOf([
1180
1177
  types.AST_NODE_TYPES.ClassDeclaration,
1181
1178
  types.AST_NODE_TYPES.ClassExpression
1182
1179
  ])
1183
- )),
1184
- eff.O.bind("parentConstructor", () => AST11__namespace.findParentNodeGuard(node, isConstructorFunction)),
1185
- eff.O.filter(
1186
- ({ parentClass, parentConstructor }) => core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== parentConstructor
1187
- ),
1188
- eff.O.map(() => ({
1189
- messageId: "noDirectMutationState",
1190
- node
1191
- }))
1192
- );
1193
- }
1194
- return {
1195
- AssignmentExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
1180
+ );
1181
+ if (parentClass == null) return;
1182
+ if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== AST11__namespace.findParentNodeGuard(node, isConstructorFunction)) {
1183
+ context.report({
1184
+ messageId: "noDirectMutationState",
1185
+ node
1186
+ });
1187
+ }
1188
+ }
1196
1189
  };
1197
1190
  },
1198
1191
  defaultOptions: []
@@ -1223,7 +1216,7 @@ var no_duplicate_jsx_props_default = createRule({
1223
1216
  continue;
1224
1217
  }
1225
1218
  const name2 = attr.name.name;
1226
- if (!eff.isString(name2)) {
1219
+ if (typeof name2 !== "string") {
1227
1220
  continue;
1228
1221
  }
1229
1222
  if (!props.includes(name2)) {
@@ -1287,16 +1280,11 @@ var no_duplicate_key_default = createRule({
1287
1280
  break;
1288
1281
  }
1289
1282
  default: {
1290
- const mbEntry = eff.F.pipe(
1291
- eff.O.Do,
1292
- eff.O.bind("call", () => AST11__namespace.findParentNodeGuard(jsxElement, AST11__namespace.isMapCallLoose)),
1293
- eff.O.bind("iter", ({ call: call2 }) => AST11__namespace.findParentNodeStop(jsxElement, call2, AST11__namespace.isFunction)),
1294
- eff.O.bind("arg0", ({ call: call2 }) => eff.O.fromNullable(call2.arguments[0]))
1295
- );
1296
- if (eff.O.isNone(mbEntry)) {
1297
- return;
1298
- }
1299
- const { arg0, call, iter } = mbEntry.value;
1283
+ const call = AST11__namespace.findParentNodeGuard(jsxElement, AST11__namespace.isMapCallLoose);
1284
+ const iter = AST11__namespace.findParentNode(jsxElement, (n) => n === call || AST11__namespace.isFunction(n));
1285
+ if (!AST11__namespace.isFunction(iter)) return;
1286
+ const arg0 = call?.arguments[0];
1287
+ if (call == null || arg0 == null) return;
1300
1288
  if (AST11__namespace.unwrapTypeExpression(arg0) !== iter) {
1301
1289
  return;
1302
1290
  }
@@ -1397,21 +1385,19 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
1397
1385
  if (arg0 == null) {
1398
1386
  return [];
1399
1387
  }
1400
- const fixedArg0Text = tsPattern.match(arg0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => eff.O.some(`...${n.name}`)).with({ type: types.AST_NODE_TYPES.ObjectPattern }, (n) => eff.O.some(n.properties.map(getText).join(", "))).otherwise(eff.O.none);
1401
- const fixedArg1Text = tsPattern.match(arg1).with(tsPattern.P.nullish, () => eff.O.some("ref")).with({ type: types.AST_NODE_TYPES.Identifier, name: "ref" }, () => eff.O.some("ref")).with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.not("ref") }, (n) => eff.O.some(`ref: ${n.name}`)).otherwise(eff.O.none);
1402
- if (eff.O.isNone(fixedArg0Text) || eff.O.isNone(fixedArg1Text)) {
1388
+ const fixedArg0Text = tsPattern.match(arg0).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => `...${n.name}`).with({ type: types.AST_NODE_TYPES.ObjectPattern }, (n) => n.properties.map(getText).join(", ")).otherwise(() => eff._);
1389
+ const fixedArg1Text = tsPattern.match(arg1).with(tsPattern.P.nullish, () => "ref").with({ type: types.AST_NODE_TYPES.Identifier, name: "ref" }, () => "ref").with({ type: types.AST_NODE_TYPES.Identifier, name: tsPattern.P.not("ref") }, (n) => `ref: ${n.name}`).otherwise(() => eff._);
1390
+ if (fixedArg0Text == null || fixedArg1Text == null) {
1403
1391
  return [];
1404
1392
  }
1405
- const fixedPropsText = fixedArg0Text.value;
1406
- const fixedRefText = fixedArg1Text.value;
1407
1393
  if (typeArg0 == null || typeArg1 == null) {
1408
1394
  return [
1409
1395
  fixer.replaceText(
1410
1396
  arg0,
1411
1397
  [
1412
1398
  "{",
1413
- fixedRefText + ",",
1414
- fixedPropsText,
1399
+ fixedArg1Text + ",",
1400
+ fixedArg0Text,
1415
1401
  "}"
1416
1402
  ].join(" ")
1417
1403
  ),
@@ -1423,8 +1409,8 @@ function getComponentPropsFixes(node, typeArguments, fixer, context) {
1423
1409
  arg0,
1424
1410
  [
1425
1411
  "{",
1426
- fixedRefText + ",",
1427
- fixedPropsText,
1412
+ fixedArg1Text + ",",
1413
+ fixedArg0Text,
1428
1414
  "}:",
1429
1415
  getText(typeArg1),
1430
1416
  "&",
@@ -1455,17 +1441,17 @@ var no_implicit_key_default = createRule({
1455
1441
  },
1456
1442
  name: RULE_NAME26,
1457
1443
  create(context) {
1458
- function getReportDescriptor(node) {
1459
- const initialScope = context.sourceCode.getScope(node);
1460
- const keyPropFound = JSX7__namespace.findPropInAttributes(node.attributes, initialScope)("key");
1461
- const keyPropOnElement = node.attributes.some((n) => AST11__namespace.is(types.AST_NODE_TYPES.JSXAttribute)(n) && n.name.name === "key");
1462
- if (eff.O.isSome(keyPropFound) && !keyPropOnElement) {
1463
- return eff.O.some({ messageId: "noImplicitKey", node: keyPropFound.value });
1464
- }
1465
- return eff.O.none();
1466
- }
1467
1444
  return {
1468
- JSXOpeningElement: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
1445
+ JSXOpeningElement(node) {
1446
+ const initialScope = context.sourceCode.getScope(node);
1447
+ const keyPropFound = JSX7__namespace.findPropInAttributes("key", initialScope, node.attributes);
1448
+ const keyPropOnElement = node.attributes.some(
1449
+ (n) => n.type === types.AST_NODE_TYPES.JSXAttribute && n.name.type === types.AST_NODE_TYPES.JSXIdentifier && n.name.name === "key"
1450
+ );
1451
+ if (keyPropFound != null && !keyPropOnElement) {
1452
+ context.report({ messageId: "noImplicitKey", node: keyPropFound });
1453
+ }
1454
+ }
1469
1455
  };
1470
1456
  },
1471
1457
  defaultOptions: []
@@ -1511,11 +1497,12 @@ function inspectVariantTypes(types) {
1511
1497
  const booleans = types.filter(tsHelpers.isBooleanType);
1512
1498
  switch (true) {
1513
1499
  case (booleans.length === 1 && booleans[0] != null): {
1514
- const [first] = booleans;
1515
- const evaluated = eff.F.pipe(
1516
- tsPattern.match(first).when(tsApiUtils.isTrueLiteralType, () => eff.O.some("truthy boolean")).when(tsApiUtils.isFalseLiteralType, () => eff.O.some("falsy boolean")).otherwise(eff.O.none)
1517
- );
1518
- eff.O.map(evaluated, (v) => variantTypes.add(v));
1500
+ const first = booleans[0];
1501
+ if (tsApiUtils.isTrueLiteralType(first)) {
1502
+ variantTypes.add("truthy boolean");
1503
+ } else if (tsApiUtils.isFalseLiteralType(first)) {
1504
+ variantTypes.add("falsy boolean");
1505
+ }
1519
1506
  break;
1520
1507
  }
1521
1508
  case booleans.length === 2: {
@@ -1525,17 +1512,17 @@ function inspectVariantTypes(types) {
1525
1512
  }
1526
1513
  const strings = types.filter(tsHelpers.isStringType);
1527
1514
  if (strings.length > 0) {
1528
- const evaluated = tsPattern.match(strings).when((types2) => types2.every(tsHelpers.isTruthyStringType), eff.F.constant("truthy string")).when((types2) => types2.every(tsHelpers.isFalsyStringType), eff.F.constant("falsy string")).otherwise(eff.F.constant("string"));
1515
+ const evaluated = tsPattern.match(strings).when((types2) => types2.every(tsHelpers.isTruthyStringType), () => "truthy string").when((types2) => types2.every(tsHelpers.isFalsyStringType), () => "falsy string").otherwise(() => "string");
1529
1516
  variantTypes.add(evaluated);
1530
1517
  }
1531
1518
  const bigints = types.filter(tsHelpers.isBigIntType);
1532
1519
  if (bigints.length > 0) {
1533
- const evaluated = tsPattern.match(bigints).when((types2) => types2.every(tsHelpers.isTruthyBigIntType), eff.F.constant("truthy bigint")).when((types2) => types2.every(tsHelpers.isFalsyBigIntType), eff.F.constant("falsy bigint")).otherwise(eff.F.constant("bigint"));
1520
+ const evaluated = tsPattern.match(bigints).when((types2) => types2.every(tsHelpers.isTruthyBigIntType), () => "truthy bigint").when((types2) => types2.every(tsHelpers.isFalsyBigIntType), () => "falsy bigint").otherwise(() => "bigint");
1534
1521
  variantTypes.add(evaluated);
1535
1522
  }
1536
1523
  const numbers = types.filter(tsHelpers.isNumberType);
1537
1524
  if (numbers.length > 0) {
1538
- const evaluated = tsPattern.match(numbers).when((types2) => types2.every(tsHelpers.isTruthyNumberType), eff.F.constant("truthy number")).when((types2) => types2.every(tsHelpers.isFalsyNumberType), eff.F.constant("falsy number")).otherwise(eff.F.constant("number"));
1525
+ const evaluated = tsPattern.match(numbers).when((types2) => types2.every(tsHelpers.isTruthyNumberType), () => "truthy number").when((types2) => types2.every(tsHelpers.isFalsyNumberType), () => "falsy number").otherwise(() => "number");
1539
1526
  variantTypes.add(evaluated);
1540
1527
  }
1541
1528
  if (types.some(tsHelpers.isEnumType)) {
@@ -1553,19 +1540,15 @@ function inspectVariantTypes(types) {
1553
1540
  return variantTypes;
1554
1541
  }
1555
1542
  function isInitExpression(node) {
1543
+ if (node == null) return false;
1556
1544
  return node.type !== types.AST_NODE_TYPES.VariableDeclaration;
1557
1545
  }
1558
- function getVariableInitExpression(at) {
1559
- return (variable) => {
1560
- return eff.F.pipe(
1561
- eff.O.some(variable),
1562
- eff.O.flatMapNullable((v) => v.defs.at(at)),
1563
- eff.O.flatMap(
1564
- (d) => "init" in d.node ? eff.O.fromNullable(d.node.init) : eff.O.none()
1565
- ),
1566
- eff.O.filter(isInitExpression)
1567
- );
1568
- };
1546
+ function getVariableInitExpression(variable, at) {
1547
+ const def = variable?.defs[at];
1548
+ if (def?.node == null || !("init" in def.node)) {
1549
+ return eff._;
1550
+ }
1551
+ return isInitExpression(def.node.init) ? def.node.init : eff._;
1569
1552
  }
1570
1553
  var no_leaked_conditional_rendering_default = createRule({
1571
1554
  meta: {
@@ -1599,19 +1582,20 @@ var no_leaked_conditional_rendering_default = createRule({
1599
1582
  ];
1600
1583
  const services = utils.ESLintUtils.getParserServices(context, false);
1601
1584
  function getReportDescriptor(node) {
1602
- return tsPattern.match(node).when(AST11__namespace.isJSX, eff.O.none).with({ type: types.AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1585
+ if (node == null) return eff._;
1586
+ return tsPattern.match(node).when(AST11__namespace.isJSX, () => eff._).with({ type: types.AST_NODE_TYPES.LogicalExpression, operator: "&&" }, ({ left, right }) => {
1603
1587
  const isLeftUnaryNot = left.type === types.AST_NODE_TYPES.UnaryExpression && left.operator === "!";
1604
1588
  if (isLeftUnaryNot) {
1605
1589
  return getReportDescriptor(right);
1606
1590
  }
1607
1591
  const initialScope = context.sourceCode.getScope(left);
1608
- const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || eff.O.exists(VAR__namespace.getStaticValue(left, initialScope), (v) => v === "NaN");
1592
+ const isLeftNan = left.type === types.AST_NODE_TYPES.Identifier && left.name === "NaN" || VAR__namespace.toResolved({ kind: "lazy", node: left, initialScope }).value === "NaN";
1609
1593
  if (isLeftNan) {
1610
- return eff.O.some({
1594
+ return {
1611
1595
  messageId: "noLeakedConditionalRendering",
1612
1596
  node: left,
1613
1597
  data: { value: context.sourceCode.getText(left) }
1614
- });
1598
+ };
1615
1599
  }
1616
1600
  const leftType = typeUtils.getConstrainedTypeAtLocation(services, left);
1617
1601
  const leftTypeVariants = inspectVariantTypes(tsApiUtils.unionTypeParts(leftType));
@@ -1619,22 +1603,24 @@ var no_leaked_conditional_rendering_default = createRule({
1619
1603
  if (isLeftValid) {
1620
1604
  return getReportDescriptor(right);
1621
1605
  }
1622
- return eff.O.some({
1606
+ return {
1623
1607
  messageId: "noLeakedConditionalRendering",
1624
1608
  node: left,
1625
1609
  data: { value: context.sourceCode.getText(left) }
1626
- });
1610
+ };
1627
1611
  }).with({ type: types.AST_NODE_TYPES.ConditionalExpression }, ({ alternate, consequent }) => {
1628
- return eff.O.orElse(getReportDescriptor(consequent), () => getReportDescriptor(alternate));
1612
+ return getReportDescriptor(consequent) ?? getReportDescriptor(alternate);
1629
1613
  }).with({ type: types.AST_NODE_TYPES.Identifier }, (n) => {
1630
- return eff.F.pipe(
1631
- VAR__namespace.findVariable(n.name, context.sourceCode.getScope(n)),
1632
- eff.O.flatMap(getVariableInitExpression(0)),
1633
- eff.O.flatMap(getReportDescriptor)
1634
- );
1635
- }).otherwise(eff.O.none);
1614
+ const variable = VAR__namespace.findVariable(n.name, context.sourceCode.getScope(n));
1615
+ const initExpression = getVariableInitExpression(variable, 0);
1616
+ return getReportDescriptor(initExpression);
1617
+ }).otherwise(() => eff._);
1636
1618
  }
1637
- const visitorFunction = eff.F.flow(getReportDescriptor, eff.O.map(context.report));
1619
+ const visitorFunction = (node) => {
1620
+ const descriptor = getReportDescriptor(node);
1621
+ if (descriptor == null) return;
1622
+ context.report(descriptor);
1623
+ };
1638
1624
  return {
1639
1625
  "JSXExpressionContainer > ConditionalExpression": visitorFunction,
1640
1626
  "JSXExpressionContainer > LogicalExpression": visitorFunction
@@ -1670,13 +1656,13 @@ var no_missing_component_display_name_default = createRule({
1670
1656
  const components = ctx.getAllComponents(node);
1671
1657
  for (const { node: node2, displayName, flag } of components.values()) {
1672
1658
  const isMemoOrForwardRef = (flag & (core.ERFunctionComponentFlag.ForwardRef | core.ERFunctionComponentFlag.Memo)) > 0n;
1673
- if (eff.O.isSome(AST11__namespace.getFunctionIdentifier(node2))) {
1659
+ if (AST11__namespace.getFunctionIdentifier(node2) != null) {
1674
1660
  continue;
1675
1661
  }
1676
1662
  if (!isMemoOrForwardRef) {
1677
1663
  continue;
1678
1664
  }
1679
- if (eff.O.isNone(displayName)) {
1665
+ if (displayName == null) {
1680
1666
  context.report({
1681
1667
  messageId: "noMissingComponentDisplayName",
1682
1668
  node: node2
@@ -1712,51 +1698,55 @@ var no_missing_key_default = createRule({
1712
1698
  switch (node.type) {
1713
1699
  case types.AST_NODE_TYPES.JSXElement: {
1714
1700
  const initialScope = context.sourceCode.getScope(node);
1715
- if (!JSX7__namespace.hasProp(node.openingElement.attributes, "key", initialScope)) {
1716
- return eff.O.some({
1701
+ if (!JSX7__namespace.hasProp("key", initialScope, node.openingElement.attributes)) {
1702
+ return {
1717
1703
  messageId: "noMissingKey",
1718
1704
  node
1719
- });
1705
+ };
1720
1706
  }
1721
- return eff.O.none();
1707
+ return null;
1722
1708
  }
1723
1709
  case types.AST_NODE_TYPES.JSXFragment: {
1724
- return eff.O.some({
1710
+ return {
1725
1711
  messageId: "noMissingKeyWithFragment",
1726
1712
  node
1727
- });
1713
+ };
1728
1714
  }
1729
1715
  default:
1730
- return eff.O.none();
1716
+ return null;
1731
1717
  }
1732
1718
  }
1733
1719
  function checkExpression(node) {
1734
1720
  switch (node.type) {
1735
1721
  case types.AST_NODE_TYPES.ConditionalExpression:
1736
- if (!("consequent" in node)) {
1737
- return eff.O.none();
1722
+ if ("consequent" in node) {
1723
+ return checkIteratorElement(node.consequent) ?? checkIteratorElement(node.alternate);
1738
1724
  }
1739
- return eff.O.orElse(checkIteratorElement(node.consequent), () => checkIteratorElement(node.alternate));
1725
+ return null;
1740
1726
  case types.AST_NODE_TYPES.JSXElement:
1741
1727
  case types.AST_NODE_TYPES.JSXFragment:
1742
1728
  return checkIteratorElement(node);
1743
1729
  case types.AST_NODE_TYPES.LogicalExpression:
1744
- if (!("left" in node)) {
1745
- return eff.O.none();
1730
+ if ("left" in node) {
1731
+ return checkIteratorElement(node.left) ?? checkIteratorElement(node.right);
1746
1732
  }
1747
- return eff.O.orElse(checkIteratorElement(node.left), () => checkIteratorElement(node.right));
1733
+ return null;
1748
1734
  default:
1749
- return eff.O.none();
1735
+ return null;
1750
1736
  }
1751
1737
  }
1752
1738
  function checkBlockStatement(node) {
1753
- return AST11__namespace.getNestedReturnStatements(node).reduce((acc, statement) => {
1739
+ const descriptors = [];
1740
+ for (const statement of AST11__namespace.getNestedReturnStatements(node)) {
1754
1741
  if (statement.argument == null) {
1755
- return acc;
1742
+ continue;
1756
1743
  }
1757
- const mbDescriptor = checkIteratorElement(statement.argument);
1758
- return eff.O.isNone(mbDescriptor) ? acc : [...acc, mbDescriptor.value];
1759
- }, []);
1744
+ const descriptor = checkIteratorElement(statement.argument);
1745
+ if (descriptor != null) {
1746
+ descriptors.push(descriptor);
1747
+ }
1748
+ }
1749
+ return descriptors;
1760
1750
  }
1761
1751
  return {
1762
1752
  ArrayExpression(node) {
@@ -1769,7 +1759,7 @@ var no_missing_key_default = createRule({
1769
1759
  }
1770
1760
  const initialScope = context.sourceCode.getScope(node);
1771
1761
  for (const element of elements) {
1772
- if (!JSX7__namespace.hasProp(element.openingElement.attributes, "key", initialScope)) {
1762
+ if (!JSX7__namespace.hasProp("key", initialScope, element.openingElement.attributes)) {
1773
1763
  context.report({
1774
1764
  messageId: "noMissingKey",
1775
1765
  node: element
@@ -1782,30 +1772,24 @@ var no_missing_key_default = createRule({
1782
1772
  if (state.isWithinChildrenToArray) {
1783
1773
  return;
1784
1774
  }
1785
- const isMapCall = AST11__namespace.isMapCallLoose(node);
1786
- const isArrayFromCall = tsPattern.isMatching({
1787
- type: types.AST_NODE_TYPES.CallExpression,
1788
- callee: {
1789
- type: types.AST_NODE_TYPES.MemberExpression,
1790
- property: {
1791
- name: "from"
1792
- }
1793
- }
1794
- }, node);
1795
- if (!isMapCall && !isArrayFromCall) {
1775
+ const isMapCallLike = AST11__namespace.isMapCallLoose(node);
1776
+ if (!isMapCallLike && !isArrayFromCall(node)) {
1796
1777
  return;
1797
1778
  }
1798
- const fn = node.arguments[isMapCall ? 0 : 1];
1799
- if (!AST11__namespace.isOneOf([types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression])(fn)) {
1779
+ const fn = node.arguments[isMapCallLike ? 0 : 1];
1780
+ if (fn?.type !== types.AST_NODE_TYPES.ArrowFunctionExpression && fn?.type !== types.AST_NODE_TYPES.FunctionExpression) {
1800
1781
  return;
1801
1782
  }
1802
1783
  if (fn.body.type === types.AST_NODE_TYPES.BlockStatement) {
1803
- for (const descriptor of checkBlockStatement(fn.body)) {
1804
- context.report(descriptor);
1784
+ for (const descriptor2 of checkBlockStatement(fn.body)) {
1785
+ context.report(descriptor2);
1805
1786
  }
1806
1787
  return;
1807
1788
  }
1808
- eff.O.map(checkExpression(fn.body), context.report);
1789
+ const descriptor = checkExpression(fn.body);
1790
+ if (descriptor != null) {
1791
+ context.report(descriptor);
1792
+ }
1809
1793
  },
1810
1794
  "CallExpression:exit"(node) {
1811
1795
  if (!core.isChildrenToArrayCall(node, context)) {
@@ -1828,6 +1812,9 @@ var no_missing_key_default = createRule({
1828
1812
  },
1829
1813
  defaultOptions: []
1830
1814
  });
1815
+ function isArrayFromCall(node) {
1816
+ return node.type === types.AST_NODE_TYPES.CallExpression && node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "from";
1817
+ }
1831
1818
  var RULE_NAME30 = "no-nested-components";
1832
1819
  var RULE_FEATURES30 = [
1833
1820
  "CHK"
@@ -1866,16 +1853,15 @@ var no_nested_components_default = createRule({
1866
1853
  const isClassComponent11 = (node2) => {
1867
1854
  return AST11__namespace.isClass(node2) && classComponents.some((component) => component.node === node2);
1868
1855
  };
1869
- for (const { name: componentName, node: component } of functionComponents) {
1856
+ for (const { name: name2, node: component } of functionComponents) {
1870
1857
  if (core.isDirectValueOfRenderPropertyLoose(component)) {
1871
1858
  continue;
1872
1859
  }
1873
- if (eff.O.isNone(componentName)) {
1860
+ if (name2 === eff._) {
1874
1861
  continue;
1875
1862
  }
1876
- const name2 = componentName.value;
1877
1863
  const isInsideProperty = component.parent.type === types.AST_NODE_TYPES.Property;
1878
- const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || eff.O.isSome(JSX7__namespace.findParentProp(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer));
1864
+ const isInsideJSXPropValue = component.parent.type === types.AST_NODE_TYPES.JSXAttribute || JSX7__namespace.findParentProp(node, (n) => n.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) != null;
1879
1865
  if (isInsideJSXPropValue) {
1880
1866
  if (!core.isDeclaredInRenderPropLoose(component)) {
1881
1867
  context.report({
@@ -1898,13 +1884,8 @@ var no_nested_components_default = createRule({
1898
1884
  });
1899
1885
  continue;
1900
1886
  }
1901
- const isParnetComponentNotDirectValueOfRenderProperty = eff.O.exists(
1902
- AST11__namespace.findParentNodeGuard(
1903
- component,
1904
- isFunctionComponent
1905
- ),
1906
- eff.not(core.isDirectValueOfRenderPropertyLoose)
1907
- );
1887
+ const parentComponent = AST11__namespace.findParentNodeGuard(component, isFunctionComponent);
1888
+ const isParnetComponentNotDirectValueOfRenderProperty = parentComponent != null && !core.isDirectValueOfRenderPropertyLoose(parentComponent);
1908
1889
  if (isParnetComponentNotDirectValueOfRenderProperty) {
1909
1890
  context.report({
1910
1891
  messageId: isInsideProperty ? "nestedComponentInProps" : "nestedComponent",
@@ -1925,15 +1906,15 @@ var no_nested_components_default = createRule({
1925
1906
  });
1926
1907
  }
1927
1908
  }
1928
- for (const { name: name2, node: component } of classComponents) {
1929
- if (eff.O.isNone(AST11__namespace.findParentNode(component, eff.or(isClassComponent11, isFunctionComponent)))) {
1909
+ for (const { name: name2 = "unknown", node: component } of classComponents) {
1910
+ if (AST11__namespace.findParentNode(component, (n) => isClassComponent11(n) || isFunctionComponent(n)) == null) {
1930
1911
  continue;
1931
1912
  }
1932
1913
  context.report({
1933
1914
  messageId: "nestedComponent",
1934
1915
  node: component,
1935
1916
  data: {
1936
- name: eff.O.getOrElse(() => "unknown")(name2)
1917
+ name: name2
1937
1918
  }
1938
1919
  });
1939
1920
  }
@@ -1978,15 +1959,11 @@ var no_prop_types_default = createRule({
1978
1959
  if (!core.isComponentName(object.name)) {
1979
1960
  return;
1980
1961
  }
1981
- const isComponent = eff.F.pipe(
1982
- VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node)),
1983
- eff.O.flatMap(VAR__namespace.getVariableNode(0)),
1984
- eff.O.exists((n) => AST11__namespace.isFunction(n) || core.isClassComponent(n))
1985
- );
1986
- if (!isComponent) {
1987
- return;
1962
+ const variable = VAR__namespace.findVariable(object.name, context.sourceCode.getScope(node));
1963
+ const variableNode = VAR__namespace.getVariableNode(variable, 0);
1964
+ if (variableNode != null && (AST11__namespace.isFunction(variableNode) || core.isClassComponent(variableNode))) {
1965
+ context.report({ messageId: "noPropTypes", node: property });
1988
1966
  }
1989
- context.report({ messageId: "noPropTypes", node: property });
1990
1967
  },
1991
1968
  PropertyDefinition(node) {
1992
1969
  if (!core.isClassComponent(node.parent.parent)) {
@@ -2030,7 +2007,7 @@ var no_redundant_should_component_update_default = createRule({
2030
2007
  ...listeners,
2031
2008
  "Program:exit"(node) {
2032
2009
  const components = ctx.getAllComponents(node);
2033
- for (const { name: name2, node: component, flag } of components.values()) {
2010
+ for (const { name: name2 = "PureComponent", node: component, flag } of components.values()) {
2034
2011
  if ((flag & core.ERClassComponentFlag.PureComponent) === 0n) {
2035
2012
  continue;
2036
2013
  }
@@ -2041,7 +2018,7 @@ var no_redundant_should_component_update_default = createRule({
2041
2018
  messageId: "noRedundantShouldComponentUpdate",
2042
2019
  node: member,
2043
2020
  data: {
2044
- componentName: eff.O.getOrElse(() => "PureComponent")(name2)
2021
+ componentName: name2
2045
2022
  }
2046
2023
  });
2047
2024
  }
@@ -2076,32 +2053,23 @@ var no_set_state_in_component_did_mount_default = createRule({
2076
2053
  if (!context.sourceCode.text.includes("componentDidMount")) {
2077
2054
  return {};
2078
2055
  }
2079
- function getReportDescriptor(node) {
2080
- if (!core.isThisSetState(node)) {
2081
- return eff.O.none();
2082
- }
2083
- return eff.F.pipe(
2084
- eff.O.Do,
2085
- eff.O.bind("clazz", () => AST11__namespace.findParentNodeGuard(node, core.isClassComponent)),
2086
- eff.O.bind("method", ({ clazz }) => AST11__namespace.findParentNodeStop(node, clazz, isComponentDidMount)),
2087
- eff.O.bind("methodScope", ({ method }) => eff.O.some(context.sourceCode.getScope(method))),
2088
- eff.O.bind("upperScope", () => eff.O.fromNullable(context.sourceCode.getScope(node).upper)),
2089
- eff.O.filter(
2090
- ({
2091
- clazz,
2092
- method,
2093
- methodScope,
2094
- upperScope
2095
- }) => method.parent === clazz.body && upperScope === methodScope
2096
- ),
2097
- eff.O.map(() => ({
2098
- messageId: "noSetStateInComponentDidMount",
2099
- node
2100
- }))
2101
- );
2102
- }
2103
2056
  return {
2104
- CallExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
2057
+ CallExpression(node) {
2058
+ if (!core.isThisSetState(node)) {
2059
+ return;
2060
+ }
2061
+ const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2062
+ const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidMount(n));
2063
+ if (clazz == null || method == null || method === clazz) return;
2064
+ const methodScope = context.sourceCode.getScope(method);
2065
+ const upperScope = context.sourceCode.getScope(node).upper;
2066
+ if (method.parent === clazz.body && upperScope === methodScope) {
2067
+ context.report({
2068
+ messageId: "noSetStateInComponentDidMount",
2069
+ node
2070
+ });
2071
+ }
2072
+ }
2105
2073
  };
2106
2074
  },
2107
2075
  defaultOptions: []
@@ -2130,32 +2098,23 @@ var no_set_state_in_component_did_update_default = createRule({
2130
2098
  if (!context.sourceCode.text.includes("componentDidUpdate")) {
2131
2099
  return {};
2132
2100
  }
2133
- function getReportDescriptor(node) {
2134
- if (!core.isThisSetState(node)) {
2135
- return eff.O.none();
2136
- }
2137
- return eff.F.pipe(
2138
- eff.O.Do,
2139
- eff.O.bind("clazz", () => AST11__namespace.findParentNodeGuard(node, core.isClassComponent)),
2140
- eff.O.bind("method", ({ clazz }) => AST11__namespace.findParentNodeStop(node, clazz, isComponentDidUpdate)),
2141
- eff.O.bind("methodScope", ({ method }) => eff.O.some(context.sourceCode.getScope(method))),
2142
- eff.O.bind("upperScope", () => eff.O.fromNullable(context.sourceCode.getScope(node).upper)),
2143
- eff.O.filter(
2144
- ({
2145
- clazz,
2146
- method,
2147
- methodScope,
2148
- upperScope
2149
- }) => method.parent === clazz.body && upperScope === methodScope
2150
- ),
2151
- eff.O.map(() => ({
2152
- messageId: "noSetStateInComponentDidUpdate",
2153
- node
2154
- }))
2155
- );
2156
- }
2157
2101
  return {
2158
- CallExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
2102
+ CallExpression(node) {
2103
+ if (!core.isThisSetState(node)) {
2104
+ return;
2105
+ }
2106
+ const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2107
+ const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentDidUpdate(n));
2108
+ if (clazz == null || method == null || method === clazz) return;
2109
+ const methodScope = context.sourceCode.getScope(method);
2110
+ const upperScope = context.sourceCode.getScope(node).upper;
2111
+ if (method.parent === clazz.body && upperScope === methodScope) {
2112
+ context.report({
2113
+ messageId: "noSetStateInComponentDidUpdate",
2114
+ node
2115
+ });
2116
+ }
2117
+ }
2159
2118
  };
2160
2119
  },
2161
2120
  defaultOptions: []
@@ -2184,32 +2143,23 @@ var no_set_state_in_component_will_update_default = createRule({
2184
2143
  if (!context.sourceCode.text.includes("componentWillUpdate")) {
2185
2144
  return {};
2186
2145
  }
2187
- function getReportDescriptor(node) {
2188
- if (!core.isThisSetState(node)) {
2189
- return eff.O.none();
2190
- }
2191
- return eff.F.pipe(
2192
- eff.O.Do,
2193
- eff.O.bind("clazz", () => AST11__namespace.findParentNodeGuard(node, core.isClassComponent)),
2194
- eff.O.bind("method", ({ clazz }) => AST11__namespace.findParentNodeStop(node, clazz, isComponentWillUpdate3)),
2195
- eff.O.bind("methodScope", ({ method }) => eff.O.some(context.sourceCode.getScope(method))),
2196
- eff.O.bind("upperScope", () => eff.O.fromNullable(context.sourceCode.getScope(node).upper)),
2197
- eff.O.filter(
2198
- ({
2199
- clazz,
2200
- method,
2201
- methodScope,
2202
- upperScope
2203
- }) => method.parent === clazz.body && upperScope === methodScope
2204
- ),
2205
- eff.O.map(() => ({
2206
- messageId: "noSetStateInComponentWillUpdate",
2207
- node
2208
- }))
2209
- );
2210
- }
2211
2146
  return {
2212
- CallExpression: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
2147
+ CallExpression(node) {
2148
+ if (!core.isThisSetState(node)) {
2149
+ return;
2150
+ }
2151
+ const clazz = AST11__namespace.findParentNodeGuard(node, core.isClassComponent);
2152
+ const method = AST11__namespace.findParentNode(node, (n) => n === clazz || isComponentWillUpdate3(n));
2153
+ if (clazz == null || method == null || method === clazz) return;
2154
+ const methodScope = context.sourceCode.getScope(method);
2155
+ const upperScope = context.sourceCode.getScope(node).upper;
2156
+ if (method.parent === clazz.body && upperScope === methodScope) {
2157
+ context.report({
2158
+ messageId: "noSetStateInComponentWillUpdate",
2159
+ node
2160
+ });
2161
+ }
2162
+ }
2213
2163
  };
2214
2164
  },
2215
2165
  defaultOptions: []
@@ -2219,14 +2169,14 @@ var RULE_FEATURES36 = [
2219
2169
  "CHK"
2220
2170
  ];
2221
2171
  function containsStringLiteral({ value }) {
2222
- return value?.type === types.AST_NODE_TYPES.Literal && eff.isString(value.value);
2172
+ return value?.type === types.AST_NODE_TYPES.Literal && typeof value.value === "string";
2223
2173
  }
2224
2174
  function containsStringExpressionContainer({ value }) {
2225
2175
  if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) {
2226
2176
  return false;
2227
2177
  }
2228
2178
  if (value.expression.type === types.AST_NODE_TYPES.Literal) {
2229
- return eff.isString(value.expression.value);
2179
+ return typeof value.expression.value === "string";
2230
2180
  }
2231
2181
  return value.expression.type === types.AST_NODE_TYPES.TemplateLiteral;
2232
2182
  }
@@ -2427,39 +2377,28 @@ var no_unstable_context_value_default = createRule({
2427
2377
  if (openingElementName.property.name !== "Provider") {
2428
2378
  return;
2429
2379
  }
2430
- eff.F.pipe(
2431
- eff.O.Do,
2432
- eff.O.bind("function", ctx.getCurrentFunction),
2433
- eff.O.bind("attribute", () => eff.O.fromNullable(
2434
- node.attributes.find((attribute) => {
2435
- return attribute.type === types.AST_NODE_TYPES.JSXAttribute && attribute.name.name === "value";
2436
- })
2437
- )),
2438
- eff.O.bind("value", ({ attribute }) => "value" in attribute ? eff.O.some(attribute.value) : eff.O.none()),
2439
- eff.O.bind("valueExpression", ({ value }) => value?.type === types.AST_NODE_TYPES.JSXExpressionContainer ? eff.O.some(value.expression) : eff.O.none()),
2440
- eff.O.bind("construction", ({ valueExpression }) => {
2441
- const initialScope = context.sourceCode.getScope(valueExpression);
2442
- return eff.O.some(VAR__namespace.getValueConstruction(valueExpression, initialScope));
2443
- }),
2444
- eff.O.map((vc) => {
2445
- if (vc.construction.kind === "None") {
2446
- return;
2447
- }
2448
- if (core.isReactHookCall(vc.construction.node)) {
2449
- return;
2450
- }
2451
- const prevs = constructions.get(vc.function.node) ?? [];
2452
- constructions.set(vc.function.node, [...prevs, vc.construction]);
2453
- })
2380
+ const functionEntry = ctx.getCurrentEntry();
2381
+ if (functionEntry == null) return;
2382
+ const attribute = node.attributes.find(
2383
+ (attribute2) => attribute2.type === types.AST_NODE_TYPES.JSXAttribute && attribute2.name.name === "value"
2454
2384
  );
2385
+ if (attribute == null || !("value" in attribute)) return;
2386
+ const value = attribute.value;
2387
+ if (value?.type !== types.AST_NODE_TYPES.JSXExpressionContainer) return;
2388
+ const valueExpression = value.expression;
2389
+ const initialScope = context.sourceCode.getScope(valueExpression);
2390
+ const construction = VAR__namespace.getValueConstruction(valueExpression, initialScope);
2391
+ if (construction == null) return;
2392
+ if (core.isReactHookCall(construction.node)) {
2393
+ return;
2394
+ }
2395
+ const prevs = constructions.get(functionEntry.node) ?? [];
2396
+ constructions.set(functionEntry.node, [...prevs, construction]);
2455
2397
  },
2456
2398
  "Program:exit"(node) {
2457
2399
  const components = ctx.getAllComponents(node).values();
2458
2400
  for (const { node: component } of components) {
2459
2401
  for (const construction of constructions.get(component) ?? []) {
2460
- if (construction.kind === "None") {
2461
- continue;
2462
- }
2463
2402
  const { kind, node: constructionNode } = construction;
2464
2403
  const messageId = kind.startsWith("Function") ? "noUnstableContextValueWithFunction" : "noUnstableContextValueWithIdentifier";
2465
2404
  context.report({
@@ -2521,7 +2460,7 @@ var no_unstable_default_props_default = createRule({
2521
2460
  initialScope,
2522
2461
  VAR__namespace.ValueConstructionHint.StrictCallExpression
2523
2462
  );
2524
- if (construction.kind === "None") {
2463
+ if (construction == null) {
2525
2464
  continue;
2526
2465
  }
2527
2466
  if (core.isReactHookCall(construction.node)) {
@@ -2539,13 +2478,10 @@ var no_unstable_default_props_default = createRule({
2539
2478
  }
2540
2479
  },
2541
2480
  "VariableDeclarator[id.type='ObjectPattern'][init.type='Identifier']"(node) {
2542
- const mbEntry = ctx.getCurrentFunction();
2543
- if (eff.O.isNone(mbEntry)) {
2544
- return;
2545
- }
2546
- const entry = mbEntry.value;
2547
- const prevs = declarators.get(entry.node) ?? [];
2548
- declarators.set(entry.node, [...prevs, node]);
2481
+ const functionEntry = ctx.getCurrentEntry();
2482
+ if (functionEntry == null) return;
2483
+ const prevs = declarators.get(functionEntry.node) ?? [];
2484
+ declarators.set(functionEntry.node, [...prevs, node]);
2549
2485
  }
2550
2486
  };
2551
2487
  },
@@ -2577,15 +2513,15 @@ function getName3(node) {
2577
2513
  return getName3(node.expression);
2578
2514
  }
2579
2515
  if (node.type === types.AST_NODE_TYPES.Identifier || node.type === types.AST_NODE_TYPES.PrivateIdentifier) {
2580
- return eff.O.some(node.name);
2516
+ return node.name;
2581
2517
  }
2582
2518
  if (node.type === types.AST_NODE_TYPES.Literal) {
2583
- return eff.O.some(String(node.value));
2519
+ return node.value?.toString();
2584
2520
  }
2585
2521
  if (node.type === types.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
2586
- return eff.O.fromNullable(node.quasis[0]?.value.raw);
2522
+ return node.quasis[0]?.value.raw;
2587
2523
  }
2588
- return eff.O.none();
2524
+ return eff._;
2589
2525
  }
2590
2526
  var no_unused_class_component_members_default = createRule({
2591
2527
  meta: {
@@ -2601,12 +2537,12 @@ var no_unused_class_component_members_default = createRule({
2601
2537
  },
2602
2538
  name: RULE_NAME42,
2603
2539
  create(context) {
2604
- const classStack = [];
2605
- const methodStack = [];
2540
+ const classEntries = [];
2541
+ const methodEntries = [];
2606
2542
  const propertyDefs = /* @__PURE__ */ new WeakMap();
2607
2543
  const propertyUsages = /* @__PURE__ */ new WeakMap();
2608
2544
  function classEnter(node) {
2609
- classStack.push(node);
2545
+ classEntries.push(node);
2610
2546
  if (!core.isClassComponent(node)) {
2611
2547
  return;
2612
2548
  }
@@ -2614,37 +2550,37 @@ var no_unused_class_component_members_default = createRule({
2614
2550
  propertyUsages.set(node, /* @__PURE__ */ new Set());
2615
2551
  }
2616
2552
  function classExit() {
2617
- const currentClass = classStack.pop();
2553
+ const currentClass = classEntries.pop();
2618
2554
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2619
2555
  return;
2620
2556
  }
2621
- const className = eff.O.map(AST11__namespace.getClassIdentifier(currentClass), (id) => id.name);
2557
+ const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
2622
2558
  const defs = propertyDefs.get(currentClass);
2623
2559
  const usages = propertyUsages.get(currentClass);
2624
2560
  if (defs == null) {
2625
2561
  return;
2626
2562
  }
2627
2563
  for (const def of defs) {
2628
- const name2 = getName3(def);
2629
- if (eff.O.isNone(name2)) {
2564
+ const methodName = getName3(def);
2565
+ if (methodName == null) {
2630
2566
  continue;
2631
2567
  }
2632
- if (usages?.has(name2.value) || LIFECYCLE_METHODS.has(name2.value)) {
2568
+ if (usages?.has(methodName) || LIFECYCLE_METHODS.has(methodName)) {
2633
2569
  continue;
2634
2570
  }
2635
2571
  context.report({
2636
2572
  messageId: "noUnusedClassComponentMembers",
2637
2573
  node: def,
2638
2574
  data: {
2639
- className: eff.O.getOrElse(className, () => "Component"),
2640
- methodName: name2.value
2575
+ className: className ?? "Component",
2576
+ methodName
2641
2577
  }
2642
2578
  });
2643
2579
  }
2644
2580
  }
2645
2581
  function methodEnter(node) {
2646
- methodStack.push(node);
2647
- const currentClass = classStack.at(-1);
2582
+ methodEntries.push(node);
2583
+ const currentClass = classEntries.at(-1);
2648
2584
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2649
2585
  return;
2650
2586
  }
@@ -2656,7 +2592,7 @@ var no_unused_class_component_members_default = createRule({
2656
2592
  }
2657
2593
  }
2658
2594
  function methodExit() {
2659
- methodStack.pop();
2595
+ methodEntries.pop();
2660
2596
  }
2661
2597
  return {
2662
2598
  ClassDeclaration: classEnter,
@@ -2664,8 +2600,8 @@ var no_unused_class_component_members_default = createRule({
2664
2600
  ClassExpression: classEnter,
2665
2601
  "ClassExpression:exit": classExit,
2666
2602
  MemberExpression(node) {
2667
- const currentClass = classStack.at(-1);
2668
- const currentMethod = methodStack.at(-1);
2603
+ const currentClass = classEntries.at(-1);
2604
+ const currentMethod = methodEntries.at(-1);
2669
2605
  if (currentClass == null || currentMethod == null) {
2670
2606
  return;
2671
2607
  }
@@ -2679,15 +2615,18 @@ var no_unused_class_component_members_default = createRule({
2679
2615
  propertyDefs.get(currentClass)?.add(node.property);
2680
2616
  return;
2681
2617
  }
2682
- eff.O.map(getName3(node.property), (name2) => propertyUsages.get(currentClass)?.add(name2));
2618
+ const propertyName = getName3(node.property);
2619
+ if (propertyName != null) {
2620
+ propertyUsages.get(currentClass)?.add(propertyName);
2621
+ }
2683
2622
  },
2684
2623
  MethodDefinition: methodEnter,
2685
2624
  "MethodDefinition:exit": methodExit,
2686
2625
  PropertyDefinition: methodEnter,
2687
2626
  "PropertyDefinition:exit": methodExit,
2688
2627
  VariableDeclarator(node) {
2689
- const currentClass = classStack.at(-1);
2690
- const currentMethod = methodStack.at(-1);
2628
+ const currentClass = classEntries.at(-1);
2629
+ const currentMethod = methodEntries.at(-1);
2691
2630
  if (currentClass == null || currentMethod == null) {
2692
2631
  return;
2693
2632
  }
@@ -2697,10 +2636,9 @@ var no_unused_class_component_members_default = createRule({
2697
2636
  if (node.init != null && AST11__namespace.isThisExpression(node.init) && node.id.type === types.AST_NODE_TYPES.ObjectPattern) {
2698
2637
  for (const prop of node.id.properties) {
2699
2638
  if (prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key)) {
2700
- const mbName = getName3(prop.key);
2701
- if (eff.O.isSome(mbName)) {
2702
- const name2 = mbName.value;
2703
- propertyUsages.get(currentClass)?.add(name2);
2639
+ const keyName = getName3(prop.key);
2640
+ if (keyName != null) {
2641
+ propertyUsages.get(currentClass)?.add(keyName);
2704
2642
  }
2705
2643
  }
2706
2644
  }
@@ -2719,19 +2657,19 @@ function getName4(node) {
2719
2657
  return getName4(node.expression);
2720
2658
  }
2721
2659
  if (node.type === types.AST_NODE_TYPES.Identifier || node.type === types.AST_NODE_TYPES.PrivateIdentifier) {
2722
- return eff.O.some(node.name);
2660
+ return node.name;
2723
2661
  }
2724
2662
  if (node.type === types.AST_NODE_TYPES.Literal) {
2725
- return eff.O.some(String(node.value));
2663
+ return String(node.value);
2726
2664
  }
2727
2665
  if (node.type === types.AST_NODE_TYPES.TemplateLiteral && node.expressions.length === 0) {
2728
- return eff.O.fromNullable(node.quasis[0]?.value.raw);
2666
+ return node.quasis[0]?.value.raw;
2729
2667
  }
2730
- return eff.O.none();
2668
+ return eff._;
2731
2669
  }
2732
2670
  function isAssignmentToThisState2(node) {
2733
2671
  const { left } = node;
2734
- return left.type === types.AST_NODE_TYPES.MemberExpression && AST11__namespace.isThisExpression(left.object) && eff.O.exists(getName4(left.property), (name2) => name2 === "state");
2672
+ return left.type === types.AST_NODE_TYPES.MemberExpression && AST11__namespace.isThisExpression(left.object) && getName4(left.property) === "state";
2735
2673
  }
2736
2674
  var isGetDerivedStateFromProps = tsPattern.isMatching({
2737
2675
  key: {
@@ -2756,72 +2694,72 @@ var no_unused_state_default = createRule({
2756
2694
  },
2757
2695
  name: RULE_NAME43,
2758
2696
  create(context) {
2759
- const classStack = [];
2760
- const methodStack = [];
2761
- const constructorStack = [];
2697
+ const classEntries = [];
2698
+ const methodEntries = [];
2699
+ const constructorEntries = [];
2762
2700
  const stateDefs = /* @__PURE__ */ new WeakMap();
2763
2701
  function classEnter(node) {
2764
- classStack.push(node);
2702
+ classEntries.push(node);
2765
2703
  }
2766
2704
  function classExit() {
2767
- const currentClass = classStack.pop();
2705
+ const currentClass = classEntries.pop();
2768
2706
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2769
2707
  return;
2770
2708
  }
2771
- const className = eff.O.map(AST11__namespace.getClassIdentifier(currentClass), (id) => id.name);
2772
- const [def, isUsed] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2773
- if (eff.O.isNone(def) || isUsed) {
2709
+ const className = AST11__namespace.getClassIdentifier(currentClass)?.name;
2710
+ const { node: defNode, isUsed = false } = stateDefs.get(currentClass) ?? {};
2711
+ if (defNode == null || isUsed) {
2774
2712
  return;
2775
2713
  }
2776
2714
  context.report({
2777
2715
  messageId: "noUnusedState",
2778
- node: def.value,
2716
+ node: defNode,
2779
2717
  data: {
2780
- className: eff.O.getOrElse(className, () => "Component")
2718
+ className: className ?? "Component"
2781
2719
  }
2782
2720
  });
2783
2721
  }
2784
2722
  function methodEnter(node) {
2785
- methodStack.push(node);
2786
- const currentClass = classStack.at(-1);
2723
+ methodEntries.push(node);
2724
+ const currentClass = classEntries.at(-1);
2787
2725
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2788
2726
  return;
2789
2727
  }
2790
2728
  if (node.static) {
2791
2729
  if (isGetDerivedStateFromProps(node) && node.value.params.length > 1) {
2792
- const [def] = stateDefs.get(currentClass) ?? [eff.O.none()];
2793
- stateDefs.set(currentClass, [def, true]);
2730
+ const defNode = stateDefs.get(currentClass)?.node;
2731
+ stateDefs.set(currentClass, { node: defNode, isUsed: true });
2794
2732
  }
2795
2733
  return;
2796
2734
  }
2797
- if (eff.O.exists(getName4(node.key), (name2) => name2 === "state")) {
2798
- stateDefs.set(currentClass, [eff.O.some(node.key), false]);
2735
+ if (getName4(node.key) === "state") {
2736
+ stateDefs.set(currentClass, { node: node.key, isUsed: false });
2799
2737
  }
2800
2738
  }
2801
2739
  function methodExit() {
2802
- methodStack.pop();
2740
+ methodEntries.pop();
2803
2741
  }
2804
2742
  function constructorEnter(node) {
2805
- constructorStack.push(node);
2743
+ constructorEntries.push(node);
2806
2744
  }
2807
2745
  function constructorExit() {
2808
- constructorStack.pop();
2746
+ constructorEntries.pop();
2809
2747
  }
2810
2748
  return {
2811
2749
  AssignmentExpression(node) {
2812
2750
  if (!isAssignmentToThisState2(node)) {
2813
2751
  return;
2814
2752
  }
2815
- const currentClass = classStack.at(-1);
2753
+ const currentClass = classEntries.at(-1);
2816
2754
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2817
2755
  return;
2818
2756
  }
2819
- const currentConstructor = constructorStack.at(-1);
2757
+ const currentConstructor = constructorEntries.at(-1);
2820
2758
  if (currentConstructor == null || !currentClass.body.body.includes(currentConstructor)) {
2821
2759
  return;
2822
2760
  }
2823
- const [_, isUsed] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2824
- stateDefs.set(currentClass, [eff.O.some(node.left), isUsed]);
2761
+ const isUsed = stateDefs.get(currentClass)?.isUsed ?? false;
2762
+ stateDefs.set(currentClass, { node: node.left, isUsed });
2825
2763
  },
2826
2764
  ClassDeclaration: classEnter,
2827
2765
  "ClassDeclaration:exit": classExit,
@@ -2831,25 +2769,25 @@ var no_unused_state_default = createRule({
2831
2769
  if (!AST11__namespace.isThisExpression(node.object)) {
2832
2770
  return;
2833
2771
  }
2834
- if (!eff.O.exists(getName4(node.property), (name2) => name2 === "state")) {
2772
+ if (getName4(node.property) !== "state") {
2835
2773
  return;
2836
2774
  }
2837
- const currentClass = classStack.at(-1);
2775
+ const currentClass = classEntries.at(-1);
2838
2776
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2839
2777
  return;
2840
2778
  }
2841
- const currentMethod = methodStack.at(-1);
2779
+ const currentMethod = methodEntries.at(-1);
2842
2780
  if (currentMethod == null || currentMethod.static) {
2843
2781
  return;
2844
2782
  }
2845
- if (currentMethod === constructorStack.at(-1)) {
2783
+ if (currentMethod === constructorEntries.at(-1)) {
2846
2784
  return;
2847
2785
  }
2848
2786
  if (!currentClass.body.body.includes(currentMethod)) {
2849
2787
  return;
2850
2788
  }
2851
- const [def] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2852
- stateDefs.set(currentClass, [def, true]);
2789
+ const defNode = stateDefs.get(currentClass)?.node;
2790
+ stateDefs.set(currentClass, { node: defNode, isUsed: true });
2853
2791
  },
2854
2792
  MethodDefinition: methodEnter,
2855
2793
  "MethodDefinition:exit": methodExit,
@@ -2858,15 +2796,15 @@ var no_unused_state_default = createRule({
2858
2796
  PropertyDefinition: methodEnter,
2859
2797
  "PropertyDefinition:exit": methodExit,
2860
2798
  VariableDeclarator(node) {
2861
- const currentClass = classStack.at(-1);
2799
+ const currentClass = classEntries.at(-1);
2862
2800
  if (currentClass == null || !core.isClassComponent(currentClass)) {
2863
2801
  return;
2864
2802
  }
2865
- const currentMethod = methodStack.at(-1);
2803
+ const currentMethod = methodEntries.at(-1);
2866
2804
  if (currentMethod == null || currentMethod.static) {
2867
2805
  return;
2868
2806
  }
2869
- if (currentMethod === constructorStack.at(-1)) {
2807
+ if (currentMethod === constructorEntries.at(-1)) {
2870
2808
  return;
2871
2809
  }
2872
2810
  if (!currentClass.body.body.includes(currentMethod)) {
@@ -2877,15 +2815,15 @@ var no_unused_state_default = createRule({
2877
2815
  }
2878
2816
  const hasState = node.id.properties.some((prop) => {
2879
2817
  if (prop.type === types.AST_NODE_TYPES.Property && AST11__namespace.isKeyLiteralLike(prop, prop.key)) {
2880
- return eff.O.exists(getName4(prop.key), (name2) => name2 === "state");
2818
+ return getName4(prop.key) === "state";
2881
2819
  }
2882
2820
  return false;
2883
2821
  });
2884
2822
  if (!hasState) {
2885
2823
  return;
2886
2824
  }
2887
- const [def] = stateDefs.get(currentClass) ?? [eff.O.none(), false];
2888
- stateDefs.set(currentClass, [def, true]);
2825
+ const defNode = stateDefs.get(currentClass)?.node;
2826
+ stateDefs.set(currentClass, { node: defNode, isUsed: true });
2889
2827
  }
2890
2828
  };
2891
2829
  },
@@ -3012,10 +2950,8 @@ var prefer_destructuring_assignment_default = createRule({
3012
2950
  if (!AST11__namespace.isFunction(block)) {
3013
2951
  return false;
3014
2952
  }
3015
- return eff.O.exists(
3016
- AST11__namespace.getFunctionIdentifier(block),
3017
- (id) => core.isComponentName(id.name) && components.some((component) => component.node === block)
3018
- );
2953
+ const id = AST11__namespace.getFunctionIdentifier(block);
2954
+ return id != null && core.isComponentName(id.name) && components.some((component) => component.node === block);
3019
2955
  }
3020
2956
  for (const [initialScope, memberExpression] of memberExpressionWithNames) {
3021
2957
  let scope = initialScope;
@@ -3144,7 +3080,7 @@ var prefer_read_only_props_default = createRule({
3144
3080
  ...listeners,
3145
3081
  "Program:exit"(node) {
3146
3082
  const components = ctx.getAllComponents(node);
3147
- for (const [_, component] of components) {
3083
+ for (const [, component] of components) {
3148
3084
  const [props] = component.node.params;
3149
3085
  if (props == null) {
3150
3086
  continue;
@@ -3180,24 +3116,23 @@ var prefer_shorthand_boolean_default = createRule({
3180
3116
  },
3181
3117
  name: RULE_NAME48,
3182
3118
  create(context) {
3183
- function getReportDescriptor(node) {
3184
- const { value } = node;
3185
- const propName = JSX7__namespace.getPropName(node);
3186
- const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
3187
- if (!hasValueTrue) {
3188
- return eff.O.none();
3189
- }
3190
- return eff.O.some({
3191
- messageId: "preferShorthandBoolean",
3192
- node,
3193
- data: {
3194
- propName
3195
- },
3196
- fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
3197
- });
3198
- }
3199
3119
  return {
3200
- JSXAttribute: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
3120
+ JSXAttribute(node) {
3121
+ const { value } = node;
3122
+ const propName = JSX7__namespace.getPropName(node);
3123
+ const hasValueTrue = value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === types.AST_NODE_TYPES.Literal && value.expression.value === true;
3124
+ if (!hasValueTrue) {
3125
+ return;
3126
+ }
3127
+ context.report({
3128
+ messageId: "preferShorthandBoolean",
3129
+ node,
3130
+ data: {
3131
+ propName
3132
+ },
3133
+ fix: (fixer) => fixer.removeRange([node.name.range[1], value.range[1]])
3134
+ });
3135
+ }
3201
3136
  };
3202
3137
  },
3203
3138
  defaultOptions: []
@@ -3222,31 +3157,32 @@ var prefer_shorthand_fragment_default = createRule({
3222
3157
  },
3223
3158
  name: RULE_NAME49,
3224
3159
  create(context) {
3225
- function getReportDescriptor(node) {
3226
- if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3227
- return eff.O.none();
3228
- }
3229
- const hasAttributes = node.openingElement.attributes.length > 0;
3230
- if (hasAttributes) {
3231
- return eff.O.none();
3232
- }
3233
- return eff.O.some({
3234
- messageId: "preferShorthandFragment",
3235
- node,
3236
- fix: (fixer) => {
3237
- const { closingElement, openingElement } = node;
3238
- if (closingElement == null) {
3239
- return [];
3240
- }
3241
- return [
3242
- fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
3243
- fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
3244
- ];
3245
- }
3246
- });
3247
- }
3248
3160
  return {
3249
- JSXElement: eff.F.flow(getReportDescriptor, eff.O.map(context.report))
3161
+ JSXElement(node) {
3162
+ if (JSX7__namespace.getElementName(node.openingElement).split(".").at(-1) !== "Fragment") {
3163
+ return;
3164
+ }
3165
+ const hasAttributes = node.openingElement.attributes.length > 0;
3166
+ if (hasAttributes) {
3167
+ return;
3168
+ }
3169
+ context.report({
3170
+ messageId: "preferShorthandFragment",
3171
+ node,
3172
+ fix: (fixer) => {
3173
+ const { closingElement, openingElement } = node;
3174
+ if (closingElement == null) {
3175
+ return [];
3176
+ }
3177
+ return [
3178
+ // eslint-disable-next-line eslint-plugin/prefer-replace-text
3179
+ fixer.replaceTextRange([openingElement.range[0], openingElement.range[1]], "<>"),
3180
+ // eslint-disable-next-line eslint-plugin/prefer-replace-text
3181
+ fixer.replaceTextRange([closingElement.range[0], closingElement.range[1]], "</>")
3182
+ ];
3183
+ }
3184
+ });
3185
+ }
3250
3186
  };
3251
3187
  },
3252
3188
  defaultOptions: []
@@ -3268,23 +3204,23 @@ var use_jsx_vars_default = createRule({
3268
3204
  },
3269
3205
  name: RULE_NAME50,
3270
3206
  create(context) {
3271
- function getName5(node) {
3272
- switch (node.type) {
3273
- case types.AST_NODE_TYPES.JSXIdentifier:
3274
- return eff.O.some(node.name);
3275
- case types.AST_NODE_TYPES.JSXMemberExpression:
3276
- return getName5(node.object);
3277
- default:
3278
- return eff.O.none();
3279
- }
3280
- }
3281
3207
  return {
3282
3208
  JSXOpeningElement(node) {
3283
- if (node.name.type === types.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.name.name)) {
3284
- return;
3285
- }
3286
- for (const name2 of eff.O.toArray(getName5(node.name))) {
3287
- context.sourceCode.markVariableAsUsed(name2, node);
3209
+ switch (node.name.type) {
3210
+ case types.AST_NODE_TYPES.JSXIdentifier: {
3211
+ if (/^[a-z]/u.test(node.name.name)) {
3212
+ return;
3213
+ }
3214
+ context.sourceCode.markVariableAsUsed(node.name.name, node);
3215
+ break;
3216
+ }
3217
+ case types.AST_NODE_TYPES.JSXMemberExpression: {
3218
+ const { object } = node.name;
3219
+ if (object.type === types.AST_NODE_TYPES.JSXIdentifier) {
3220
+ context.sourceCode.markVariableAsUsed(object.name, node);
3221
+ }
3222
+ break;
3223
+ }
3288
3224
  }
3289
3225
  }
3290
3226
  };