eslint-plugin-react-debug 4.2.4-beta.0 → 5.0.0-beta.0

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +15 -41
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -38,4 +38,4 @@ export default defineConfig(
38
38
 
39
39
  ## Rules
40
40
 
41
- <https://eslint-react.xyz/docs/rules/overview#debug-rules>
41
+ <https://eslint-react.xyz/docs/rules#debug-rules>
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ var __exportAll = (all, no_symbols) => {
27
27
  //#endregion
28
28
  //#region package.json
29
29
  var name$1 = "eslint-plugin-react-debug";
30
- var version = "4.2.4-beta.0";
30
+ var version = "5.0.0-beta.0";
31
31
 
32
32
  //#endregion
33
33
  //#region src/utils/create-rule.ts
@@ -42,31 +42,6 @@ function stringify(value) {
42
42
  return JSON.stringify(value, null, 2);
43
43
  }
44
44
 
45
- //#endregion
46
- //#region src/rules/class-component/class-component.ts
47
- const RULE_NAME$5 = "class-component";
48
- var class_component_default = createRule({
49
- meta: {
50
- type: "problem",
51
- docs: { description: "Reports all class components in JSON format." },
52
- messages: { default: "{{json}}" },
53
- schema: []
54
- },
55
- name: RULE_NAME$5,
56
- create: create$5,
57
- defaultOptions: []
58
- });
59
- function create$5(context) {
60
- const { api, visitor } = core.getComponentCollectorLegacy(context);
61
- return defineRuleListener(visitor, { "Program:exit"(program) {
62
- for (const { name = "anonymous", node: component } of api.getAllComponents(program)) context.report({
63
- data: { json: stringify({ name }) },
64
- messageId: "default",
65
- node: component
66
- });
67
- } });
68
- }
69
-
70
45
  //#endregion
71
46
  //#region src/rules/function-component/function-component.ts
72
47
  const RULE_NAME$4 = "function-component";
@@ -82,7 +57,7 @@ var function_component_default = createRule({
82
57
  defaultOptions: []
83
58
  });
84
59
  function create$4(context) {
85
- const { api, visitor } = core.getComponentCollector(context, {
60
+ const { api, visitor } = core.getFunctionComponentCollector(context, {
86
61
  collectDisplayName: true,
87
62
  hint: core.DEFAULT_COMPONENT_DETECTION_HINT
88
63
  });
@@ -91,9 +66,9 @@ function create$4(context) {
91
66
  data: { json: stringify({
92
67
  name: name ?? "anonymous",
93
68
  displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
94
- forwardRef: (flag & core.ComponentFlag.ForwardRef) > 0n,
69
+ forwardRef: (flag & core.FunctionComponentFlag.ForwardRef) > 0n,
95
70
  hookCalls: hookCalls.length,
96
- memo: (flag & core.ComponentFlag.Memo) > 0n
71
+ memo: (flag & core.FunctionComponentFlag.Memo) > 0n
97
72
  }) },
98
73
  messageId: "default",
99
74
  node
@@ -173,9 +148,9 @@ function create$2(context) {
173
148
  function isFromReact(node, initialScope, importSource = "react") {
174
149
  const name = node.name;
175
150
  switch (true) {
176
- case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return core.isInitializedFromReact(node.parent.object.name, initialScope, importSource);
177
- case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return core.isInitializedFromReact(node.parent.object.name, initialScope, importSource);
178
- default: return core.isInitializedFromReact(name, initialScope, importSource);
151
+ case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return core.isAPIFromReact(node.parent.object.name, initialScope, importSource);
152
+ case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return core.isAPIFromReact(node.parent.object.name, initialScope, importSource);
153
+ default: return core.isAPIFromReact(name, initialScope, importSource);
179
154
  }
180
155
  }
181
156
 
@@ -195,7 +170,7 @@ var is_from_ref_default = createRule({
195
170
  });
196
171
  function create$1(context) {
197
172
  function visitorFunction(node) {
198
- const refInit = getRefInitNode(node, context.sourceCode.getScope(node));
173
+ const refInit = getRefInitNode(context, node, context.sourceCode.getScope(node));
199
174
  if (refInit != null) {
200
175
  const json = stringify({
201
176
  name: node.name,
@@ -213,28 +188,29 @@ function create$1(context) {
213
188
  JSXIdentifier: visitorFunction
214
189
  });
215
190
  }
216
- function getRefInitNode(node, initialScope) {
191
+ function getRefInitNode(context, node, initialScope) {
217
192
  const name = node.name;
218
193
  switch (true) {
219
- case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return getRefInit(node.parent.object.name, initialScope);
220
- case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return getRefInit(node.parent.object.name, initialScope);
221
- default: return getRefInit(name, initialScope);
194
+ case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return getRefInit(context, node.parent.object.name, initialScope);
195
+ case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return getRefInit(context, node.parent.object.name, initialScope);
196
+ default: return getRefInit(context, name, initialScope);
222
197
  }
223
198
  }
224
199
  /**
225
200
  * Get the init expression of a ref variable
201
+ * @param context The rule context
226
202
  * @param name The variable name
227
203
  * @param initialScope The initial scope
228
204
  * @returns The init expression node if the variable is derived from a ref, or null otherwise
229
205
  */
230
- function getRefInit(name, initialScope) {
206
+ function getRefInit(context, name, initialScope) {
231
207
  for (const { node } of findVariable(initialScope, name)?.defs ?? []) {
232
208
  if (node.type !== AST_NODE_TYPES.VariableDeclarator) continue;
233
209
  const init = node.init;
234
210
  if (init == null) continue;
235
211
  switch (true) {
236
212
  case init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier && (init.object.name === "ref" || init.object.name.endsWith("Ref")): return init;
237
- case init.type === AST_NODE_TYPES.CallExpression && isUseRefCall(init): return init;
213
+ case init.type === AST_NODE_TYPES.CallExpression && isUseRefCall(context, init): return init;
238
214
  }
239
215
  }
240
216
  return null;
@@ -429,7 +405,6 @@ const plugin = {
429
405
  version
430
406
  },
431
407
  rules: {
432
- ["class-component"]: class_component_default,
433
408
  ["function-component"]: function_component_default,
434
409
  ["hook"]: hook_default,
435
410
  ["is-from-react"]: is_from_react_default,
@@ -448,7 +423,6 @@ var all_exports = /* @__PURE__ */ __exportAll({
448
423
  });
449
424
  const name = "react-debug/all";
450
425
  const rules = {
451
- "react-debug/class-component": "warn",
452
426
  "react-debug/function-component": "warn",
453
427
  "react-debug/hook": "warn",
454
428
  "react-debug/is-from-react": "warn",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-debug",
3
- "version": "4.2.4-beta.0",
3
+ "version": "5.0.0-beta.0",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -43,16 +43,16 @@
43
43
  "@typescript-eslint/types": "^8.58.0",
44
44
  "@typescript-eslint/utils": "^8.58.0",
45
45
  "ts-pattern": "^5.9.0",
46
- "@eslint-react/ast": "4.2.4-beta.0",
47
- "@eslint-react/core": "4.2.4-beta.0",
48
- "@eslint-react/jsx": "4.2.4-beta.0",
49
- "@eslint-react/shared": "4.2.4-beta.0",
50
- "@eslint-react/var": "4.2.4-beta.0"
46
+ "@eslint-react/core": "5.0.0-beta.0",
47
+ "@eslint-react/ast": "5.0.0-beta.0",
48
+ "@eslint-react/jsx": "5.0.0-beta.0",
49
+ "@eslint-react/shared": "5.0.0-beta.0",
50
+ "@eslint-react/var": "5.0.0-beta.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",
54
54
  "@types/react-dom": "^19.2.3",
55
- "eslint": "^10.1.0",
55
+ "eslint": "^10.2.0",
56
56
  "tsdown": "^0.21.7",
57
57
  "@local/configs": "0.0.0",
58
58
  "@local/eff": "3.0.0-beta.72"