eslint-plugin-react-debug 2.7.4-beta.1 → 2.7.4-beta.10

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 +10 -0
  2. package/dist/index.js +21 -20
  3. package/package.json +7 -7
package/README.md CHANGED
@@ -38,6 +38,16 @@ export default defineConfig(
38
38
  );
39
39
  ```
40
40
 
41
+ > [!WARNING]
42
+ > Debug rules report `React` patterns for code metrics, transformations, or custom tooling. These are not included in the unified plugin by default.
43
+
44
+ - [`class-component`](./debug-class-component) - Reports all class components
45
+ - [`function-component`](./debug-function-component) - Reports all function components
46
+ - [`hook`](./debug-hook) - Reports all `React` hooks
47
+ - [`is-from-react`](./debug-is-from-react) - Reports identifiers initialized from `React`
48
+ - [`is-from-ref`](./debug-is-from-ref) - Reports identifiers initialized or derived from refs
49
+ - [`jsx`](./debug-jsx) - Reports all `JSX` elements and fragments
50
+
41
51
  ## Rules
42
52
 
43
53
  <https://eslint-react.xyz/docs/rules/overview#debug-rules>
package/dist/index.js CHANGED
@@ -9,9 +9,9 @@ import { P, match } from "ts-pattern";
9
9
  var __defProp = Object.defineProperty;
10
10
  var __exportAll = (all, symbols) => {
11
11
  let target = {};
12
- for (var name$2 in all) {
13
- __defProp(target, name$2, {
14
- get: all[name$2],
12
+ for (var name in all) {
13
+ __defProp(target, name, {
14
+ get: all[name],
15
15
  enumerable: true
16
16
  });
17
17
  }
@@ -41,7 +41,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
41
41
  //#endregion
42
42
  //#region package.json
43
43
  var name = "eslint-plugin-react-debug";
44
- var version = "2.7.4-beta.1";
44
+ var version = "2.7.4-beta.10";
45
45
 
46
46
  //#endregion
47
47
  //#region src/utils/create-rule.ts
@@ -73,10 +73,10 @@ var class_component_default = createRule({
73
73
  function create$4(context) {
74
74
  const { ctx, visitor } = useComponentCollectorLegacy(context);
75
75
  return defineRuleListener(visitor, { "Program:exit"(program) {
76
- for (const { name: name$2 = "anonymous", node: component } of ctx.getAllComponents(program)) context.report({
76
+ for (const { name = "anonymous", node: component } of ctx.getAllComponents(program)) context.report({
77
77
  messageId: "classComponent",
78
78
  node: component,
79
- data: { json: stringify({ name: name$2 }) }
79
+ data: { json: stringify({ name }) }
80
80
  });
81
81
  } });
82
82
  }
@@ -102,11 +102,11 @@ function create$3(context) {
102
102
  hint: DEFAULT_COMPONENT_DETECTION_HINT
103
103
  });
104
104
  return defineRuleListener(visitor, { "Program:exit"(program) {
105
- for (const { name: name$2 = "anonymous", node, displayName, flag, hookCalls } of ctx.getAllComponents(program)) context.report({
105
+ for (const { name = "anonymous", node, displayName, flag, hookCalls } of ctx.getAllComponents(program)) context.report({
106
106
  messageId: "functionComponent",
107
107
  node,
108
108
  data: { json: stringify({
109
- name: name$2,
109
+ name,
110
110
  displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
111
111
  forwardRef: (flag & ComponentFlag.ForwardRef) > 0n,
112
112
  hookCalls: hookCalls.length,
@@ -133,11 +133,11 @@ var hook_default = createRule({
133
133
  function create$2(context) {
134
134
  const { ctx, visitor } = useHookCollector(context);
135
135
  return defineRuleListener(visitor, { "Program:exit"(program) {
136
- for (const { name: name$2, node, hookCalls } of ctx.getAllHooks(program)) context.report({
136
+ for (const { name, node, hookCalls } of ctx.getAllHooks(program)) context.report({
137
137
  messageId: "hook",
138
138
  node,
139
139
  data: { json: stringify({
140
- name: name$2,
140
+ name,
141
141
  hookCalls: hookCalls.length
142
142
  }) }
143
143
  });
@@ -162,13 +162,13 @@ function create$1(context) {
162
162
  const { importSource } = getSettingsFromContext(context);
163
163
  function visitorFunction(node) {
164
164
  if (node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name) return;
165
- const name$2 = node.name;
166
- if (!isFromReact(node, importSource, context.sourceCode.getScope(node))) return;
165
+ const name = node.name;
166
+ if (!isFromReact(node, context.sourceCode.getScope(node), importSource)) return;
167
167
  context.report({
168
168
  messageId: "isFromReact",
169
169
  node,
170
170
  data: { json: stringify({
171
- name: name$2,
171
+ name,
172
172
  importSource
173
173
  }) }
174
174
  });
@@ -181,16 +181,16 @@ function create$1(context) {
181
181
  /**
182
182
  * Check if an identifier node is initialized from React
183
183
  * @param node The identifier node to check
184
- * @param importSource The import source to check against
185
184
  * @param initialScope Initial scope to search for the identifier
185
+ * @param importSource The import source to check against
186
186
  * @returns Whether the identifier node is initialized from React
187
187
  */
188
- function isFromReact(node, importSource, initialScope) {
189
- const name$2 = node.name;
188
+ function isFromReact(node, initialScope, importSource = "react") {
189
+ const name = node.name;
190
190
  switch (true) {
191
191
  case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return isInitializedFromReact(node.parent.object.name, initialScope, importSource);
192
192
  case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return isInitializedFromReact(node.parent.object.name, initialScope, importSource);
193
- default: return isInitializedFromReact(name$2, initialScope, importSource);
193
+ default: return isInitializedFromReact(name, initialScope, importSource);
194
194
  }
195
195
  }
196
196
 
@@ -215,13 +215,13 @@ function create(context) {
215
215
  ...jsxConfigFromContext,
216
216
  ...jsxConfigFromAnnotation
217
217
  };
218
- function getReportDescriptor(context$1) {
218
+ function getReportDescriptor(context) {
219
219
  return (node) => ({
220
220
  messageId: "jsx",
221
221
  node,
222
222
  data: { json: stringify({
223
- kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => isJsxFragmentElement(context$1, n, jsxConfig) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
224
- type: getJsxElementType(context$1, node),
223
+ kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => isJsxFragmentElement(context, n, jsxConfig) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
224
+ type: getJsxElementType(context, node),
225
225
  jsx: match(jsxConfig.jsx).with(JsxEmit.None, () => "none").with(JsxEmit.ReactJSX, () => "react-jsx").with(JsxEmit.ReactJSXDev, () => "react-jsx-dev").with(JsxEmit.React, () => "react").with(JsxEmit.ReactNative, () => "react-native").with(JsxEmit.Preserve, () => "preserve").otherwise(() => "unknown"),
226
226
  jsxFactory: jsxConfig.jsxFactory,
227
227
  jsxFragmentFactory: jsxConfig.jsxFragmentFactory,
@@ -245,6 +245,7 @@ const plugin = {
245
245
  ["function-component"]: function_component_default,
246
246
  ["hook"]: hook_default,
247
247
  ["is-from-react"]: is_from_react_default,
248
+ ["is-from-ref"]: is_from_react_default,
248
249
  ["jsx"]: jsx_default
249
250
  }
250
251
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-debug",
3
- "version": "2.7.4-beta.1",
3
+ "version": "2.7.4-beta.10",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -44,16 +44,16 @@
44
44
  "@typescript-eslint/utils": "^8.53.1",
45
45
  "string-ts": "^2.3.1",
46
46
  "ts-pattern": "^5.9.0",
47
- "@eslint-react/ast": "2.7.4-beta.1",
48
- "@eslint-react/core": "2.7.4-beta.1",
49
- "@eslint-react/eff": "2.7.4-beta.1",
50
- "@eslint-react/var": "2.7.4-beta.1",
51
- "@eslint-react/shared": "2.7.4-beta.1"
47
+ "@eslint-react/ast": "2.7.4-beta.10",
48
+ "@eslint-react/core": "2.7.4-beta.10",
49
+ "@eslint-react/eff": "2.7.4-beta.10",
50
+ "@eslint-react/var": "2.7.4-beta.10",
51
+ "@eslint-react/shared": "2.7.4-beta.10"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/react": "^19.2.9",
55
55
  "@types/react-dom": "^19.2.3",
56
- "tsdown": "^0.20.0-beta.4",
56
+ "tsdown": "^0.20.1",
57
57
  "@local/configs": "0.0.0"
58
58
  },
59
59
  "peerDependencies": {