eslint-plugin-react-debug 1.24.0-beta.1 → 1.24.0-beta.16

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/dist/index.js +17 -13
  2. package/dist/index.mjs +18 -14
  3. package/package.json +12 -13
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var utils = require('@typescript-eslint/utils');
6
6
 
7
7
  // package.json
8
8
  var name = "eslint-plugin-react-debug";
9
- var version = "1.24.0-beta.1";
9
+ var version = "1.24.0-beta.16";
10
10
  var createRule = shared.createRuleForPlugin("debug");
11
11
 
12
12
  // src/rules/class-component.ts
@@ -61,23 +61,31 @@ var function_component_default = createRule({
61
61
  [Symbol.for("rule_features")]: RULE_FEATURES2
62
62
  },
63
63
  messages: {
64
- functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}."
64
+ functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}, displayName: {{displayName}}."
65
65
  },
66
66
  schema: []
67
67
  },
68
68
  name: RULE_NAME2,
69
69
  create(context) {
70
- const { ctx, listeners } = core.useComponentCollector(context);
70
+ const { ctx, listeners } = core.useComponentCollector(
71
+ context,
72
+ core.DEFAULT_COMPONENT_HINT,
73
+ {
74
+ collectDisplayName: true,
75
+ collectHookCalls: true
76
+ }
77
+ );
71
78
  return {
72
79
  ...listeners,
73
80
  "Program:exit"(node) {
74
81
  const components = ctx.getAllComponents(node);
75
- for (const { name: name2 = "anonymous", node: node2, flag, hookCalls } of components.values()) {
82
+ for (const { name: name2 = "anonymous", node: node2, displayName, flag, hookCalls } of components.values()) {
76
83
  context.report({
77
84
  messageId: "functionComponent",
78
85
  node: node2,
79
86
  data: {
80
87
  name: name2,
88
+ displayName: displayName != null ? context.sourceCode.getText(displayName) : "none",
81
89
  forwardRef: (flag & core.ERFunctionComponentFlag.ForwardRef) > 0n,
82
90
  hookCalls: hookCalls.length,
83
91
  memo: (flag & core.ERFunctionComponentFlag.Memo) > 0n
@@ -147,20 +155,16 @@ var is_from_react_default = createRule({
147
155
  },
148
156
  name: RULE_NAME4,
149
157
  create(context) {
150
- const settings = {
151
- importSource: "react",
152
- ...shared.getSettingsFromContext(context),
153
- strictImportCheck: true
154
- };
158
+ const { importSource = "react" } = shared.getSettingsFromContext(context);
155
159
  function isFromReact(node, initialScope) {
156
160
  const name2 = node.name;
157
161
  switch (true) {
158
162
  case (node.parent.type === utils.AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.Identifier):
159
- return core.isInitializedFromReact(node.parent.object.name, initialScope, settings.importSource);
163
+ return core.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
160
164
  case (node.parent.type === utils.AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.JSXIdentifier):
161
- return core.isInitializedFromReact(node.parent.object.name, initialScope, settings.importSource);
165
+ return core.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
162
166
  default:
163
- return core.isInitializedFromReact(name2, initialScope, settings.importSource);
167
+ return core.isInitializedFromReact(name2, importSource, initialScope);
164
168
  }
165
169
  }
166
170
  function visitorFunction(node) {
@@ -180,7 +184,7 @@ var is_from_react_default = createRule({
180
184
  // eslint-disable-next-line eslint-plugin/no-unused-placeholders
181
185
  type: node.type,
182
186
  name: name2,
183
- importSource: settings.importSource
187
+ importSource
184
188
  }
185
189
  });
186
190
  }
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { useComponentCollectorLegacy, useComponentCollector, ERFunctionComponentFlag, useHookCollector, isInitializedFromReact } from '@eslint-react/core';
1
+ import { useComponentCollectorLegacy, useComponentCollector, DEFAULT_COMPONENT_HINT, ERFunctionComponentFlag, useHookCollector, isInitializedFromReact } from '@eslint-react/core';
2
2
  import { createRuleForPlugin, getSettingsFromContext } from '@eslint-react/shared';
3
3
  import { AST_NODE_TYPES } from '@typescript-eslint/utils';
4
4
 
5
5
  // package.json
6
6
  var name = "eslint-plugin-react-debug";
7
- var version = "1.24.0-beta.1";
7
+ var version = "1.24.0-beta.16";
8
8
  var createRule = createRuleForPlugin("debug");
9
9
 
10
10
  // src/rules/class-component.ts
@@ -59,23 +59,31 @@ var function_component_default = createRule({
59
59
  [Symbol.for("rule_features")]: RULE_FEATURES2
60
60
  },
61
61
  messages: {
62
- functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}."
62
+ functionComponent: "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}, displayName: {{displayName}}."
63
63
  },
64
64
  schema: []
65
65
  },
66
66
  name: RULE_NAME2,
67
67
  create(context) {
68
- const { ctx, listeners } = useComponentCollector(context);
68
+ const { ctx, listeners } = useComponentCollector(
69
+ context,
70
+ DEFAULT_COMPONENT_HINT,
71
+ {
72
+ collectDisplayName: true,
73
+ collectHookCalls: true
74
+ }
75
+ );
69
76
  return {
70
77
  ...listeners,
71
78
  "Program:exit"(node) {
72
79
  const components = ctx.getAllComponents(node);
73
- for (const { name: name2 = "anonymous", node: node2, flag, hookCalls } of components.values()) {
80
+ for (const { name: name2 = "anonymous", node: node2, displayName, flag, hookCalls } of components.values()) {
74
81
  context.report({
75
82
  messageId: "functionComponent",
76
83
  node: node2,
77
84
  data: {
78
85
  name: name2,
86
+ displayName: displayName != null ? context.sourceCode.getText(displayName) : "none",
79
87
  forwardRef: (flag & ERFunctionComponentFlag.ForwardRef) > 0n,
80
88
  hookCalls: hookCalls.length,
81
89
  memo: (flag & ERFunctionComponentFlag.Memo) > 0n
@@ -145,20 +153,16 @@ var is_from_react_default = createRule({
145
153
  },
146
154
  name: RULE_NAME4,
147
155
  create(context) {
148
- const settings = {
149
- importSource: "react",
150
- ...getSettingsFromContext(context),
151
- strictImportCheck: true
152
- };
156
+ const { importSource = "react" } = getSettingsFromContext(context);
153
157
  function isFromReact(node, initialScope) {
154
158
  const name2 = node.name;
155
159
  switch (true) {
156
160
  case (node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier):
157
- return isInitializedFromReact(node.parent.object.name, initialScope, settings.importSource);
161
+ return isInitializedFromReact(node.parent.object.name, importSource, initialScope);
158
162
  case (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier):
159
- return isInitializedFromReact(node.parent.object.name, initialScope, settings.importSource);
163
+ return isInitializedFromReact(node.parent.object.name, importSource, initialScope);
160
164
  default:
161
- return isInitializedFromReact(name2, initialScope, settings.importSource);
165
+ return isInitializedFromReact(name2, importSource, initialScope);
162
166
  }
163
167
  }
164
168
  function visitorFunction(node) {
@@ -178,7 +182,7 @@ var is_from_react_default = createRule({
178
182
  // eslint-disable-next-line eslint-plugin/no-unused-placeholders
179
183
  type: node.type,
180
184
  name: name2,
181
- importSource: settings.importSource
185
+ importSource
182
186
  }
183
187
  });
184
188
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-debug",
3
- "version": "1.24.0-beta.1",
3
+ "version": "1.24.0-beta.16",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -41,22 +41,21 @@
41
41
  "./package.json"
42
42
  ],
43
43
  "dependencies": {
44
- "@typescript-eslint/scope-manager": "^8.19.1",
45
- "@typescript-eslint/type-utils": "^8.19.1",
46
- "@typescript-eslint/types": "^8.19.1",
47
- "@typescript-eslint/utils": "^8.19.1",
44
+ "@typescript-eslint/scope-manager": "^8.20.0",
45
+ "@typescript-eslint/type-utils": "^8.20.0",
46
+ "@typescript-eslint/types": "^8.20.0",
47
+ "@typescript-eslint/utils": "^8.20.0",
48
48
  "string-ts": "^2.2.0",
49
49
  "ts-pattern": "^5.6.0",
50
- "@eslint-react/ast": "1.24.0-beta.1",
51
- "@eslint-react/eff": "1.24.0-beta.1",
52
- "@eslint-react/shared": "1.24.0-beta.1",
53
- "@eslint-react/core": "1.24.0-beta.1",
54
- "@eslint-react/jsx": "1.24.0-beta.1",
55
- "@eslint-react/types": "1.24.0-beta.1",
56
- "@eslint-react/var": "1.24.0-beta.1"
50
+ "@eslint-react/ast": "1.24.0-beta.16",
51
+ "@eslint-react/core": "1.24.0-beta.16",
52
+ "@eslint-react/jsx": "1.24.0-beta.16",
53
+ "@eslint-react/eff": "1.24.0-beta.16",
54
+ "@eslint-react/shared": "1.24.0-beta.16",
55
+ "@eslint-react/var": "1.24.0-beta.16"
57
56
  },
58
57
  "devDependencies": {
59
- "@types/react": "^19.0.5",
58
+ "@types/react": "^19.0.7",
60
59
  "@types/react-dom": "^19.0.3",
61
60
  "tsup": "^8.3.5",
62
61
  "@workspace/configs": "0.0.0"