eslint-plugin-react-x 5.2.3-beta.1 → 5.2.3-beta.2

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 +19 -16
  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-beta.1";
146
+ var version = "5.2.3-beta.2";
147
147
 
148
148
  //#endregion
149
149
  //#region src/rules/component-hook-factories/lib.ts
@@ -1613,7 +1613,7 @@ function create$45(context) {
1613
1613
  classStack.pop();
1614
1614
  },
1615
1615
  MemberExpression(node) {
1616
- if (!Check.thisExpression(node.object)) return;
1616
+ if (node.object.type !== AST_NODE_TYPES.ThisExpression) return;
1617
1617
  const [currClass, isComponent = false] = classStack.at(-1) ?? [];
1618
1618
  if (currClass == null || !isComponent) return;
1619
1619
  const [currMethod, isStatic = false] = methodStack.at(-1) ?? [];
@@ -1645,7 +1645,7 @@ function create$45(context) {
1645
1645
  if (currMethod == null || isStatic) return;
1646
1646
  const [setState, hasThisState = false] = setStateStack.at(-1) ?? [];
1647
1647
  if (setState == null || hasThisState) return;
1648
- if (node.init == null || !Check.thisExpression(node.init) || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
1648
+ if (node.init == null || node.init.type !== AST_NODE_TYPES.ThisExpression || node.id.type !== AST_NODE_TYPES.ObjectPattern) return;
1649
1649
  if (!node.id.properties.some((prop) => prop.type === AST_NODE_TYPES.Property && isKeyLiteral$1(prop, prop.key) && Extract.propertyName(prop.key) === "state")) return;
1650
1650
  context.report({
1651
1651
  messageId: "default",
@@ -2508,7 +2508,7 @@ function create$25(context) {
2508
2508
  }, ({ left, right }) => {
2509
2509
  if (left.type === AST_NODE_TYPES.UnaryExpression && left.operator === "!") return getReportDescriptor(right);
2510
2510
  const initialScope = context.sourceCode.getScope(left);
2511
- if (Check.identifier(left, "NaN") || getStaticValue(left, initialScope)?.value === "NaN") return {
2511
+ if (Check.isIdentifier("NaN")(left) || getStaticValue(left, initialScope)?.value === "NaN") return {
2512
2512
  data: { value: context.sourceCode.getText(left) },
2513
2513
  messageId: "default",
2514
2514
  node: left
@@ -2765,8 +2765,8 @@ function isProcessEnvNodeEnvCompare(node, operator, value) {
2765
2765
  if (node == null) return false;
2766
2766
  if (node.type !== AST_NODE_TYPES.BinaryExpression) return false;
2767
2767
  if (node.operator !== operator) return false;
2768
- if (isProcessEnvNodeEnv(node.left) && Check.literal(node.right, "string")) return node.right.value === value;
2769
- if (Check.literal(node.left, "string") && isProcessEnvNodeEnv(node.right)) return node.left.value === value;
2768
+ if (isProcessEnvNodeEnv(node.left) && Check.isLiteral("string")(node.right)) return node.right.value === value;
2769
+ if (Check.isLiteral("string")(node.left) && isProcessEnvNodeEnv(node.right)) return node.left.value === value;
2770
2770
  return false;
2771
2771
  }
2772
2772
 
@@ -3207,7 +3207,7 @@ var no_unstable_context_value_default = createRule({
3207
3207
  function create$11(context) {
3208
3208
  const { compilationMode, version } = getSettingsFromContext(context);
3209
3209
  if (compilationMode === "infer" || compilationMode === "all") return {};
3210
- if (compilationMode === "annotation" && context.sourceCode.ast.body.some((stmt) => Check.directive(stmt) && stmt.directive === "use memo")) return {};
3210
+ if (compilationMode === "annotation" && context.sourceCode.ast.body.some(Check.isDirective("use memo"))) return {};
3211
3211
  const isReact18OrBelow = compare(version, "19.0.0", "<");
3212
3212
  const { api, visitor } = core.getFunctionComponentCollector(context);
3213
3213
  const constructions = /* @__PURE__ */ new WeakMap();
@@ -3254,6 +3254,14 @@ function isContextName(name, isReact18OrBelow) {
3254
3254
  return false;
3255
3255
  }
3256
3256
 
3257
+ //#endregion
3258
+ //#region src/rules/no-unstable-default-props/lib.ts
3259
+ const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
3260
+ "VariableDeclarator",
3261
+ "[id.type='ObjectPattern']",
3262
+ "[init.type='Identifier']"
3263
+ ].join("");
3264
+
3257
3265
  //#endregion
3258
3266
  //#region src/rules/no-unstable-default-props/no-unstable-default-props.ts
3259
3267
  const RULE_NAME$10 = "no-unstable-default-props";
@@ -3288,13 +3296,8 @@ function extractIdentifier(node) {
3288
3296
  function create$10(context, [options]) {
3289
3297
  const { compilationMode } = getSettingsFromContext(context);
3290
3298
  if (compilationMode === "infer" || compilationMode === "all") return {};
3291
- if (compilationMode === "annotation" && context.sourceCode.ast.body.some((stmt) => Check.directive(stmt) && stmt.directive === "use memo")) return {};
3299
+ if (compilationMode === "annotation" && context.sourceCode.ast.body.some(Check.isDirective("use memo"))) return {};
3292
3300
  const { api, visitor } = core.getFunctionComponentCollector(context);
3293
- const SEL_OBJECT_DESTRUCTURING_VARIABLE_DECLARATOR = [
3294
- "VariableDeclarator",
3295
- "[id.type='ObjectPattern']",
3296
- "[init.type='Identifier']"
3297
- ].join("");
3298
3301
  const declarators = /* @__PURE__ */ new WeakMap();
3299
3302
  const { safeDefaultProps = [] } = options;
3300
3303
  const safePatterns = safeDefaultProps.map((s) => toRegExp(s));
@@ -3423,7 +3426,7 @@ function create$9(context) {
3423
3426
  const currentMethod = methodStack.at(-1);
3424
3427
  if (currentClass == null || currentMethod == null) return;
3425
3428
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3426
- if (!Check.thisExpression(node.object) || !isKeyLiteral(node, node.property)) return;
3429
+ if (node.object.type !== AST_NODE_TYPES.ThisExpression || !isKeyLiteral(node, node.property)) return;
3427
3430
  if (node.parent.type === AST_NODE_TYPES.AssignmentExpression && node.parent.left === node) {
3428
3431
  propertyDefs.get(currentClass)?.add(node.property);
3429
3432
  return;
@@ -3440,7 +3443,7 @@ function create$9(context) {
3440
3443
  const currentMethod = methodStack.at(-1);
3441
3444
  if (currentClass == null || currentMethod == null) return;
3442
3445
  if (!core.isClassComponent(currentClass) || currentMethod.static) return;
3443
- if (node.init != null && Check.thisExpression(node.init) && node.id.type === AST_NODE_TYPES.ObjectPattern) {
3446
+ if (node.init != null && node.init.type === AST_NODE_TYPES.ThisExpression && node.id.type === AST_NODE_TYPES.ObjectPattern) {
3444
3447
  for (const prop of node.id.properties) if (prop.type === AST_NODE_TYPES.Property && isKeyLiteral(prop, prop.key)) {
3445
3448
  const keyName = Extract.propertyName(prop.key);
3446
3449
  if (keyName != null) propertyUsages.get(currentClass)?.add(keyName);
@@ -4040,7 +4043,7 @@ function create$5(context) {
4040
4043
  }
4041
4044
  },
4042
4045
  MemberExpression(node) {
4043
- if (!Check.identifier(node.property, "current")) return;
4046
+ if (!Check.isIdentifier("current")(node.property)) return;
4044
4047
  refAccesses.push({
4045
4048
  isWrite: (() => {
4046
4049
  let parent = node.parent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.2.3-beta.1",
3
+ "version": "5.2.3-beta.2",
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-beta.1",
50
- "@eslint-react/core": "5.2.3-beta.1",
51
- "@eslint-react/jsx": "5.2.3-beta.1",
52
- "@eslint-react/eslint": "5.2.3-beta.1",
53
- "@eslint-react/shared": "5.2.3-beta.1",
54
- "@eslint-react/var": "5.2.3-beta.1"
49
+ "@eslint-react/ast": "5.2.3-beta.2",
50
+ "@eslint-react/core": "5.2.3-beta.2",
51
+ "@eslint-react/jsx": "5.2.3-beta.2",
52
+ "@eslint-react/eslint": "5.2.3-beta.2",
53
+ "@eslint-react/shared": "5.2.3-beta.2",
54
+ "@eslint-react/var": "5.2.3-beta.2"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/react": "^19.2.14",