eslint-plugin-react-x 3.0.0-next.16 → 3.0.0-next.18

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 +22 -18
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -69,7 +69,7 @@ const rules$7 = {
69
69
  //#endregion
70
70
  //#region package.json
71
71
  var name$6 = "eslint-plugin-react-x";
72
- var version = "3.0.0-next.16";
72
+ var version = "3.0.0-next.18";
73
73
 
74
74
  //#endregion
75
75
  //#region src/utils/create-rule.ts
@@ -2762,8 +2762,9 @@ var no_unstable_context_value_default = createRule({
2762
2762
  defaultOptions: []
2763
2763
  });
2764
2764
  function create$17(context) {
2765
- const { isCompilerEnabled, version } = getSettingsFromContext(context);
2766
- 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 {};
2767
2768
  const isReact18OrBelow = compare(version, "19.0.0", "<");
2768
2769
  const { ctx, visitor } = core.useComponentCollector(context);
2769
2770
  const constructions = /* @__PURE__ */ new WeakMap();
@@ -2774,7 +2775,7 @@ function create$17(context) {
2774
2775
  if (!isContextName(selfName, isReact18OrBelow)) return;
2775
2776
  const functionEntry = ctx.getCurrentEntry();
2776
2777
  if (functionEntry == null) return;
2777
- if (isCompilerEnabled && ast.isDirectiveInFunction(functionEntry.node, "use memo")) return;
2778
+ if (compilationMode === "annotation" && ast.isDirectiveInFunction(functionEntry.node, "use memo")) return;
2778
2779
  const attribute = node.attributes.find((attribute) => attribute.type === AST_NODE_TYPES.JSXAttribute && attribute.name.name === "value");
2779
2780
  if (attribute == null || !("value" in attribute)) return;
2780
2781
  const value = attribute.value;
@@ -2786,18 +2787,20 @@ function create$17(context) {
2786
2787
  getOrElseUpdate(constructions, functionEntry.node, () => []).push(construction);
2787
2788
  },
2788
2789
  "Program:exit"(program) {
2789
- for (const { node: component, directives } of ctx.getAllComponents(program)) for (const construction of constructions.get(component) ?? []) {
2790
- if (directives.some((d) => d.directive === "use memo")) return;
2791
- const { kind, node: constructionNode } = construction;
2792
- const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
2793
- context.report({
2794
- messageId: "unstableContextValue",
2795
- node: constructionNode,
2796
- data: {
2797
- kind: ast.getHumanReadableKind(constructionNode),
2798
- suggestion
2799
- }
2800
- });
2790
+ for (const { node: component, directives } of ctx.getAllComponents(program)) {
2791
+ if (compilationMode === "annotation" && directives.some((d) => d.directive === "use memo")) continue;
2792
+ for (const construction of constructions.get(component) ?? []) {
2793
+ const { kind, node: constructionNode } = construction;
2794
+ const suggestion = kind === "function" ? "Consider wrapping it in a useCallback hook." : "Consider wrapping it in a useMemo hook.";
2795
+ context.report({
2796
+ messageId: "unstableContextValue",
2797
+ node: constructionNode,
2798
+ data: {
2799
+ kind: ast.getHumanReadableKind(constructionNode),
2800
+ suggestion
2801
+ }
2802
+ });
2803
+ }
2801
2804
  }
2802
2805
  }
2803
2806
  });
@@ -2840,8 +2843,9 @@ function extractIdentifier(node) {
2840
2843
  return null;
2841
2844
  }
2842
2845
  function create$16(context, [options]) {
2843
- const { isCompilerEnabled } = getSettingsFromContext(context);
2844
- if (isCompilerEnabled && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2846
+ const { compilationMode } = getSettingsFromContext(context);
2847
+ if (compilationMode === "infer" || compilationMode === "all") return {};
2848
+ if (compilationMode === "annotation" && ast.isDirectiveInFile(context.sourceCode.ast, "use memo")) return {};
2845
2849
  const { ctx, visitor } = core.useComponentCollector(context);
2846
2850
  const declarators = /* @__PURE__ */ new WeakMap();
2847
2851
  const { safeDefaultProps = [] } = options;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "3.0.0-next.16",
3
+ "version": "3.0.0-next.18",
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-next.16",
49
- "@eslint-react/core": "3.0.0-next.16",
50
- "@eslint-react/eff": "3.0.0-next.16",
51
- "@eslint-react/shared": "3.0.0-next.16",
52
- "@eslint-react/var": "3.0.0-next.16"
48
+ "@eslint-react/ast": "3.0.0-next.18",
49
+ "@eslint-react/core": "3.0.0-next.18",
50
+ "@eslint-react/eff": "3.0.0-next.18",
51
+ "@eslint-react/var": "3.0.0-next.18",
52
+ "@eslint-react/shared": "3.0.0-next.18"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",