eslint-plugin-react-x 3.0.0-beta.15 → 3.0.0-beta.17

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 -12
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -48,7 +48,8 @@ const rules$8 = {
48
48
  "react-x/no-unused-props": "off",
49
49
  "react-x/prefer-read-only-props": "off",
50
50
  "react-x/refs": "off",
51
- "react-x/rules-of-hooks": "off"
51
+ "react-x/rules-of-hooks": "off",
52
+ "react-x/set-state-in-render": "off"
52
53
  };
53
54
 
54
55
  //#endregion
@@ -68,7 +69,7 @@ const rules$7 = {
68
69
  //#endregion
69
70
  //#region package.json
70
71
  var name$6 = "eslint-plugin-react-x";
71
- var version = "3.0.0-beta.15";
72
+ var version = "3.0.0-beta.17";
72
73
 
73
74
  //#endregion
74
75
  //#region src/utils/create-rule.ts
@@ -2761,8 +2762,9 @@ var no_unstable_context_value_default = createRule({
2761
2762
  defaultOptions: []
2762
2763
  });
2763
2764
  function create$17(context) {
2764
- const { isCompilerEnabled, version } = getSettingsFromContext(context);
2765
- if (isCompilerEnabled && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2765
+ const { compilationMode, version } = getSettingsFromContext(context);
2766
+ if (compilationMode === "infer" || compilationMode === "all") return {};
2767
+ if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2766
2768
  const isReact18OrBelow = compare(version, "19.0.0", "<");
2767
2769
  const { ctx, visitor } = core.useComponentCollector(context);
2768
2770
  const constructions = /* @__PURE__ */ new WeakMap();
@@ -2773,7 +2775,7 @@ function create$17(context) {
2773
2775
  if (!isContextName(selfName, isReact18OrBelow)) return;
2774
2776
  const functionEntry = ctx.getCurrentEntry();
2775
2777
  if (functionEntry == null) return;
2776
- if (isCompilerEnabled && ast.isDirectiveInFunction(functionEntry.node, "use memo")) return;
2778
+ if (compilationMode === "annotation" && ast.isDirectiveInFunction(functionEntry.node, "use memo")) return;
2777
2779
  const attribute = node.attributes.find((attribute) => attribute.type === AST_NODE_TYPES.JSXAttribute && attribute.name.name === "value");
2778
2780
  if (attribute == null || !("value" in attribute)) return;
2779
2781
  const value = attribute.value;
@@ -2839,8 +2841,9 @@ function extractIdentifier(node) {
2839
2841
  return null;
2840
2842
  }
2841
2843
  function create$16(context, [options]) {
2842
- const { isCompilerEnabled } = getSettingsFromContext(context);
2843
- if (isCompilerEnabled && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2844
+ const { compilationMode } = getSettingsFromContext(context);
2845
+ if (compilationMode === "infer" || compilationMode === "all") return {};
2846
+ if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2844
2847
  const { ctx, visitor } = core.useComponentCollector(context);
2845
2848
  const declarators = /* @__PURE__ */ new WeakMap();
2846
2849
  const { safeDefaultProps = [] } = options;
@@ -3861,7 +3864,7 @@ function isWriteAfterNullCheckIf(node, refName) {
3861
3864
  var refs_default = createRule({
3862
3865
  meta: {
3863
3866
  type: "problem",
3864
- docs: { description: "Validates correct usage of refs by checking that ref.current is not read or written during render." },
3867
+ docs: { description: "Validates correct usage of refs by checking that 'ref.current' is not read or written during render." },
3865
3868
  messages: {
3866
3869
  readDuringRender: "Do not read 'ref.current' during render. Refs are not available during rendering and their values may be stale or inconsistent. Move this read into an effect or event handler.",
3867
3870
  writeDuringRender: "Do not write to 'ref.current' during render. Refs should only be mutated in effects or event handlers. Move this write into an effect or event handler."
@@ -4413,15 +4416,15 @@ function create$1(context) {
4413
4416
  }
4414
4417
  return false;
4415
4418
  }
4416
- function isComponentLikeFunction(node) {
4419
+ function isComponentOrHookLikeFunction(node) {
4417
4420
  const id = ast.getFunctionId(node);
4418
4421
  if (id == null) return false;
4419
- if (id.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.name);
4420
- if (id.type === AST_NODE_TYPES.MemberExpression && id.property.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.property.name);
4422
+ if (id.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.name) || core.isHookName(id.name);
4423
+ if (id.type === AST_NODE_TYPES.MemberExpression && id.property.type === AST_NODE_TYPES.Identifier) return core.isComponentName(id.property.name) || core.isHookName(id.property.name);
4421
4424
  return false;
4422
4425
  }
4423
4426
  function getFunctionKind(node) {
4424
- if (isComponentLikeFunction(node)) return "component";
4427
+ if (isComponentOrHookLikeFunction(node)) return "component";
4425
4428
  const parent = ast.findParentNode(node, not(ast.isTypeExpression)) ?? node.parent;
4426
4429
  if (parent.type === AST_NODE_TYPES.CallExpression && parent.callee !== node) return "callback";
4427
4430
  return "other";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-beta.15",
3
+ "version": "3.0.0-beta.17",
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,11 +45,11 @@
45
45
  "is-immutable-type": "^5.0.1",
46
46
  "ts-api-utils": "^2.4.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "3.0.0-beta.15",
49
- "@eslint-react/core": "3.0.0-beta.15",
50
- "@eslint-react/eff": "3.0.0-beta.15",
51
- "@eslint-react/shared": "3.0.0-beta.15",
52
- "@eslint-react/var": "3.0.0-beta.15"
48
+ "@eslint-react/ast": "3.0.0-beta.17",
49
+ "@eslint-react/core": "3.0.0-beta.17",
50
+ "@eslint-react/eff": "3.0.0-beta.17",
51
+ "@eslint-react/shared": "3.0.0-beta.17",
52
+ "@eslint-react/var": "3.0.0-beta.17"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",