eslint-plugin-react-x 2.0.4 → 2.0.5-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +15 -15
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { P, isMatching, match } from "ts-pattern";
6
6
  import ts from "typescript";
7
7
  import * as AST from "@eslint-react/ast";
8
8
  import { ConstructionDetectionHint, findVariable, getChildScopes, getConstruction, getVariableDefinitionNode } from "@eslint-react/var";
9
- import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findParentAttribute, getAttribute, getAttributeName, getElementType, getInstanceId, getJsxConfigFromAnnotation, getJsxConfigFromContext, hasAttribute, isAssignmentToThisState, isCaptureOwnerStackCall, isChildrenCount, isChildrenForEach, isChildrenMap, isChildrenOnly, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUpdate, isCreateContextCall, isCreateElementCall, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRefCall, isFragmentElement, isGetDerivedStateFromError, isGetDerivedStateFromProps, isHostElement, isInitializedFromReact, isInstanceIdEqual, isJsxText, isLazyCall, isReactHookCall, isReactHookName, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseMemoCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
9
+ import { ComponentDetectionHint, ComponentFlag, DEFAULT_COMPONENT_DETECTION_HINT, JsxEmit, findParentJsxAttribute, getInstanceId, getJsxAttribute, getJsxAttributeName, getJsxConfigFromAnnotation, getJsxConfigFromContext, getJsxElementType, hasJsxAttribute, 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, isRenderMethodLike, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseCall, isUseCallbackCall, isUseContextCall, isUseMemoCall, isUseStateCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector } from "@eslint-react/core";
10
10
  import { report, toRegExp } from "@eslint-react/kit";
11
11
  import { constFalse, constTrue, flow, getOrElseUpdate, identity, unit } from "@eslint-react/eff";
12
12
  import { compare } from "compare-versions";
@@ -115,7 +115,7 @@ const settings = { ...settings$1 };
115
115
  //#endregion
116
116
  //#region package.json
117
117
  var name = "eslint-plugin-react-x";
118
- var version = "2.0.4";
118
+ var version = "2.0.5-next.0";
119
119
 
120
120
  //#endregion
121
121
  //#region src/utils/create-rule.ts
@@ -409,7 +409,7 @@ function create$56(context) {
409
409
  const policy = context.options[0] ?? defaultOptions$3[0];
410
410
  return { JSXAttribute(node) {
411
411
  const { value } = node;
412
- const propName = getAttributeName(context, node);
412
+ const propName = getJsxAttributeName(context, node);
413
413
  switch (true) {
414
414
  case policy === 1 && value?.type === AST_NODE_TYPES.JSXExpressionContainer && value.expression.type === AST_NODE_TYPES.Literal && value.expression.value === true:
415
415
  context.report({
@@ -462,7 +462,7 @@ function create$55(context) {
462
462
  ...getJsxConfigFromAnnotation(context)
463
463
  };
464
464
  return match(policy).with(1, () => ({ JSXElement(node) {
465
- if (!isFragmentElement(context, node)) return;
465
+ if (!isJsxFragmentElement(context, node)) return;
466
466
  if (node.openingElement.attributes.length > 0) return;
467
467
  context.report({
468
468
  messageId: "jsxShorthandFragment",
@@ -905,7 +905,7 @@ var no_children_prop_default = createRule({
905
905
  });
906
906
  function create$46(context) {
907
907
  return { JSXElement(node) {
908
- const childrenProp = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("children");
908
+ const childrenProp = getJsxAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("children");
909
909
  if (childrenProp != null) context.report({
910
910
  messageId: "noChildrenProp",
911
911
  node: childrenProp
@@ -1151,7 +1151,7 @@ function create$39(context) {
1151
1151
  const { version: version$1 } = getSettingsFromContext(context);
1152
1152
  if (compare(version$1, "19.0.0", "<")) return {};
1153
1153
  return { JSXElement(node) {
1154
- const parts = getElementType(context, node).split(".");
1154
+ const parts = getJsxElementType(context, node).split(".");
1155
1155
  const selfName = parts.pop();
1156
1156
  const contextFullName = parts.join(".");
1157
1157
  const contextSelfName = parts.pop();
@@ -1535,7 +1535,7 @@ var no_implicit_key_default = createRule({
1535
1535
  function create$32(context) {
1536
1536
  return { JSXOpeningElement(node) {
1537
1537
  const initialScope = context.sourceCode.getScope(node);
1538
- const keyProp = getAttribute(context, node.attributes, initialScope)("key");
1538
+ const keyProp = getJsxAttribute(context, node.attributes, initialScope)("key");
1539
1539
  const isKeyPropOnElement = node.attributes.some((n) => n.type === AST_NODE_TYPES.JSXAttribute && n.name.type === AST_NODE_TYPES.JSXIdentifier && n.name.name === "key");
1540
1540
  if (keyProp != null && !isKeyPropOnElement) context.report({
1541
1541
  messageId: "noImplicitKey",
@@ -1753,7 +1753,7 @@ function create$28(context) {
1753
1753
  switch (node.type) {
1754
1754
  case AST_NODE_TYPES.JSXElement: {
1755
1755
  const initialScope = context.sourceCode.getScope(node);
1756
- if (!hasAttribute(context, "key", node.openingElement.attributes, initialScope)) return {
1756
+ if (!hasJsxAttribute(context, "key", node.openingElement.attributes, initialScope)) return {
1757
1757
  messageId: "missingKey",
1758
1758
  node
1759
1759
  };
@@ -1794,7 +1794,7 @@ function create$28(context) {
1794
1794
  const elements = node.elements.filter(AST.is(AST_NODE_TYPES.JSXElement));
1795
1795
  if (elements.length === 0) return;
1796
1796
  const initialScope = context.sourceCode.getScope(node);
1797
- for (const element of elements) if (!hasAttribute(context, "key", element.openingElement.attributes, initialScope)) context.report({
1797
+ for (const element of elements) if (!hasJsxAttribute(context, "key", element.openingElement.attributes, initialScope)) context.report({
1798
1798
  messageId: "missingKey",
1799
1799
  node: element
1800
1800
  });
@@ -1977,7 +1977,7 @@ function create$26(context) {
1977
1977
  * @returns `true` if the node is inside JSX attribute value
1978
1978
  */
1979
1979
  function isInsideJSXAttributeValue(node) {
1980
- return node.parent.type === AST_NODE_TYPES.JSXAttribute || findParentAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
1980
+ return node.parent.type === AST_NODE_TYPES.JSXAttribute || findParentJsxAttribute(node, (n) => n.value?.type === AST_NODE_TYPES.JSXExpressionContainer) != null;
1981
1981
  }
1982
1982
  /**
1983
1983
  * Check whether given node is declared inside class component's render block
@@ -2626,7 +2626,7 @@ function create$11(context) {
2626
2626
  return {
2627
2627
  ...listeners,
2628
2628
  JSXOpeningElement(node) {
2629
- const selfName = getElementType(context, node.parent).split(".").at(-1);
2629
+ const selfName = getJsxElementType(context, node.parent).split(".").at(-1);
2630
2630
  if (selfName == null) return;
2631
2631
  if (!isContextName(selfName, isReact18OrBelow)) return;
2632
2632
  const functionEntry = ctx.getCurrentEntry();
@@ -3232,7 +3232,7 @@ function create$4(context, [option]) {
3232
3232
  const { allowExpressions = true } = option;
3233
3233
  return {
3234
3234
  JSXElement(node) {
3235
- if (!isFragmentElement(context, node)) return;
3235
+ if (!isJsxFragmentElement(context, node)) return;
3236
3236
  checkNode(context, node, allowExpressions);
3237
3237
  },
3238
3238
  JSXFragment(node) {
@@ -3267,8 +3267,8 @@ function trimLikeReact(text) {
3267
3267
  */
3268
3268
  function checkNode(context, node, allowExpressions) {
3269
3269
  const initialScope = context.sourceCode.getScope(node);
3270
- if (node.type === AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope)) return;
3271
- if (isHostElement(context, node.parent)) context.report({
3270
+ if (node.type === AST_NODE_TYPES.JSXElement && hasJsxAttribute(context, "key", node.openingElement.attributes, initialScope)) return;
3271
+ if (isJsxHostElement(context, node.parent)) context.report({
3272
3272
  messageId: "uselessFragment",
3273
3273
  node,
3274
3274
  data: { reason: "placed inside a host component" },
@@ -3328,7 +3328,7 @@ function getFix(context, node) {
3328
3328
  * Check if it's safe to automatically fix the fragment
3329
3329
  */
3330
3330
  function canFix(context, node) {
3331
- if (node.parent.type === AST_NODE_TYPES.JSXElement || node.parent.type === AST_NODE_TYPES.JSXFragment) return isHostElement(context, node.parent);
3331
+ if (node.parent.type === AST_NODE_TYPES.JSXElement || node.parent.type === AST_NODE_TYPES.JSXFragment) return isJsxHostElement(context, node.parent);
3332
3332
  if (node.children.length === 0) return false;
3333
3333
  return !node.children.some((child) => isJsxText(child) && !isWhiteSpace(child) || AST.is(AST_NODE_TYPES.JSXExpressionContainer)(child));
3334
3334
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-next.0",
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",
@@ -43,17 +43,17 @@
43
43
  "string-ts": "^2.2.1",
44
44
  "ts-api-utils": "^2.1.0",
45
45
  "ts-pattern": "^5.8.0",
46
- "@eslint-react/ast": "2.0.4",
47
- "@eslint-react/core": "2.0.4",
48
- "@eslint-react/eff": "2.0.4",
49
- "@eslint-react/shared": "2.0.4",
50
- "@eslint-react/kit": "2.0.4",
51
- "@eslint-react/var": "2.0.4"
46
+ "@eslint-react/ast": "2.0.5-next.0",
47
+ "@eslint-react/core": "2.0.5-next.0",
48
+ "@eslint-react/eff": "2.0.5-next.0",
49
+ "@eslint-react/kit": "2.0.5-next.0",
50
+ "@eslint-react/shared": "2.0.5-next.0",
51
+ "@eslint-react/var": "2.0.5-next.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@types/react": "^19.1.15",
54
+ "@types/react": "^19.1.16",
55
55
  "@types/react-dom": "^19.1.9",
56
- "tsdown": "^0.15.5",
56
+ "tsdown": "^0.15.6",
57
57
  "@local/configs": "0.0.0"
58
58
  },
59
59
  "peerDependencies": {