eslint-plugin-react-x 4.0.2-beta.5 → 4.0.2-beta.6

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 -18
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -147,7 +147,7 @@ const rules$7 = {
147
147
  //#endregion
148
148
  //#region package.json
149
149
  var name$6 = "eslint-plugin-react-x";
150
- var version = "4.0.2-beta.5";
150
+ var version = "4.0.2-beta.6";
151
151
 
152
152
  //#endregion
153
153
  //#region src/utils/create-rule.ts
@@ -2952,8 +2952,8 @@ const RULE_NAME$27 = "no-nested-lazy-component-declarations";
2952
2952
  var no_nested_lazy_component_declarations_default = createRule({
2953
2953
  meta: {
2954
2954
  type: "problem",
2955
- docs: { description: "Disallows nesting lazy component declarations inside other components." },
2956
- messages: { default: "Do not declare lazy components inside other components. Instead, always declare them at the top level of your module." },
2955
+ docs: { description: "Disallows nesting lazy component declarations inside other components or hooks." },
2956
+ messages: { default: "Do not declare lazy components inside other components or hooks. Instead, always declare them at the top level of your module." },
2957
2957
  schema: []
2958
2958
  },
2959
2959
  name: RULE_NAME$27,
@@ -2961,25 +2961,22 @@ var no_nested_lazy_component_declarations_default = createRule({
2961
2961
  defaultOptions: []
2962
2962
  });
2963
2963
  function create$27(context) {
2964
- const hint = core.ComponentDetectionHint.None;
2965
- const collector = core.getComponentCollector(context, { hint });
2966
- const collectorLegacy = core.getComponentCollectorLegacy(context);
2967
- const lazyComponentDeclarations = /* @__PURE__ */ new Set();
2968
- return defineRuleListener(collector.visitor, collectorLegacy.visitor, {
2964
+ const fCollector = core.getComponentCollector(context);
2965
+ const cCollector = core.getComponentCollectorLegacy(context);
2966
+ const hCollector = core.getHookCollector(context);
2967
+ const lazyCalls = /* @__PURE__ */ new Set();
2968
+ return defineRuleListener(fCollector.visitor, cCollector.visitor, hCollector.visitor, {
2969
2969
  ImportExpression(node) {
2970
2970
  const lazyCall = ast.findParent(node, (n) => core.isLazyCall(context, n));
2971
- if (lazyCall != null) lazyComponentDeclarations.add(lazyCall);
2971
+ if (lazyCall != null) lazyCalls.add(lazyCall);
2972
2972
  },
2973
2973
  "Program:exit"(program) {
2974
- const functionComponents = collector.api.getAllComponents(program);
2975
- const classComponents = collectorLegacy.api.getAllComponents(program);
2976
- for (const lazy of lazyComponentDeclarations) if (ast.findParent(lazy, (n) => {
2977
- if (ast.isJSX(n)) return true;
2978
- if (n.type === AST_NODE_TYPES.CallExpression) return core.isHookCall(n) || core.isCreateElementCall(context, n) || core.isCreateContextCall(context, n);
2979
- if (ast.isFunction(n)) return functionComponents.some((c) => c.node === n);
2980
- if (ast.isClass(n)) return classComponents.some((c) => c.node === n);
2981
- return false;
2982
- }) != null) context.report({
2974
+ const significantParents = [
2975
+ ...fCollector.api.getAllComponents(program),
2976
+ ...hCollector.api.getAllHooks(program),
2977
+ ...cCollector.api.getAllComponents(program)
2978
+ ];
2979
+ for (const lazy of lazyCalls) if (ast.findParent(lazy, (n) => significantParents.some((p) => p.node === n))) context.report({
2983
2980
  messageId: "default",
2984
2981
  node: lazy
2985
2982
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "4.0.2-beta.5",
3
+ "version": "4.0.2-beta.6",
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
  "string-ts": "^2.3.1",
46
46
  "ts-api-utils": "^2.5.0",
47
47
  "ts-pattern": "^5.9.0",
48
- "@eslint-react/ast": "4.0.2-beta.5",
49
- "@eslint-react/jsx": "4.0.2-beta.5",
50
- "@eslint-react/core": "4.0.2-beta.5",
51
- "@eslint-react/var": "4.0.2-beta.5",
52
- "@eslint-react/shared": "4.0.2-beta.5"
48
+ "@eslint-react/ast": "4.0.2-beta.6",
49
+ "@eslint-react/core": "4.0.2-beta.6",
50
+ "@eslint-react/shared": "4.0.2-beta.6",
51
+ "@eslint-react/jsx": "4.0.2-beta.6",
52
+ "@eslint-react/var": "4.0.2-beta.6"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",