eslint-plugin-react-x 5.0.1-next.2 → 5.0.2-beta.1

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 +38 -42
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -141,32 +141,10 @@ const rules$7 = {
141
141
  //#endregion
142
142
  //#region package.json
143
143
  var name$6 = "eslint-plugin-react-x";
144
- var version = "5.0.1-next.2";
144
+ var version = "5.0.2-beta.1";
145
145
 
146
146
  //#endregion
147
- //#region src/utils/create-rule.ts
148
- function getDocsUrl(ruleName) {
149
- return `https://eslint-react.xyz/docs/rules/${ruleName}`;
150
- }
151
- const createRule = ESLintUtils.RuleCreator(getDocsUrl);
152
-
153
- //#endregion
154
- //#region src/rules/component-hook-factories/component-hook-factories.ts
155
- const RULE_NAME$48 = "component-hook-factories";
156
- var component_hook_factories_default = createRule({
157
- meta: {
158
- type: "problem",
159
- docs: { description: "Disallows higher order functions that define components or hooks inside them." },
160
- messages: {
161
- component: "Do not define component '{{name}}' inside a function. Components should be defined at the module level. Move it to the top level.",
162
- hook: "Do not define hook '{{name}}' inside a function. Hooks should be defined at the module level. Move it to the top level."
163
- },
164
- schema: []
165
- },
166
- name: RULE_NAME$48,
167
- create: create$48,
168
- defaultOptions: []
169
- });
147
+ //#region src/rules/component-hook-factories/lib.ts
170
148
  /**
171
149
  * Check if a function parameter has a type annotation that looks like a React component type.
172
150
  * Matches types like ComponentType, React.ComponentType, FC, React.FC, etc.
@@ -203,13 +181,31 @@ function isHigherOrderComponent(fn) {
203
181
  return false;
204
182
  });
205
183
  }
206
- /**
207
- * Check if a node is inside a test mock callback (vi.mock or jest.mock).
208
- * @param node The node to check.
209
- */
210
- function isInsideTestMockCallback(node) {
211
- return ast.findParent(node, ast.isTestMockCallback) != null;
184
+
185
+ //#endregion
186
+ //#region src/utils/create-rule.ts
187
+ function getDocsUrl(ruleName) {
188
+ return `https://eslint-react.xyz/docs/rules/${ruleName}`;
212
189
  }
190
+ const createRule = ESLintUtils.RuleCreator(getDocsUrl);
191
+
192
+ //#endregion
193
+ //#region src/rules/component-hook-factories/component-hook-factories.ts
194
+ const RULE_NAME$48 = "component-hook-factories";
195
+ var component_hook_factories_default = createRule({
196
+ meta: {
197
+ type: "problem",
198
+ docs: { description: "Disallows higher order functions that define components or hooks inside them." },
199
+ messages: {
200
+ component: "Do not define component '{{name}}' inside a function. Components should be defined at the module level. Move it to the top level.",
201
+ hook: "Do not define hook '{{name}}' inside a function. Hooks should be defined at the module level. Move it to the top level."
202
+ },
203
+ schema: []
204
+ },
205
+ name: RULE_NAME$48,
206
+ create: create$48,
207
+ defaultOptions: []
208
+ });
213
209
  function create$48(context) {
214
210
  const hint = core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNumberValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithBooleanValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithNullValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithStringValue | core.FunctionComponentDetectionHint.DoNotIncludeJsxWithUndefinedValue | core.FunctionComponentDetectionHint.RequireBothSidesOfLogicalExpressionToBeJsx | core.FunctionComponentDetectionHint.RequireBothBranchesOfConditionalExpressionToBeJsx | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayPatternElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayExpressionElement | core.FunctionComponentDetectionHint.DoNotIncludeFunctionDefinedAsArrayMapCallback;
215
211
  const fCollector = core.getFunctionComponentCollector(context, { hint });
@@ -224,7 +220,7 @@ function create$48(context) {
224
220
  if (name == null) continue;
225
221
  const parentFn = ast.findParent(node, ast.isFunction);
226
222
  if (parentFn == null) continue;
227
- if (isInsideTestMockCallback(node)) continue;
223
+ if (ast.findParent(node, ast.isTestMockCallback) != null) continue;
228
224
  if (isHigherOrderComponent(parentFn)) continue;
229
225
  if (reported.has(node)) continue;
230
226
  context.report({
@@ -237,7 +233,7 @@ function create$48(context) {
237
233
  for (const { name = "unknown", node } of cComponents) {
238
234
  const parentFn = ast.findParent(node, ast.isFunction);
239
235
  if (parentFn == null) continue;
240
- if (isInsideTestMockCallback(node)) continue;
236
+ if (ast.findParent(node, ast.isTestMockCallback) != null) continue;
241
237
  if (isHigherOrderComponent(parentFn)) continue;
242
238
  context.report({
243
239
  data: { name },
@@ -247,7 +243,7 @@ function create$48(context) {
247
243
  }
248
244
  for (const { name, node } of hooks) {
249
245
  if (ast.findParent(node, ast.isFunction) == null) continue;
250
- if (isInsideTestMockCallback(node)) continue;
246
+ if (ast.findParent(node, ast.isTestMockCallback) != null) continue;
251
247
  if (reported.has(node)) continue;
252
248
  context.report({
253
249
  data: { name },
@@ -2615,10 +2611,10 @@ var no_missing_key_default = createRule({
2615
2611
  create: create$22,
2616
2612
  defaultOptions: []
2617
2613
  });
2618
- function create$22(ctx) {
2614
+ function create$22(context) {
2619
2615
  let inChildrenToArray = false;
2620
2616
  function check(node) {
2621
- if (node.type === AST_NODE_TYPES.JSXElement) return !hasAttribute(ctx, node, "key") ? {
2617
+ if (node.type === AST_NODE_TYPES.JSXElement) return !hasAttribute(context, node, "key") ? {
2622
2618
  messageId: "default",
2623
2619
  node
2624
2620
  } : null;
@@ -2652,13 +2648,13 @@ function create$22(ctx) {
2652
2648
  if (inChildrenToArray) return;
2653
2649
  const elements = node.elements.filter(ast.is(AST_NODE_TYPES.JSXElement));
2654
2650
  if (elements.length === 0) return;
2655
- for (const el of elements) if (!hasAttribute(ctx, el, "key")) ctx.report({
2651
+ for (const el of elements) if (!hasAttribute(context, el, "key")) context.report({
2656
2652
  messageId: "default",
2657
2653
  node: el
2658
2654
  });
2659
2655
  },
2660
2656
  CallExpression(node) {
2661
- inChildrenToArray ||= core.isChildrenToArrayCall(ctx, node);
2657
+ inChildrenToArray ||= core.isChildrenToArrayCall(context, node);
2662
2658
  if (inChildrenToArray) return;
2663
2659
  if (node.callee.type !== AST_NODE_TYPES.MemberExpression) return;
2664
2660
  if (node.callee.property.type !== AST_NODE_TYPES.Identifier) return;
@@ -2667,15 +2663,15 @@ function create$22(ctx) {
2667
2663
  if (idx < 0) return;
2668
2664
  const cb = node.arguments[idx];
2669
2665
  if (!ast.isFunction(cb)) return;
2670
- if (cb.body.type === AST_NODE_TYPES.BlockStatement) checkBlock(cb.body).forEach(report(ctx));
2671
- else report(ctx)(checkExpr(cb.body));
2666
+ if (cb.body.type === AST_NODE_TYPES.BlockStatement) checkBlock(cb.body).forEach(report(context));
2667
+ else report(context)(checkExpr(cb.body));
2672
2668
  },
2673
2669
  "CallExpression:exit"(node) {
2674
- if (core.isChildrenToArrayCall(ctx, node)) inChildrenToArray = false;
2670
+ if (core.isChildrenToArrayCall(context, node)) inChildrenToArray = false;
2675
2671
  },
2676
2672
  JSXFragment(node) {
2677
2673
  if (inChildrenToArray) return;
2678
- if (node.parent.type === AST_NODE_TYPES.ArrayExpression) ctx.report({
2674
+ if (node.parent.type === AST_NODE_TYPES.ArrayExpression) context.report({
2679
2675
  messageId: "unexpectedFragmentSyntax",
2680
2676
  node
2681
2677
  });
@@ -3000,7 +2996,7 @@ function create$15(context) {
3000
2996
  if (ast.isFunctionEmpty(node)) continue;
3001
2997
  if (WELL_KNOWN_HOOKS.includes(name)) continue;
3002
2998
  if (containsUseComments(context, node)) continue;
3003
- if (ast.findParent(node, ast.isViMockCallback) != null) continue;
2999
+ if (ast.findParent(node, ast.isTestMockCallback) != null) continue;
3004
3000
  context.report({
3005
3001
  data: { name },
3006
3002
  messageId: "default",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-x",
3
- "version": "5.0.1-next.2",
3
+ "version": "5.0.2-beta.1",
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,23 +45,23 @@
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.0.1-next.2",
49
- "@eslint-react/shared": "5.0.1-next.2",
50
- "@eslint-react/ast": "5.0.1-next.2",
51
- "@eslint-react/var": "5.0.1-next.2",
52
- "@eslint-react/jsx": "5.0.1-next.2"
48
+ "@eslint-react/jsx": "5.0.2-beta.1",
49
+ "@eslint-react/shared": "5.0.2-beta.1",
50
+ "@eslint-react/ast": "5.0.2-beta.1",
51
+ "@eslint-react/var": "5.0.2-beta.1",
52
+ "@eslint-react/core": "5.0.2-beta.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",
56
56
  "@types/react-dom": "^19.2.3",
57
57
  "eslint": "^10.2.0",
58
58
  "tsdown": "^0.21.7",
59
- "tsl-dx": "^0.10.2",
59
+ "tsl-dx": "^0.10.3",
60
60
  "@local/configs": "0.0.0",
61
61
  "@local/eff": "3.0.0-beta.72"
62
62
  },
63
63
  "peerDependencies": {
64
- "eslint": "^10.0.0",
64
+ "eslint": "^10.2.0",
65
65
  "typescript": "*"
66
66
  },
67
67
  "engines": {