eslint-plugin-react-x 5.2.3-next.2 → 5.2.4-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 (2) hide show
  1. package/dist/index.js +20 -20
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -143,7 +143,7 @@ const rules$7 = {
143
143
  //#endregion
144
144
  //#region package.json
145
145
  var name$6 = "eslint-plugin-react-x";
146
- var version = "5.2.3-next.2";
146
+ var version = "5.2.4-beta.1";
147
147
 
148
148
  //#endregion
149
149
  //#region src/rules/component-hook-factories/lib.ts
@@ -1325,7 +1325,7 @@ function create$46(context) {
1325
1325
  const { object, property } = node.callee;
1326
1326
  if (property.type !== AST_NODE_TYPES.Identifier) return;
1327
1327
  if (!MUTATING_ARRAY_METHODS.has(property.name)) return;
1328
- const rootId = Extract.rootIdentifier(object);
1328
+ const rootId = Extract.getRootIdentifier(object);
1329
1329
  if (rootId == null) return;
1330
1330
  if (rootId.name === "draft") return;
1331
1331
  const enclosingFn = Traverse.findParent(node, Check.isFunction);
@@ -1346,7 +1346,7 @@ function create$46(context) {
1346
1346
  },
1347
1347
  AssignmentExpression(node) {
1348
1348
  if (node.left.type !== AST_NODE_TYPES.MemberExpression) return;
1349
- const rootId = Extract.rootIdentifier(node.left);
1349
+ const rootId = Extract.getRootIdentifier(node.left);
1350
1350
  if (rootId == null) return;
1351
1351
  if (rootId.name === "draft") return;
1352
1352
  const enclosingFn = Traverse.findParent(node, Check.isFunction);
@@ -1620,7 +1620,7 @@ function create$45(context) {
1620
1620
  if (currMethod == null || isStatic) return;
1621
1621
  const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
1622
1622
  if (setState == null || hasThisState) return;
1623
- if (Extract.propertyName(node.property) !== "state") return;
1623
+ if (Extract.getPropertyName(node.property) !== "state") return;
1624
1624
  context.report({
1625
1625
  messageId: "default",
1626
1626
  node
@@ -1646,7 +1646,7 @@ function create$45(context) {
1646
1646
  const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
1647
1647
  if (setState == null || hasThisState) return;
1648
1648
  if (node.init == null || node.init.type !== AST_NODE_TYPES.ThisExpression || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
1649
- if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$1(prop, prop.key) && Extract.propertyName(prop.key) === "state")) return;
1649
+ if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$1(prop, prop.key) && Extract.getPropertyName(prop.key) === "state")) return;
1650
1650
  context.report({
1651
1651
  messageId: "default",
1652
1652
  node
@@ -2170,7 +2170,7 @@ function create$30(context) {
2170
2170
  const aValue = a.value;
2171
2171
  const bValue = b.value;
2172
2172
  if (aValue == null || bValue == null) return false;
2173
- return Compare.areEqual(aValue, bValue);
2173
+ return Compare.isEqual(aValue, bValue);
2174
2174
  }
2175
2175
  return merge({
2176
2176
  "JSXAttribute[name.name='key']"(node) {
@@ -2194,7 +2194,7 @@ function create$30(context) {
2194
2194
  if (!Check.isFunction(iter)) return;
2195
2195
  const arg0 = call?.arguments[0];
2196
2196
  if (call == null || arg0 == null) return;
2197
- if (Extract.unwrapped(arg0) !== iter) return;
2197
+ if (Extract.unwrap(arg0) !== iter) return;
2198
2198
  keyedEntries.set(call, {
2199
2199
  hasDuplicate: node.value?.type === AST_NODE_TYPES.Literal,
2200
2200
  keys: [node],
@@ -3237,7 +3237,7 @@ function create$11(context) {
3237
3237
  const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
3238
3238
  context.report({
3239
3239
  data: {
3240
- kind: Extract.humanReadableKind(constructionNode),
3240
+ kind: Extract.getHumanReadableKind(constructionNode),
3241
3241
  suggestion
3242
3242
  },
3243
3243
  messageId: "unstableContextValue",
@@ -3322,7 +3322,7 @@ function create$10(context, [options]) {
3322
3322
  if (identifier != null && safePatterns.some((pattern) => pattern.test(identifier))) continue;
3323
3323
  }
3324
3324
  context.report({
3325
- data: { kind: Extract.humanReadableKind(right) },
3325
+ data: { kind: Extract.getHumanReadableKind(right) },
3326
3326
  messageId: "default",
3327
3327
  node: right
3328
3328
  });
@@ -3393,7 +3393,7 @@ function create$9(context) {
3393
3393
  const usages = propertyUsages.get(currentClass);
3394
3394
  if (defs == null) return;
3395
3395
  for (const def of defs) {
3396
- const methodName = Extract.propertyName(def);
3396
+ const methodName = Extract.getPropertyName(def);
3397
3397
  if (methodName == null) continue;
3398
3398
  if ((usages?.has(methodName) ?? false) || LIFECYCLE_METHODS.has(methodName)) continue;
3399
3399
  context.report({
@@ -3431,7 +3431,7 @@ function create$9(context) {
3431
3431
  propertyDefs.get(currentClass)?.add(node.property);
3432
3432
  return;
3433
3433
  }
3434
- const propertyName = Extract.propertyName(node.property);
3434
+ const propertyName = Extract.getPropertyName(node.property);
3435
3435
  if (propertyName != null) propertyUsages.get(currentClass)?.add(propertyName);
3436
3436
  },
3437
3437
  MethodDefinition: methodEnter,
@@ -3445,7 +3445,7 @@ function create$9(context) {
3445
3445
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3446
3446
  if (node.init != null && node.init.type === AST_NODE_TYPES.ThisExpression && node.id.type === AST_NODE_TYPES.ObjectPattern) {
3447
3447
  for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) {
3448
- const keyName = Extract.propertyName(prop.key);
3448
+ const keyName = Extract.getPropertyName(prop.key);
3449
3449
  if (keyName != null) propertyUsages.get(currentClass)?.add(keyName);
3450
3450
  }
3451
3451
  }
@@ -3913,7 +3913,7 @@ function create$6(context) {
3913
3913
  const nEntries = [];
3914
3914
  return merge(hCollector.visitor, cCollector.visitor, {
3915
3915
  CallExpression(node) {
3916
- const expr = Extract.unwrapped(node.callee);
3916
+ const expr = Extract.unwrap(node.callee);
3917
3917
  switch (true) {
3918
3918
  case expr.type === AST_NODE_TYPES.Identifier: {
3919
3919
  if (!IMPURE_FUNCS.get("globalThis")?.has(expr.name)) return;
@@ -3940,7 +3940,7 @@ function create$6(context) {
3940
3940
  }
3941
3941
  },
3942
3942
  NewExpression(node) {
3943
- const expr = Extract.unwrapped(node.callee);
3943
+ const expr = Extract.unwrap(node.callee);
3944
3944
  if (expr.type !== AST_NODE_TYPES.Identifier) return;
3945
3945
  if (!IMPURE_CTORS.has(expr.name)) return;
3946
3946
  if (expr.name === "Date" && node.arguments.length > 0) return;
@@ -4001,7 +4001,7 @@ function create$5(context) {
4001
4001
  type: AST_NODE_TYPES.BinaryExpression,
4002
4002
  operator: P.union("===", "==", "!==", "!=")
4003
4003
  }, parent)) return false;
4004
- const otherSide = parent.left === node || Extract.unwrapped(parent.left) === node ? parent.right : parent.left;
4004
+ const otherSide = parent.left === node || Extract.unwrap(parent.left) === node ? parent.right : parent.left;
4005
4005
  if (otherSide.type !== AST_NODE_TYPES.Literal || otherSide.value != null) return false;
4006
4006
  return parent.parent.type === AST_NODE_TYPES.IfStatement && parent.parent.test === parent;
4007
4007
  }
@@ -4017,8 +4017,8 @@ function create$5(context) {
4017
4017
  if (op !== "===" && op !== "==" && op !== "!==" && op !== "!=") return false;
4018
4018
  const { left, right } = test;
4019
4019
  const checkSides = (a, b) => {
4020
- a = Check.isTypeExpression(a) ? Extract.unwrapped(a) : a;
4021
- return a.type === AST_NODE_TYPES.MemberExpression && a.object.type === AST_NODE_TYPES.Identifier && a.object.name === refName && b.type === AST_NODE_TYPES.Literal && b.value == null && Extract.propertyName(a.property) === "current";
4020
+ a = Check.isTypeExpression(a) ? Extract.unwrap(a) : a;
4021
+ return a.type === AST_NODE_TYPES.MemberExpression && a.object.type === AST_NODE_TYPES.Identifier && a.object.name === refName && b.type === AST_NODE_TYPES.Literal && b.value == null && Extract.getPropertyName(a.property) === "current";
4022
4022
  };
4023
4023
  return checkSides(left, right) || checkSides(right, left);
4024
4024
  }
@@ -4048,7 +4048,7 @@ function create$5(context) {
4048
4048
  isWrite: (() => {
4049
4049
  let parent = node.parent;
4050
4050
  while (Check.isTypeExpression(parent)) parent = parent.parent;
4051
- return match(parent).with({ type: AST_NODE_TYPES.AssignmentExpression }, (p) => p.left === node || Extract.unwrapped(p.left) === node).with({ type: AST_NODE_TYPES.UpdateExpression }, (p) => p.argument === node || Extract.unwrapped(p.argument) === node).otherwise(() => false);
4051
+ return match(parent).with({ type: AST_NODE_TYPES.AssignmentExpression }, (p) => p.left === node || Extract.unwrap(p.left) === node).with({ type: AST_NODE_TYPES.UpdateExpression }, (p) => p.argument === node || Extract.unwrap(p.argument) === node).otherwise(() => false);
4052
4052
  })(),
4053
4053
  node
4054
4054
  });
@@ -6393,8 +6393,8 @@ function create$4(context) {
6393
6393
  return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.callee !== node && isUseEffectCall(node.parent);
6394
6394
  }
6395
6395
  function getCallName(node) {
6396
- if (node.type === AST_NODE_TYPES.CallExpression) return Extract.fullyQualifiedName(node.callee, getText);
6397
- return Extract.fullyQualifiedName(node, getText);
6396
+ if (node.type === AST_NODE_TYPES.CallExpression) return Extract.getFullyQualifiedName(node.callee, getText);
6397
+ return Extract.getFullyQualifiedName(node, getText);
6398
6398
  }
6399
6399
  function getCallKind(node) {
6400
6400
  return match(node).when(isUseStateCall, () => "useState").when(isUseEffectCall, () => "useEffect").when(isSetStateCall, () => "setState").when(isThenCall, () => "then").otherwise(() => "other");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.2.3-next.2",
3
+ "version": "5.2.4-beta.1",
4
4
  "description": "A set of composable ESLint rules for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -46,12 +46,12 @@
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-api-utils": "^2.5.0",
48
48
  "ts-pattern": "^5.9.0",
49
- "@eslint-react/ast": "5.2.3-next.2",
50
- "@eslint-react/core": "5.2.3-next.2",
51
- "@eslint-react/eslint": "5.2.3-next.2",
52
- "@eslint-react/jsx": "5.2.3-next.2",
53
- "@eslint-react/shared": "5.2.3-next.2",
54
- "@eslint-react/var": "5.2.3-next.2"
49
+ "@eslint-react/ast": "5.2.4-beta.1",
50
+ "@eslint-react/core": "5.2.4-beta.1",
51
+ "@eslint-react/jsx": "5.2.4-beta.1",
52
+ "@eslint-react/eslint": "5.2.4-beta.1",
53
+ "@eslint-react/shared": "5.2.4-beta.1",
54
+ "@eslint-react/var": "5.2.4-beta.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/react": "^19.2.14",