eslint-plugin-react-x 5.0.1-beta.2 → 5.0.1-beta.4

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 +30 -34
  2. package/package.json +6 -6
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-beta.2";
144
+ var version = "5.0.1-beta.4";
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 },
@@ -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-beta.2",
3
+ "version": "5.0.1-beta.4",
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": "5.0.1-beta.2",
49
- "@eslint-react/jsx": "5.0.1-beta.2",
50
- "@eslint-react/shared": "5.0.1-beta.2",
51
- "@eslint-react/var": "5.0.1-beta.2",
52
- "@eslint-react/core": "5.0.1-beta.2"
48
+ "@eslint-react/ast": "5.0.1-beta.4",
49
+ "@eslint-react/shared": "5.0.1-beta.4",
50
+ "@eslint-react/core": "5.0.1-beta.4",
51
+ "@eslint-react/var": "5.0.1-beta.4",
52
+ "@eslint-react/jsx": "5.0.1-beta.4"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/react": "^19.2.14",