eslint-plugin-react-x 2.7.2-beta.0 → 2.7.2-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 +10 -11
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { AST_NODE_TYPES } from "@typescript-eslint/types";
3
3
  import { ESLintUtils } from "@typescript-eslint/utils";
4
4
  import { P, isMatching, match } from "ts-pattern";
5
5
  import ts from "typescript";
6
- import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findEnclosingAssignmentTarget, findParentJsxAttribute, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInstanceIdEqual, isJsxFragmentElement, isJsxHostElement, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseEffectLikeCall, isUseMemoCall, isUseRefCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
6
+ import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findEnclosingAssignmentTarget, findParentJsxAttribute, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideComponentOrHook, isInstanceIdEqual, isJsxFragmentElement, isJsxHostElement, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseEffectLikeCall, isUseMemoCall, isUseRefCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
7
7
  import * as AST from "@eslint-react/ast";
8
8
  import { findVariable, getChildScopes, getObjectType, getVariableDefinitionNode } from "@eslint-react/var";
9
9
  import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
@@ -68,7 +68,7 @@ const rules$7 = {
68
68
  //#endregion
69
69
  //#region package.json
70
70
  var name$6 = "eslint-plugin-react-x";
71
- var version = "2.7.2-beta.0";
71
+ var version = "2.7.2-beta.2";
72
72
 
73
73
  //#endregion
74
74
  //#region src/utils/create-rule.ts
@@ -1214,8 +1214,8 @@ const RULE_NAME$36 = "no-duplicate-key";
1214
1214
  var no_duplicate_key_default = createRule({
1215
1215
  meta: {
1216
1216
  type: "problem",
1217
- docs: { description: "Disallows duplicate 'key' on elements in the same array or a list of 'children'." },
1218
- messages: { noDuplicateKey: "A key must be unique. '{{value}}' is duplicated." },
1217
+ docs: { description: "Prevents duplicate 'key' props on sibling elements when rendering lists." },
1218
+ messages: { noDuplicateKey: "The 'key' prop must be unique to its sibling elements." },
1219
1219
  schema: []
1220
1220
  },
1221
1221
  name: RULE_NAME$36,
@@ -3256,22 +3256,21 @@ function create$4(context) {
3256
3256
  return {
3257
3257
  ...listeners,
3258
3258
  MemberExpression(node) {
3259
- if (isMemberExpressionWithObjectName(node)) {
3260
- const scope = context.sourceCode.getScope(node);
3261
- exprs.push([scope, node]);
3262
- }
3259
+ if (!isInsideComponentOrHook(node)) return;
3260
+ if (!isMemberExpressionWithObjectName(node)) return;
3261
+ exprs.push(node);
3263
3262
  },
3264
3263
  "Program:exit"(program) {
3265
3264
  const components = ctx.getAllComponents(program);
3266
3265
  function isFunctionComponent(block) {
3267
3266
  return components.some((comp) => {
3268
3267
  if (comp.node !== block) return false;
3269
- if (comp.name == null && comp.isExportDefault) return false;
3268
+ if (comp.name == null && comp.isExportDefaultDeclaration) return false;
3270
3269
  return true;
3271
3270
  });
3272
3271
  }
3273
- for (const [initialScope, expr] of exprs) {
3274
- let scope = initialScope;
3272
+ for (const expr of exprs) {
3273
+ let scope = context.sourceCode.getScope(expr);
3275
3274
  let isComponent = isFunctionComponent(scope.block);
3276
3275
  while (!isComponent && scope.upper != null && scope.upper !== scope) {
3277
3276
  scope = scope.upper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.7.2-beta.0",
3
+ "version": "2.7.2-beta.2",
4
4
  "description": "A set of composable ESLint rules for for libraries and frameworks that use React as a UI runtime.",
5
5
  "keywords": [
6
6
  "react",
@@ -46,11 +46,11 @@
46
46
  "string-ts": "^2.3.1",
47
47
  "ts-api-utils": "^2.4.0",
48
48
  "ts-pattern": "^5.9.0",
49
- "@eslint-react/ast": "2.7.2-beta.0",
50
- "@eslint-react/core": "2.7.2-beta.0",
51
- "@eslint-react/eff": "2.7.2-beta.0",
52
- "@eslint-react/shared": "2.7.2-beta.0",
53
- "@eslint-react/var": "2.7.2-beta.0"
49
+ "@eslint-react/ast": "2.7.2-beta.2",
50
+ "@eslint-react/core": "2.7.2-beta.2",
51
+ "@eslint-react/shared": "2.7.2-beta.2",
52
+ "@eslint-react/var": "2.7.2-beta.2",
53
+ "@eslint-react/eff": "2.7.2-beta.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.8",