eslint-plugin-react-x 5.11.0 → 5.11.3

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 +14 -14
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_ESLINT_REACT_SETTINGS, getSettingsFromContext, toRegExp } from "@eslint-react/shared";
2
2
  import { ESLintUtils } from "@typescript-eslint/utils";
3
- import { Check, Compare, Extract, Traverse, is, isOneOf } from "@eslint-react/ast";
3
+ import { Check, Compare, Extract, Traverse } from "@eslint-react/ast";
4
4
  import * as core from "@eslint-react/core";
5
5
  import { merge } from "@eslint-react/eslint";
6
6
  import { JsxDetectionHint, findParentAttribute, getElementFullType, hasAttribute } from "@eslint-react/jsx";
@@ -144,7 +144,7 @@ const rules$6 = {
144
144
  //#endregion
145
145
  //#region package.json
146
146
  var name$6 = "eslint-plugin-react-x";
147
- var version = "5.11.0";
147
+ var version = "5.11.3";
148
148
 
149
149
  //#endregion
150
150
  //#region src/utils/create-rule.ts
@@ -1830,7 +1830,7 @@ function isArrayIndexReference(context, node) {
1830
1830
  const def = findVariable(context.sourceCode.getScope(node), node)?.defs.at(0);
1831
1831
  if (def == null || def.type !== DefinitionType.Parameter) return false;
1832
1832
  const callback = def.node;
1833
- if (!isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(callback)) return false;
1833
+ if (!Check.isOneOf([AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression])(callback)) return false;
1834
1834
  let argument = callback;
1835
1835
  while (Check.isTypeExpression(argument.parent)) argument = argument.parent;
1836
1836
  const call = argument.parent;
@@ -2302,7 +2302,7 @@ function create$34(context) {
2302
2302
  //#region src/rules/no-direct-mutation-state/no-direct-mutation-state.ts
2303
2303
  const RULE_NAME$33 = "no-direct-mutation-state";
2304
2304
  function isConstructorFunction(node) {
2305
- return isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && Check.isPropertyOrMethod(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
2305
+ return Check.isOneOf([AST_NODE_TYPES.FunctionDeclaration, AST_NODE_TYPES.FunctionExpression])(node) && Check.isPropertyOrMethod(node.parent) && node.parent.key.type === AST_NODE_TYPES.Identifier && node.parent.key.name === "constructor";
2306
2306
  }
2307
2307
  var no_direct_mutation_state_default = createRule({
2308
2308
  meta: {
@@ -2318,7 +2318,7 @@ var no_direct_mutation_state_default = createRule({
2318
2318
  function create$33(context) {
2319
2319
  return { AssignmentExpression(node) {
2320
2320
  if (!core.isAssignmentToThisState(node)) return;
2321
- const parentClass = Traverse.findParent(node, isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
2321
+ const parentClass = Traverse.findParent(node, Check.isOneOf([AST_NODE_TYPES.ClassDeclaration, AST_NODE_TYPES.ClassExpression]));
2322
2322
  if (parentClass == null) return;
2323
2323
  if (core.isClassComponent(parentClass) && context.sourceCode.getScope(node).block !== Traverse.findParent(node, isConstructorFunction)) context.report({
2324
2324
  messageId: "default",
@@ -2424,8 +2424,8 @@ function create$31(context) {
2424
2424
  return { CallExpression(node) {
2425
2425
  if (!core.isForwardRefCall(context, node)) return;
2426
2426
  const id = core.getFunctionId(node);
2427
- const suggest = canFix(context, node) ? [{
2428
- fix: getFix(context, node),
2427
+ const suggest = couldFix(context, node) ? [{
2428
+ fix: buildFix(context, node),
2429
2429
  messageId: "replace"
2430
2430
  }] : [];
2431
2431
  context.report({
@@ -2443,7 +2443,7 @@ function create$31(context) {
2443
2443
  * @param node The CallExpression node to check
2444
2444
  * @returns True if the call can be auto-fixed, false otherwise
2445
2445
  */
2446
- function canFix(context, node) {
2446
+ function couldFix(context, node) {
2447
2447
  const { importSource } = getSettingsFromContext(context);
2448
2448
  const initialScope = context.sourceCode.getScope(node);
2449
2449
  const callee = Extract.unwrap(node.callee);
@@ -2459,14 +2459,14 @@ function canFix(context, node) {
2459
2459
  * @param node The `forwardRef` call expression
2460
2460
  * @returns A fixer function that applies the changes
2461
2461
  */
2462
- function getFix(context, node) {
2462
+ function buildFix(context, node) {
2463
2463
  return (fixer) => {
2464
2464
  const [componentNode] = node.arguments;
2465
2465
  if (componentNode == null || !Check.isFunction(componentNode)) return [];
2466
2466
  return [
2467
2467
  fixer.removeRange([node.range[0], componentNode.range[0]]),
2468
2468
  fixer.removeRange([componentNode.range[1], node.range[1]]),
2469
- ...getComponentPropsFixes(context, fixer, componentNode, node.typeArguments?.params ?? [])
2469
+ ...buildFixForComponentProps(context, fixer, componentNode, node.typeArguments?.params ?? [])
2470
2470
  ];
2471
2471
  };
2472
2472
  }
@@ -2478,7 +2478,7 @@ function getFix(context, node) {
2478
2478
  * @param typeArguments The type arguments from the `forwardRef` call
2479
2479
  * @returns An array of fixes for the component's signature
2480
2480
  */
2481
- function getComponentPropsFixes(context, fixer, node, typeArguments) {
2481
+ function buildFixForComponentProps(context, fixer, node, typeArguments) {
2482
2482
  const getText = (node) => context.sourceCode.getText(node);
2483
2483
  const [arg0, arg1] = node.params;
2484
2484
  const [typeArg0, typeArg1] = typeArguments;
@@ -2683,7 +2683,7 @@ function create$27(context) {
2683
2683
  */
2684
2684
  function getReportDescriptor(node, visited = /* @__PURE__ */ new Set()) {
2685
2685
  if (node == null) return null;
2686
- if (is(AST_NODE_TYPES.JSXExpressionContainer)(node)) return getReportDescriptor(node.expression, visited);
2686
+ if (Check.is(AST_NODE_TYPES.JSXExpressionContainer)(node)) return getReportDescriptor(node.expression, visited);
2687
2687
  if (Check.isJSX(node)) return null;
2688
2688
  if (Check.isTypeExpression(node)) return getReportDescriptor(node.expression, visited);
2689
2689
  return match(node).with({
@@ -3050,7 +3050,7 @@ function isInsideRenderMethod(node) {
3050
3050
  function isInsideCreateElementProps(context, node) {
3051
3051
  const call = Traverse.findParent(node, core.isCreateElementCall(context));
3052
3052
  if (call == null) return false;
3053
- const prop = Traverse.findParent(node, is(AST_NODE_TYPES.ObjectExpression));
3053
+ const prop = Traverse.findParent(node, Check.is(AST_NODE_TYPES.ObjectExpression));
3054
3054
  if (prop == null) return false;
3055
3055
  return prop === call.arguments[1];
3056
3056
  }
@@ -7632,7 +7632,7 @@ const LAZY_INIT_ALLOW_LIST = [
7632
7632
  * node, and it will return an array of all nested expressions of type AST.
7633
7633
  */
7634
7634
  function getNestedExpressionsOfType(type) {
7635
- const isNodeOfType = is(type);
7635
+ const isNodeOfType = Check.is(type);
7636
7636
  const recurse = (node) => {
7637
7637
  const expressions = [];
7638
7638
  if (isNodeOfType(node)) expressions.push(node);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.11.0",
3
+ "version": "5.11.3",
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",
@@ -45,12 +45,12 @@
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.5.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/core": "5.11.0",
49
- "@eslint-react/ast": "5.11.0",
50
- "@eslint-react/jsx": "5.11.0",
51
- "@eslint-react/shared": "5.11.0",
52
- "@eslint-react/eslint": "5.11.0",
53
- "@eslint-react/var": "5.11.0"
48
+ "@eslint-react/ast": "5.11.3",
49
+ "@eslint-react/shared": "5.11.3",
50
+ "@eslint-react/var": "5.11.3",
51
+ "@eslint-react/jsx": "5.11.3",
52
+ "@eslint-react/core": "5.11.3",
53
+ "@eslint-react/eslint": "5.11.3"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/react": "^19.2.17",