eslint-plugin-react-debug 2.0.0-next.0 → 2.0.0-next.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.
package/dist/index.js CHANGED
@@ -1,33 +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
- var typescript = require('typescript');
11
-
12
- function _interopNamespace(e) {
13
- if (e && e.__esModule) return e;
14
- var n = Object.create(null);
15
- if (e) {
16
- Object.keys(e).forEach(function (k) {
17
- if (k !== 'default') {
18
- var d = Object.getOwnPropertyDescriptor(e, k);
19
- Object.defineProperty(n, k, d.get ? d : {
20
- enumerable: true,
21
- get: function () { return e[k]; }
22
- });
23
- }
24
- });
25
- }
26
- n.default = e;
27
- return Object.freeze(n);
28
- }
29
-
30
- 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';
31
8
 
32
9
  var __defProp = Object.defineProperty;
33
10
  var __export = (target, all) => {
@@ -51,13 +28,13 @@ var rules = {
51
28
  "react-debug/jsx": "warn"
52
29
  };
53
30
  var settings = {
54
- "react-x": shared.DEFAULT_ESLINT_REACT_SETTINGS
31
+ "react-x": DEFAULT_ESLINT_REACT_SETTINGS
55
32
  };
56
33
 
57
34
  // package.json
58
35
  var name2 = "eslint-plugin-react-debug";
59
- var version = "2.0.0-next.0";
60
- var createRule = utils.ESLintUtils.RuleCreator(shared.getDocsUrl("debug"));
36
+ var version = "2.0.0-next.10";
37
+ var createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
61
38
 
62
39
  // src/utils/stringify.ts
63
40
  function stringify(value) {
@@ -86,7 +63,7 @@ var class_component_default = createRule({
86
63
  defaultOptions: []
87
64
  });
88
65
  function create(context) {
89
- const { ctx, listeners } = ER2__namespace.useComponentCollectorLegacy();
66
+ const { ctx, listeners } = ER2.useComponentCollectorLegacy();
90
67
  return {
91
68
  ...listeners,
92
69
  "Program:exit"(program) {
@@ -125,12 +102,12 @@ var function_component_default = createRule({
125
102
  defaultOptions: []
126
103
  });
127
104
  function create2(context) {
128
- const { ctx, listeners } = ER2__namespace.useComponentCollector(
105
+ const { ctx, listeners } = ER2.useComponentCollector(
129
106
  context,
130
107
  {
131
108
  collectDisplayName: true,
132
109
  collectHookCalls: true,
133
- hint: ER2__namespace.DEFAULT_COMPONENT_DETECTION_HINT
110
+ hint: ER2.DEFAULT_COMPONENT_DETECTION_HINT
134
111
  }
135
112
  );
136
113
  return {
@@ -145,9 +122,9 @@ function create2(context) {
145
122
  json: stringify({
146
123
  name: name3,
147
124
  displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
148
- forwardRef: (flag & ER2__namespace.ComponentFlag.ForwardRef) > 0n,
125
+ forwardRef: (flag & ER2.ComponentFlag.ForwardRef) > 0n,
149
126
  hookCalls: hookCalls.length,
150
- memo: (flag & ER2__namespace.ComponentFlag.Memo) > 0n
127
+ memo: (flag & ER2.ComponentFlag.Memo) > 0n
151
128
  })
152
129
  }
153
130
  });
@@ -176,7 +153,7 @@ var hook_default = createRule({
176
153
  defaultOptions: []
177
154
  });
178
155
  function create3(context) {
179
- const { ctx, listeners } = ER2__namespace.useHookCollector();
156
+ const { ctx, listeners } = ER2.useHookCollector();
180
157
  return {
181
158
  ...listeners,
182
159
  "Program:exit"(program) {
@@ -217,20 +194,20 @@ var is_from_react_default = createRule({
217
194
  defaultOptions: []
218
195
  });
219
196
  function create4(context) {
220
- const { importSource = "react" } = shared.getSettingsFromContext(context);
197
+ const { importSource = "react" } = getSettingsFromContext(context);
221
198
  function isFromReact(node, initialScope) {
222
199
  const name3 = node.name;
223
200
  switch (true) {
224
- case (node.parent.type === utils.AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.Identifier):
225
- return ER2__namespace.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
226
- case (node.parent.type === utils.AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === utils.AST_NODE_TYPES.JSXIdentifier):
227
- 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);
228
205
  default:
229
- return ER2__namespace.isInitializedFromReact(name3, importSource, initialScope);
206
+ return ER2.isInitializedFromReact(name3, importSource, initialScope);
230
207
  }
231
208
  }
232
209
  function visitorFunction(node) {
233
- 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;
234
211
  if (shouldSkipDuplicate) return;
235
212
  const name3 = node.name;
236
213
  const initialScope = context.sourceCode.getScope(node);
@@ -251,6 +228,7 @@ function create4(context) {
251
228
  JSXIdentifier: visitorFunction
252
229
  };
253
230
  }
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(typescript.JsxEmit.None, () => "none").with(typescript.JsxEmit.ReactJSX, () => "react-jsx").with(typescript.JsxEmit.ReactJSXDev, () => "react-jsx-dev").with(typescript.JsxEmit.React, () => "react").with(typescript.JsxEmit.ReactNative, () => "react-native").with(typescript.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(typescript.JsxEmit.None, typescript.JsxEmit.ReactJSX, typescript.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
 
@@ -338,4 +316,4 @@ var index_default = {
338
316
  }
339
317
  };
340
318
 
341
- 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": "2.0.0-next.0",
3
+ "version": "2.0.0-next.10",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -22,39 +22,31 @@
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"
44
36
  ],
45
37
  "dependencies": {
46
- "@typescript-eslint/scope-manager": "^8.30.1",
47
- "@typescript-eslint/type-utils": "^8.30.1",
48
- "@typescript-eslint/types": "^8.30.1",
49
- "@typescript-eslint/utils": "^8.30.1",
38
+ "@typescript-eslint/scope-manager": "^8.31.1",
39
+ "@typescript-eslint/type-utils": "^8.31.1",
40
+ "@typescript-eslint/types": "^8.31.1",
41
+ "@typescript-eslint/utils": "^8.31.1",
50
42
  "string-ts": "^2.2.1",
51
43
  "ts-pattern": "^5.7.0",
52
- "@eslint-react/eff": "2.0.0-next.0",
53
- "@eslint-react/ast": "2.0.0-next.0",
54
- "@eslint-react/kit": "2.0.0-next.0",
55
- "@eslint-react/var": "2.0.0-next.0",
56
- "@eslint-react/shared": "2.0.0-next.0",
57
- "@eslint-react/core": "2.0.0-next.0"
44
+ "@eslint-react/ast": "2.0.0-next.10",
45
+ "@eslint-react/core": "2.0.0-next.10",
46
+ "@eslint-react/eff": "2.0.0-next.10",
47
+ "@eslint-react/kit": "2.0.0-next.10",
48
+ "@eslint-react/var": "2.0.0-next.10",
49
+ "@eslint-react/shared": "2.0.0-next.10"
58
50
  },
59
51
  "devDependencies": {
60
52
  "@types/react": "^19.1.2",
@@ -63,7 +55,7 @@
63
55
  "@local/configs": "0.0.0"
64
56
  },
65
57
  "peerDependencies": {
66
- "eslint": "^9.24.0",
58
+ "eslint": "^9.25.1",
67
59
  "typescript": "^4.9.5 || ^5.4.5"
68
60
  },
69
61
  "peerDependenciesMeta": {
package/dist/index.d.mts DELETED
@@ -1,43 +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
- };
20
- };
21
- };
22
- name: string;
23
- rules: RulePreset;
24
- };
25
- "all-legacy": {
26
- plugins: string[];
27
- rules: RulePreset;
28
- };
29
- };
30
- meta: {
31
- readonly name: string;
32
- readonly version: string;
33
- };
34
- rules: {
35
- readonly "class-component": _typescript_eslint_utils_ts_eslint.RuleModule<"classComponent", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
36
- readonly "function-component": _typescript_eslint_utils_ts_eslint.RuleModule<"functionComponent", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
37
- readonly hook: _typescript_eslint_utils_ts_eslint.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
38
- readonly "is-from-react": _typescript_eslint_utils_ts_eslint.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
39
- readonly jsx: _typescript_eslint_utils_ts_eslint.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint.RuleListener>;
40
- };
41
- };
42
-
43
- export { _default as default };
package/dist/index.mjs DELETED
@@ -1,319 +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
- import { JsxEmit } from 'typescript';
9
-
10
- var __defProp = Object.defineProperty;
11
- var __export = (target, all) => {
12
- for (var name3 in all)
13
- __defProp(target, name3, { get: all[name3], enumerable: true });
14
- };
15
-
16
- // src/configs/all.ts
17
- var all_exports = {};
18
- __export(all_exports, {
19
- name: () => name,
20
- rules: () => rules,
21
- settings: () => settings
22
- });
23
- var name = "react-debug/all";
24
- var rules = {
25
- "react-debug/class-component": "warn",
26
- "react-debug/function-component": "warn",
27
- "react-debug/hook": "warn",
28
- "react-debug/is-from-react": "warn",
29
- "react-debug/jsx": "warn"
30
- };
31
- var settings = {
32
- "react-x": DEFAULT_ESLINT_REACT_SETTINGS
33
- };
34
-
35
- // package.json
36
- var name2 = "eslint-plugin-react-debug";
37
- var version = "2.0.0-next.0";
38
- var createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
39
-
40
- // src/utils/stringify.ts
41
- function stringify(value) {
42
- return JSON.stringify(value, null, 2);
43
- }
44
-
45
- // src/rules/class-component.ts
46
- var RULE_NAME = "class-component";
47
- var RULE_FEATURES = [
48
- "DBG"
49
- ];
50
- var class_component_default = createRule({
51
- meta: {
52
- type: "problem",
53
- docs: {
54
- description: "Reports all class components.",
55
- [Symbol.for("rule_features")]: RULE_FEATURES
56
- },
57
- messages: {
58
- classComponent: "{{json}}"
59
- },
60
- schema: []
61
- },
62
- name: RULE_NAME,
63
- create,
64
- defaultOptions: []
65
- });
66
- function create(context) {
67
- const { ctx, listeners } = ER2.useComponentCollectorLegacy();
68
- return {
69
- ...listeners,
70
- "Program:exit"(program) {
71
- const components = ctx.getAllComponents(program);
72
- for (const { name: name3 = "anonymous", node: component } of components.values()) {
73
- context.report({
74
- messageId: "classComponent",
75
- node: component,
76
- data: {
77
- json: stringify({ name: name3 })
78
- }
79
- });
80
- }
81
- }
82
- };
83
- }
84
- var RULE_NAME2 = "function-component";
85
- var RULE_FEATURES2 = [
86
- "DBG"
87
- ];
88
- var function_component_default = createRule({
89
- meta: {
90
- type: "problem",
91
- docs: {
92
- description: "Reports all function components.",
93
- [Symbol.for("rule_features")]: RULE_FEATURES2
94
- },
95
- messages: {
96
- functionComponent: "{{json}}"
97
- // "[function component] name: {{name}}, memo: {{memo}}, forwardRef: {{forwardRef}}, hookCalls: {{hookCalls}}, displayName: {{displayName}}.",
98
- },
99
- schema: []
100
- },
101
- name: RULE_NAME2,
102
- create: create2,
103
- defaultOptions: []
104
- });
105
- function create2(context) {
106
- const { ctx, listeners } = ER2.useComponentCollector(
107
- context,
108
- {
109
- collectDisplayName: true,
110
- collectHookCalls: true,
111
- hint: ER2.DEFAULT_COMPONENT_DETECTION_HINT
112
- }
113
- );
114
- return {
115
- ...listeners,
116
- "Program:exit"(program) {
117
- const components = ctx.getAllComponents(program);
118
- for (const { name: name3 = "anonymous", node, displayName, flag, hookCalls } of components.values()) {
119
- context.report({
120
- messageId: "functionComponent",
121
- node,
122
- data: {
123
- json: stringify({
124
- name: name3,
125
- displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
126
- forwardRef: (flag & ER2.ComponentFlag.ForwardRef) > 0n,
127
- hookCalls: hookCalls.length,
128
- memo: (flag & ER2.ComponentFlag.Memo) > 0n
129
- })
130
- }
131
- });
132
- }
133
- }
134
- };
135
- }
136
- var RULE_NAME3 = "hook";
137
- var RULE_FEATURES3 = [
138
- "DBG"
139
- ];
140
- var hook_default = createRule({
141
- meta: {
142
- type: "problem",
143
- docs: {
144
- description: "Reports all React Hooks.",
145
- [Symbol.for("rule_features")]: RULE_FEATURES3
146
- },
147
- messages: {
148
- hook: "{{json}}"
149
- },
150
- schema: []
151
- },
152
- name: RULE_NAME3,
153
- create: create3,
154
- defaultOptions: []
155
- });
156
- function create3(context) {
157
- const { ctx, listeners } = ER2.useHookCollector();
158
- return {
159
- ...listeners,
160
- "Program:exit"(program) {
161
- const allHooks = ctx.getAllHooks(program);
162
- for (const { name: name3, node, hookCalls } of allHooks.values()) {
163
- context.report({
164
- messageId: "hook",
165
- node,
166
- data: {
167
- json: stringify({
168
- name: name3,
169
- hookCalls: hookCalls.length
170
- })
171
- }
172
- });
173
- }
174
- }
175
- };
176
- }
177
- var RULE_NAME4 = "is-from-react";
178
- var RULE_FEATURES4 = [
179
- "DBG"
180
- ];
181
- var is_from_react_default = createRule({
182
- meta: {
183
- type: "problem",
184
- docs: {
185
- description: "Reports all identifiers that are initialized from React.",
186
- [Symbol.for("rule_features")]: RULE_FEATURES4
187
- },
188
- messages: {
189
- isFromReact: "{{json}}"
190
- },
191
- schema: []
192
- },
193
- name: RULE_NAME4,
194
- create: create4,
195
- defaultOptions: []
196
- });
197
- function create4(context) {
198
- const { importSource = "react" } = getSettingsFromContext(context);
199
- function isFromReact(node, initialScope) {
200
- const name3 = node.name;
201
- switch (true) {
202
- case (node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier):
203
- return ER2.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
204
- case (node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier):
205
- return ER2.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
206
- default:
207
- return ER2.isInitializedFromReact(name3, importSource, initialScope);
208
- }
209
- }
210
- function visitorFunction(node) {
211
- const shouldSkipDuplicate = node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name;
212
- if (shouldSkipDuplicate) return;
213
- const name3 = node.name;
214
- const initialScope = context.sourceCode.getScope(node);
215
- if (!isFromReact(node, initialScope)) return;
216
- context.report({
217
- messageId: "isFromReact",
218
- node,
219
- data: {
220
- json: stringify({
221
- name: name3,
222
- importSource
223
- })
224
- }
225
- });
226
- }
227
- return {
228
- Identifier: visitorFunction,
229
- JSXIdentifier: visitorFunction
230
- };
231
- }
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
- }
294
- };
295
-
296
- // src/index.ts
297
- function makeConfig(config) {
298
- return {
299
- ...config,
300
- plugins: {
301
- "react-debug": plugin
302
- }
303
- };
304
- }
305
- function makeLegacyConfig({ rules: rules2 }) {
306
- return {
307
- plugins: ["react-debug"],
308
- rules: rules2
309
- };
310
- }
311
- var index_default = {
312
- ...plugin,
313
- configs: {
314
- ["all"]: makeConfig(all_exports),
315
- ["all-legacy"]: makeLegacyConfig(all_exports)
316
- }
317
- };
318
-
319
- export { index_default as default };