eslint-plugin-react-debug 1.49.0-next.0 → 2.0.0-beta.13

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.
package/dist/index.d.ts CHANGED
@@ -16,7 +16,6 @@ declare const _default: {
16
16
  readonly hook: _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
17
17
  readonly "is-from-react": _typescript_eslint_utils_ts_eslint.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
18
18
  readonly jsx: _typescript_eslint_utils_ts_eslint.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
19
- readonly "react-hooks": _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
19
  };
21
20
  };
22
21
  };
@@ -38,7 +37,6 @@ declare const _default: {
38
37
  readonly hook: _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
39
38
  readonly "is-from-react": _typescript_eslint_utils_ts_eslint.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
40
39
  readonly jsx: _typescript_eslint_utils_ts_eslint.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
41
- readonly "react-hooks": _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
42
40
  };
43
41
  };
44
42
 
package/dist/index.js CHANGED
@@ -1,32 +1,10 @@
1
- 'use strict';
2
-
3
- var shared = require('@eslint-react/shared');
4
- var ER2 = require('@eslint-react/core');
5
- var utils = require('@typescript-eslint/utils');
6
- var eff = require('@eslint-react/eff');
7
- var kit = require('@eslint-react/kit');
8
- var types = require('@typescript-eslint/types');
9
- var tsPattern = require('ts-pattern');
10
-
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var ER2__namespace = /*#__PURE__*/_interopNamespace(ER2);
1
+ import { getDocsUrl, getSettingsFromContext, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
2
+ import * as ER2 from '@eslint-react/core';
3
+ import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
4
+ import { flow } from '@eslint-react/eff';
5
+ import { JsxConfig, Reporter } from '@eslint-react/kit';
6
+ import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/types';
7
+ import { match, P } from 'ts-pattern';
30
8
 
31
9
  var __defProp = Object.defineProperty;
32
10
  var __export = (target, all) => {
@@ -50,13 +28,13 @@ var rules = {
50
28
  "react-debug/jsx": "warn"
51
29
  };
52
30
  var settings = {
53
- "react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
31
+ "react-x": DEFAULT_ESLINT_REACT_SETTINGS
54
32
  };
55
33
 
56
34
  // package.json
57
35
  var name2 = "eslint-plugin-react-debug";
58
- var version = "1.49.0-next.0";
59
- var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("debug"));
36
+ var version = "2.0.0-beta.13";
37
+ var createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
60
38
 
61
39
  // src/utils/stringify.ts
62
40
  function stringify(value) {
@@ -85,7 +63,7 @@ var class_component_default = createRule({
85
63
  defaultOptions: []
86
64
  });
87
65
  function create(context) {
88
- const { ctx, listeners } = ER2__namespace.useComponentCollectorLegacy();
66
+ const { ctx, listeners } = ER2.useComponentCollectorLegacy();
89
67
  return {
90
68
  ...listeners,
91
69
  "Program:exit"(program) {
@@ -124,12 +102,12 @@ var function_component_default = createRule({
124
102
  defaultOptions: []
125
103
  });
126
104
  function create2(context) {
127
- const { ctx, listeners } = ER2__namespace.useComponentCollector(
105
+ const { ctx, listeners } = ER2.useComponentCollector(
128
106
  context,
129
107
  {
130
108
  collectDisplayName: true,
131
109
  collectHookCalls: true,
132
- hint: ER2__namespace.DEFAULT_COMPONENT_DETECTION_HINT
110
+ hint: ER2.DEFAULT_COMPONENT_DETECTION_HINT
133
111
  }
134
112
  );
135
113
  return {
@@ -144,9 +122,9 @@ function create2(context) {
144
122
  json: stringify({
145
123
  name: name3,
146
124
  displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
147
- forwardRef: (flag & ER2__namespace.ComponentFlag.ForwardRef) > 0n,
125
+ forwardRef: (flag & ER2.ComponentFlag.ForwardRef) > 0n,
148
126
  hookCalls: hookCalls.length,
149
- memo: (flag & ER2__namespace.ComponentFlag.Memo) > 0n
127
+ memo: (flag & ER2.ComponentFlag.Memo) > 0n
150
128
  })
151
129
  }
152
130
  });
@@ -175,7 +153,7 @@ var hook_default = createRule({
175
153
  defaultOptions: []
176
154
  });
177
155
  function create3(context) {
178
- const { ctx, listeners } = ER2__namespace.useHookCollector();
156
+ const { ctx, listeners } = ER2.useHookCollector();
179
157
  return {
180
158
  ...listeners,
181
159
  "Program:exit"(program) {
@@ -216,20 +194,20 @@ var is_from_react_default = createRule({
216
194
  defaultOptions: []
217
195
  });
218
196
  function create4(context) {
219
- const { importSource = "react" } = shared.getSettingsFromContext(context);
197
+ const { importSource = "react" } = getSettingsFromContext(context);
220
198
  function isFromReact(node, initialScope) {
221
199
  const name3 = node.name;
222
200
  switch (true) {
223
- case (node.parent.type === utils.AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.Identifier):
224
- return ER2__namespace.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
225
- case (node.parent.type === utils.AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.JSXIdentifier):
226
- return ER2__namespace.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
201
+ case (node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier):
202
+ return ER2.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
203
+ case (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier):
204
+ return ER2.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
227
205
  default:
228
- return ER2__namespace.isInitializedFromReact(name3, importSource, initialScope);
206
+ return ER2.isInitializedFromReact(name3, importSource, initialScope);
229
207
  }
230
208
  }
231
209
  function visitorFunction(node) {
232
- const shouldSkipDuplicate = node.parent.type === utils.AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name;
210
+ const shouldSkipDuplicate = node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name;
233
211
  if (shouldSkipDuplicate) return;
234
212
  const name3 = node.name;
235
213
  const initialScope = context.sourceCode.getScope(node);
@@ -250,7 +228,7 @@ function create4(context) {
250
228
  JSXIdentifier: visitorFunction
251
229
  };
252
230
  }
253
- var { JsxEmit } = kit.JsxConfig;
231
+ var { JsxEmit } = JsxConfig;
254
232
  var RULE_NAME5 = "jsx";
255
233
  var RULE_FEATURES5 = [
256
234
  "DBG"
@@ -272,8 +250,8 @@ var jsx_default = createRule({
272
250
  defaultOptions: []
273
251
  });
274
252
  function create5(context) {
275
- const jsxConfigFromContext = kit.JsxConfig.getFromContext(context);
276
- const jsxConfigFromAnnotation = kit.JsxConfig.getFromAnnotation(context);
253
+ const jsxConfigFromContext = JsxConfig.getFromContext(context);
254
+ const jsxConfigFromAnnotation = JsxConfig.getFromAnnotation(context);
277
255
  const jsxConfig = {
278
256
  ...jsxConfigFromContext,
279
257
  ...jsxConfigFromAnnotation
@@ -284,19 +262,19 @@ function create5(context) {
284
262
  node,
285
263
  data: {
286
264
  json: stringify({
287
- kind: tsPattern.match(node).with({ type: types.AST_NODE_TYPES.JSXElement }, (n) => ER2__namespace.isFragmentElement(context2, n) ? "fragment" : "element").with({ type: types.AST_NODE_TYPES.JSXFragment }, () => "fragment").exhaustive(),
288
- type: ER2__namespace.getElementType(context2, node),
289
- jsx: tsPattern.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"),
265
+ kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => ER2.isFragmentElement(context2, n) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
266
+ type: ER2.getElementType(context2, node),
267
+ 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"),
290
268
  jsxFactory: jsxConfig.jsxFactory,
291
269
  jsxFragmentFactory: jsxConfig.jsxFragmentFactory,
292
270
  jsxImportSource: jsxConfig.jsxImportSource,
293
- jsxRuntime: tsPattern.match(jsxConfig.jsx).with(tsPattern.P.union(JsxEmit.None, JsxEmit.ReactJSX, JsxEmit.ReactJSXDev), () => "automatic").otherwise(() => "classic")
271
+ jsxRuntime: match(jsxConfig.jsx).with(P.union(JsxEmit.None, JsxEmit.ReactJSX, JsxEmit.ReactJSXDev), () => "automatic").otherwise(() => "classic")
294
272
  })
295
273
  }
296
274
  });
297
275
  }
298
276
  return {
299
- "JSXElement, JSXFragment": eff.flow(getReportDescriptor(context), kit.Reporter.make(context).send)
277
+ "JSXElement, JSXFragment": flow(getReportDescriptor(context), Reporter.make(context).send)
300
278
  };
301
279
  }
302
280
 
@@ -311,10 +289,7 @@ var plugin = {
311
289
  ["function-component"]: function_component_default,
312
290
  ["hook"]: hook_default,
313
291
  ["is-from-react"]: is_from_react_default,
314
- ["jsx"]: jsx_default,
315
- // Part: deprecated rules
316
- /** @deprecated Use `hook` instead */
317
- "react-hooks": hook_default
292
+ ["jsx"]: jsx_default
318
293
  }
319
294
  };
320
295
 
@@ -341,4 +316,4 @@ var index_default = {
341
316
  }
342
317
  };
343
318
 
344
- module.exports = index_default;
319
+ export { index_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-debug",
3
- "version": "1.49.0-next.0",
3
+ "version": "2.0.0-beta.13",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -22,22 +22,14 @@
22
22
  "license": "MIT",
23
23
  "author": "Rel1cx<rel1cx@proton.me>",
24
24
  "sideEffects": false,
25
+ "type": "module",
25
26
  "exports": {
26
27
  ".": {
27
- "import": {
28
- "types": "./dist/index.d.mts",
29
- "default": "./dist/index.mjs"
30
- },
31
- "require": {
32
- "types": "./dist/index.d.ts",
33
- "default": "./dist/index.js"
34
- }
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
35
30
  },
36
31
  "./package.json": "./package.json"
37
32
  },
38
- "main": "dist/index.js",
39
- "module": "dist/index.mjs",
40
- "types": "./dist/index.d.ts",
41
33
  "files": [
42
34
  "dist",
43
35
  "./package.json"
@@ -49,12 +41,12 @@
49
41
  "@typescript-eslint/utils": "^8.31.1",
50
42
  "string-ts": "^2.2.1",
51
43
  "ts-pattern": "^5.7.0",
52
- "@eslint-react/ast": "1.49.0-next.0",
53
- "@eslint-react/core": "1.49.0-next.0",
54
- "@eslint-react/eff": "1.49.0-next.0",
55
- "@eslint-react/kit": "1.49.0-next.0",
56
- "@eslint-react/var": "1.49.0-next.0",
57
- "@eslint-react/shared": "1.49.0-next.0"
44
+ "@eslint-react/ast": "2.0.0-beta.13",
45
+ "@eslint-react/core": "2.0.0-beta.13",
46
+ "@eslint-react/eff": "2.0.0-beta.13",
47
+ "@eslint-react/shared": "2.0.0-beta.13",
48
+ "@eslint-react/kit": "2.0.0-beta.13",
49
+ "@eslint-react/var": "2.0.0-beta.13"
58
50
  },
59
51
  "devDependencies": {
60
52
  "@types/react": "^19.1.2",
@@ -63,8 +55,8 @@
63
55
  "@local/configs": "0.0.0"
64
56
  },
65
57
  "peerDependencies": {
66
- "eslint": "^8.57.0 || ^9.0.0",
67
- "typescript": "^4.9.5 || ^5.3.3"
58
+ "eslint": "^9.26.0",
59
+ "typescript": "^4.9.5 || ^5.4.5"
68
60
  },
69
61
  "peerDependenciesMeta": {
70
62
  "eslint": {
@@ -76,7 +68,7 @@
76
68
  },
77
69
  "engines": {
78
70
  "bun": ">=1.0.15",
79
- "node": ">=18.18.0"
71
+ "node": ">=20.19.0"
80
72
  },
81
73
  "publishConfig": {
82
74
  "access": "public"
package/dist/index.d.mts DELETED
@@ -1,45 +0,0 @@
1
- import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
2
- import { RulePreset } from '@eslint-react/kit';
3
-
4
- declare const _default: {
5
- configs: {
6
- all: {
7
- plugins: {
8
- "react-debug": {
9
- readonly meta: {
10
- readonly name: string;
11
- readonly version: string;
12
- };
13
- readonly rules: {
14
- readonly "class-component": _typescript_eslint_utils_ts_eslint.RuleModule<"classComponent", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
15
- readonly "function-component": _typescript_eslint_utils_ts_eslint.RuleModule<"functionComponent", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
16
- readonly hook: _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
17
- readonly "is-from-react": _typescript_eslint_utils_ts_eslint.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
18
- readonly jsx: _typescript_eslint_utils_ts_eslint.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
19
- readonly "react-hooks": _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
20
- };
21
- };
22
- };
23
- name: string;
24
- rules: RulePreset;
25
- };
26
- "all-legacy": {
27
- plugins: string[];
28
- rules: RulePreset;
29
- };
30
- };
31
- meta: {
32
- readonly name: string;
33
- readonly version: string;
34
- };
35
- rules: {
36
- readonly "class-component": _typescript_eslint_utils_ts_eslint.RuleModule<"classComponent", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
37
- readonly "function-component": _typescript_eslint_utils_ts_eslint.RuleModule<"functionComponent", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
38
- readonly hook: _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
39
- readonly "is-from-react": _typescript_eslint_utils_ts_eslint.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
40
- readonly jsx: _typescript_eslint_utils_ts_eslint.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
41
- readonly "react-hooks": _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
42
- };
43
- };
44
-
45
- export { _default as default };
package/dist/index.mjs DELETED
@@ -1,322 +0,0 @@
1
- import { getDocsUrl, getSettingsFromContext, DEFAULT_ESLINT_REACT_SETTINGS } from '@eslint-react/shared';
2
- import * as ER2 from '@eslint-react/core';
3
- import { ESLintUtils, AST_NODE_TYPES } from '@typescript-eslint/utils';
4
- import { flow } from '@eslint-react/eff';
5
- import { JsxConfig, Reporter } from '@eslint-react/kit';
6
- import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from '@typescript-eslint/types';
7
- import { match, P } from 'ts-pattern';
8
-
9
- var __defProp = Object.defineProperty;
10
- var __export = (target, all) => {
11
- for (var name3 in all)
12
- __defProp(target, name3, { get: all[name3], enumerable: true });
13
- };
14
-
15
- // src/configs/all.ts
16
- var all_exports = {};
17
- __export(all_exports, {
18
- name: () => name,
19
- rules: () => rules,
20
- settings: () => settings
21
- });
22
- var name = "react-debug/all";
23
- var rules = {
24
- "react-debug/class-component": "warn",
25
- "react-debug/function-component": "warn",
26
- "react-debug/hook": "warn",
27
- "react-debug/is-from-react": "warn",
28
- "react-debug/jsx": "warn"
29
- };
30
- var settings = {
31
- "react-x": DEFAULT_ESLINT_REACT_SETTINGS
32
- };
33
-
34
- // package.json
35
- var name2 = "eslint-plugin-react-debug";
36
- var version = "1.49.0-next.0";
37
- var createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
38
-
39
- // src/utils/stringify.ts
40
- function stringify(value) {
41
- return JSON.stringify(value, null, 2);
42
- }
43
-
44
- // src/rules/class-component.ts
45
- var RULE_NAME = "class-component";
46
- var RULE_FEATURES = [
47
- "DBG"
48
- ];
49
- var class_component_default = createRule({
50
- meta: {
51
- type: "problem",
52
- docs: {
53
- description: "Reports all class components.",
54
- [Symbol.for("rule_features")]: RULE_FEATURES
55
- },
56
- messages: {
57
- classComponent: "{{json}}"
58
- },
59
- schema: []
60
- },
61
- name: RULE_NAME,
62
- create,
63
- defaultOptions: []
64
- });
65
- function create(context) {
66
- const { ctx, listeners } = ER2.useComponentCollectorLegacy();
67
- return {
68
- ...listeners,
69
- "Program:exit"(program) {
70
- const components = ctx.getAllComponents(program);
71
- for (const { name: name3 = "anonymous", node: component } of components.values()) {
72
- context.report({
73
- messageId: "classComponent",
74
- node: component,
75
- data: {
76
- json: stringify({ name: name3 })
77
- }
78
- });
79
- }
80
- }
81
- };
82
- }
83
- var RULE_NAME2 = "function-component";
84
- var RULE_FEATURES2 = [
85
- "DBG"
86
- ];
87
- var function_component_default = createRule({
88
- meta: {
89
- type: "problem",
90
- docs: {
91
- description: "Reports all function components.",
92
- [Symbol.for("rule_features")]: RULE_FEATURES2
93
- },
94
- messages: {
95
- functionComponent: "{{json}}"
96
- // "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}, displayName: {{displayName}}.",
97
- },
98
- schema: []
99
- },
100
- name: RULE_NAME2,
101
- create: create2,
102
- defaultOptions: []
103
- });
104
- function create2(context) {
105
- const { ctx, listeners } = ER2.useComponentCollector(
106
- context,
107
- {
108
- collectDisplayName: true,
109
- collectHookCalls: true,
110
- hint: ER2.DEFAULT_COMPONENT_DETECTION_HINT
111
- }
112
- );
113
- return {
114
- ...listeners,
115
- "Program:exit"(program) {
116
- const components = ctx.getAllComponents(program);
117
- for (const { name: name3 = "anonymous", node, displayName, flag, hookCalls } of components.values()) {
118
- context.report({
119
- messageId: "functionComponent",
120
- node,
121
- data: {
122
- json: stringify({
123
- name: name3,
124
- displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
125
- forwardRef: (flag & ER2.ComponentFlag.ForwardRef) > 0n,
126
- hookCalls: hookCalls.length,
127
- memo: (flag & ER2.ComponentFlag.Memo) > 0n
128
- })
129
- }
130
- });
131
- }
132
- }
133
- };
134
- }
135
- var RULE_NAME3 = "hook";
136
- var RULE_FEATURES3 = [
137
- "DBG"
138
- ];
139
- var hook_default = createRule({
140
- meta: {
141
- type: "problem",
142
- docs: {
143
- description: "Reports all React Hooks.",
144
- [Symbol.for("rule_features")]: RULE_FEATURES3
145
- },
146
- messages: {
147
- hook: "{{json}}"
148
- },
149
- schema: []
150
- },
151
- name: RULE_NAME3,
152
- create: create3,
153
- defaultOptions: []
154
- });
155
- function create3(context) {
156
- const { ctx, listeners } = ER2.useHookCollector();
157
- return {
158
- ...listeners,
159
- "Program:exit"(program) {
160
- const allHooks = ctx.getAllHooks(program);
161
- for (const { name: name3, node, hookCalls } of allHooks.values()) {
162
- context.report({
163
- messageId: "hook",
164
- node,
165
- data: {
166
- json: stringify({
167
- name: name3,
168
- hookCalls: hookCalls.length
169
- })
170
- }
171
- });
172
- }
173
- }
174
- };
175
- }
176
- var RULE_NAME4 = "is-from-react";
177
- var RULE_FEATURES4 = [
178
- "DBG"
179
- ];
180
- var is_from_react_default = createRule({
181
- meta: {
182
- type: "problem",
183
- docs: {
184
- description: "Reports all identifiers that are initialized from React.",
185
- [Symbol.for("rule_features")]: RULE_FEATURES4
186
- },
187
- messages: {
188
- isFromReact: "{{json}}"
189
- },
190
- schema: []
191
- },
192
- name: RULE_NAME4,
193
- create: create4,
194
- defaultOptions: []
195
- });
196
- function create4(context) {
197
- const { importSource = "react" } = getSettingsFromContext(context);
198
- function isFromReact(node, initialScope) {
199
- const name3 = node.name;
200
- switch (true) {
201
- case (node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier):
202
- return ER2.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
203
- case (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier):
204
- return ER2.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
205
- default:
206
- return ER2.isInitializedFromReact(name3, importSource, initialScope);
207
- }
208
- }
209
- function visitorFunction(node) {
210
- const shouldSkipDuplicate = node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name;
211
- if (shouldSkipDuplicate) return;
212
- const name3 = node.name;
213
- const initialScope = context.sourceCode.getScope(node);
214
- if (!isFromReact(node, initialScope)) return;
215
- context.report({
216
- messageId: "isFromReact",
217
- node,
218
- data: {
219
- json: stringify({
220
- name: name3,
221
- importSource
222
- })
223
- }
224
- });
225
- }
226
- return {
227
- Identifier: visitorFunction,
228
- JSXIdentifier: visitorFunction
229
- };
230
- }
231
- var { JsxEmit } = JsxConfig;
232
- var RULE_NAME5 = "jsx";
233
- var RULE_FEATURES5 = [
234
- "DBG"
235
- ];
236
- var jsx_default = createRule({
237
- meta: {
238
- type: "problem",
239
- docs: {
240
- description: "Reports all JSX elements and fragments.",
241
- [Symbol.for("rule_features")]: RULE_FEATURES5
242
- },
243
- messages: {
244
- jsx: "{{json}}"
245
- },
246
- schema: []
247
- },
248
- name: RULE_NAME5,
249
- create: create5,
250
- defaultOptions: []
251
- });
252
- function create5(context) {
253
- const jsxConfigFromContext = JsxConfig.getFromContext(context);
254
- const jsxConfigFromAnnotation = JsxConfig.getFromAnnotation(context);
255
- const jsxConfig = {
256
- ...jsxConfigFromContext,
257
- ...jsxConfigFromAnnotation
258
- };
259
- function getReportDescriptor(context2) {
260
- return (node) => ({
261
- messageId: "jsx",
262
- node,
263
- data: {
264
- json: stringify({
265
- kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => ER2.isFragmentElement(context2, n) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
266
- type: ER2.getElementType(context2, node),
267
- 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"),
268
- jsxFactory: jsxConfig.jsxFactory,
269
- jsxFragmentFactory: jsxConfig.jsxFragmentFactory,
270
- jsxImportSource: jsxConfig.jsxImportSource,
271
- jsxRuntime: match(jsxConfig.jsx).with(P.union(JsxEmit.None, JsxEmit.ReactJSX, JsxEmit.ReactJSXDev), () => "automatic").otherwise(() => "classic")
272
- })
273
- }
274
- });
275
- }
276
- return {
277
- "JSXElement, JSXFragment": flow(getReportDescriptor(context), Reporter.make(context).send)
278
- };
279
- }
280
-
281
- // src/plugin.ts
282
- var plugin = {
283
- meta: {
284
- name: name2,
285
- version
286
- },
287
- rules: {
288
- ["class-component"]: class_component_default,
289
- ["function-component"]: function_component_default,
290
- ["hook"]: hook_default,
291
- ["is-from-react"]: is_from_react_default,
292
- ["jsx"]: jsx_default,
293
- // Part: deprecated rules
294
- /** @deprecated Use `hook` instead */
295
- "react-hooks": hook_default
296
- }
297
- };
298
-
299
- // src/index.ts
300
- function makeConfig(config) {
301
- return {
302
- ...config,
303
- plugins: {
304
- "react-debug": plugin
305
- }
306
- };
307
- }
308
- function makeLegacyConfig({ rules: rules2 }) {
309
- return {
310
- plugins: ["react-debug"],
311
- rules: rules2
312
- };
313
- }
314
- var index_default = {
315
- ...plugin,
316
- configs: {
317
- ["all"]: makeConfig(all_exports),
318
- ["all-legacy"]: makeLegacyConfig(all_exports)
319
- }
320
- };
321
-
322
- export { index_default as default };