eslint-plugin-react-debug 2.8.2-next.4 → 2.8.2-next.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 +68 -28
  2. package/package.json +6 -7
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ const rules = {
34
34
  "react-debug/function-component": "warn",
35
35
  "react-debug/hook": "warn",
36
36
  "react-debug/is-from-react": "warn",
37
+ "react-debug/is-from-ref": "warn",
37
38
  "react-debug/jsx": "warn"
38
39
  };
39
40
  const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
@@ -41,7 +42,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
41
42
  //#endregion
42
43
  //#region package.json
43
44
  var name = "eslint-plugin-react-debug";
44
- var version = "2.8.2-next.4";
45
+ var version = "2.8.2-next.6";
45
46
 
46
47
  //#endregion
47
48
  //#region src/utils/create-rule.ts
@@ -58,23 +59,23 @@ function stringify(value) {
58
59
 
59
60
  //#endregion
60
61
  //#region src/rules/class-component.ts
61
- const RULE_NAME$4 = "class-component";
62
+ const RULE_NAME$5 = "class-component";
62
63
  var class_component_default = createRule({
63
64
  meta: {
64
65
  type: "problem",
65
66
  docs: { description: "Reports all class components in JSON format." },
66
- messages: { classComponent: "{{json}}" },
67
+ messages: { default: "{{json}}" },
67
68
  schema: []
68
69
  },
69
- name: RULE_NAME$4,
70
- create: create$4,
70
+ name: RULE_NAME$5,
71
+ create: create$5,
71
72
  defaultOptions: []
72
73
  });
73
- function create$4(context) {
74
+ function create$5(context) {
74
75
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
75
76
  return defineRuleListener(visitor, { "Program:exit"(program) {
76
77
  for (const { name = "anonymous", node: component } of ctx.getAllComponents(program)) context.report({
77
- messageId: "classComponent",
78
+ messageId: "default",
78
79
  node: component,
79
80
  data: { json: stringify({ name }) }
80
81
  });
@@ -83,26 +84,26 @@ function create$4(context) {
83
84
 
84
85
  //#endregion
85
86
  //#region src/rules/function-component.ts
86
- const RULE_NAME$3 = "function-component";
87
+ const RULE_NAME$4 = "function-component";
87
88
  var function_component_default = createRule({
88
89
  meta: {
89
90
  type: "problem",
90
91
  docs: { description: "Reports all function components in JSON format." },
91
- messages: { functionComponent: "{{json}}" },
92
+ messages: { default: "{{json}}" },
92
93
  schema: []
93
94
  },
94
- name: RULE_NAME$3,
95
- create: create$3,
95
+ name: RULE_NAME$4,
96
+ create: create$4,
96
97
  defaultOptions: []
97
98
  });
98
- function create$3(context) {
99
+ function create$4(context) {
99
100
  const { ctx, visitor } = core.useComponentCollector(context, {
100
101
  collectDisplayName: true,
101
102
  hint: core.DEFAULT_COMPONENT_DETECTION_HINT
102
103
  });
103
104
  return defineRuleListener(visitor, { "Program:exit"(program) {
104
105
  for (const { name = "anonymous", node, displayName, flag, hookCalls } of ctx.getAllComponents(program)) context.report({
105
- messageId: "functionComponent",
106
+ messageId: "default",
106
107
  node,
107
108
  data: { json: stringify({
108
109
  name,
@@ -117,23 +118,23 @@ function create$3(context) {
117
118
 
118
119
  //#endregion
119
120
  //#region src/rules/hook.ts
120
- const RULE_NAME$2 = "hook";
121
+ const RULE_NAME$3 = "hook";
121
122
  var hook_default = createRule({
122
123
  meta: {
123
124
  type: "problem",
124
125
  docs: { description: "Reports all React Hooks in JSON format." },
125
- messages: { hook: "{{json}}" },
126
+ messages: { default: "{{json}}" },
126
127
  schema: []
127
128
  },
128
- name: RULE_NAME$2,
129
- create: create$2,
129
+ name: RULE_NAME$3,
130
+ create: create$3,
130
131
  defaultOptions: []
131
132
  });
132
- function create$2(context) {
133
+ function create$3(context) {
133
134
  const { ctx, visitor } = core.useHookCollector(context);
134
135
  return defineRuleListener(visitor, { "Program:exit"(program) {
135
136
  for (const { name, node, hookCalls } of ctx.getAllHooks(program)) context.report({
136
- messageId: "hook",
137
+ messageId: "default",
137
138
  node,
138
139
  data: { json: stringify({
139
140
  name,
@@ -145,26 +146,26 @@ function create$2(context) {
145
146
 
146
147
  //#endregion
147
148
  //#region src/rules/is-from-react.ts
148
- const RULE_NAME$1 = "is-from-react";
149
+ const RULE_NAME$2 = "is-from-react";
149
150
  var is_from_react_default = createRule({
150
151
  meta: {
151
152
  type: "problem",
152
153
  docs: { description: "Reports all identifiers initialized from React in JSON format." },
153
- messages: { isFromReact: "{{json}}" },
154
+ messages: { default: "{{json}}" },
154
155
  schema: []
155
156
  },
156
- name: RULE_NAME$1,
157
- create: create$1,
157
+ name: RULE_NAME$2,
158
+ create: create$2,
158
159
  defaultOptions: []
159
160
  });
160
- function create$1(context) {
161
+ function create$2(context) {
161
162
  const { importSource } = getSettingsFromContext(context);
162
163
  function visitorFunction(node) {
163
164
  if (node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name) return;
164
165
  const name = node.name;
165
166
  if (!isFromReact(node, context.sourceCode.getScope(node), importSource)) return;
166
167
  context.report({
167
- messageId: "isFromReact",
168
+ messageId: "default",
168
169
  node,
169
170
  data: { json: stringify({
170
171
  name,
@@ -193,6 +194,45 @@ function isFromReact(node, initialScope, importSource = "react") {
193
194
  }
194
195
  }
195
196
 
197
+ //#endregion
198
+ //#region src/rules/is-from-ref.ts
199
+ const RULE_NAME$1 = "is-from-ref";
200
+ var is_from_ref_default = createRule({
201
+ meta: {
202
+ type: "problem",
203
+ docs: { description: "Reports all identifiers initialized or derived from refs in JSON format." },
204
+ messages: { default: "{{json}}" },
205
+ schema: []
206
+ },
207
+ name: RULE_NAME$1,
208
+ create: create$1,
209
+ defaultOptions: []
210
+ });
211
+ function create$1(context) {
212
+ function visitorFunction(node) {
213
+ if (isFromRef(node, context.sourceCode.getScope(node))) {
214
+ const json = stringify({ name: node.name });
215
+ context.report({
216
+ messageId: "default",
217
+ node,
218
+ data: { json }
219
+ });
220
+ }
221
+ }
222
+ return {
223
+ Identifier: visitorFunction,
224
+ JSXIdentifier: visitorFunction
225
+ };
226
+ }
227
+ function isFromRef(node, initialScope) {
228
+ const name = node.name;
229
+ switch (true) {
230
+ case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return core.isInitializedFromRef(node.parent.object.name, initialScope);
231
+ case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return core.isInitializedFromRef(node.parent.object.name, initialScope);
232
+ default: return core.isInitializedFromRef(name, initialScope);
233
+ }
234
+ }
235
+
196
236
  //#endregion
197
237
  //#region src/rules/jsx.ts
198
238
  const { JsxEmit } = core;
@@ -201,7 +241,7 @@ var jsx_default = createRule({
201
241
  meta: {
202
242
  type: "problem",
203
243
  docs: { description: "Reports all JSX elements and fragments in JSON format." },
204
- messages: { jsx: "{{json}}" },
244
+ messages: { default: "{{json}}" },
205
245
  schema: []
206
246
  },
207
247
  name: RULE_NAME,
@@ -217,7 +257,7 @@ function create(context) {
217
257
  };
218
258
  function getReportDescriptor(context) {
219
259
  return (node) => ({
220
- messageId: "jsx",
260
+ messageId: "default",
221
261
  node,
222
262
  data: { json: stringify({
223
263
  kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => core.isJsxFragmentElement(context, n, jsxConfig) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
@@ -245,7 +285,7 @@ const plugin = {
245
285
  ["function-component"]: function_component_default,
246
286
  ["hook"]: hook_default,
247
287
  ["is-from-react"]: is_from_react_default,
248
- ["is-from-ref"]: is_from_react_default,
288
+ ["is-from-ref"]: is_from_ref_default,
249
289
  ["jsx"]: jsx_default
250
290
  }
251
291
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-debug",
3
- "version": "2.8.2-next.4",
3
+ "version": "2.8.2-next.6",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -42,13 +42,12 @@
42
42
  "@typescript-eslint/type-utils": "^8.54.0",
43
43
  "@typescript-eslint/types": "^8.54.0",
44
44
  "@typescript-eslint/utils": "^8.54.0",
45
- "string-ts": "^2.3.1",
46
45
  "ts-pattern": "^5.9.0",
47
- "@eslint-react/ast": "2.8.2-next.4",
48
- "@eslint-react/eff": "2.8.2-next.4",
49
- "@eslint-react/shared": "2.8.2-next.4",
50
- "@eslint-react/var": "2.8.2-next.4",
51
- "@eslint-react/core": "2.8.2-next.4"
46
+ "@eslint-react/ast": "2.8.2-next.6",
47
+ "@eslint-react/core": "2.8.2-next.6",
48
+ "@eslint-react/shared": "2.8.2-next.6",
49
+ "@eslint-react/eff": "2.8.2-next.6",
50
+ "@eslint-react/var": "2.8.2-next.6"
52
51
  },
53
52
  "devDependencies": {
54
53
  "@types/react": "^19.2.10",