eslint-plugin-react-debug 3.0.0-next.7 → 3.0.0-next.70

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
@@ -1,20 +1,9 @@
1
- import * as _eslint_react_shared0 from "@eslint-react/shared";
1
+ import { ESLint, Linter } from "eslint";
2
2
 
3
3
  //#region src/index.d.ts
4
- declare const _default: {
5
- configs: {
6
- all: {
7
- plugins: {};
8
- name?: string;
9
- rules?: Record<string, _eslint_react_shared0.RuleConfig>;
10
- settings?: _eslint_react_shared0.SettingsConfig;
11
- };
12
- };
13
- meta: {
14
- name: string;
15
- version: string;
16
- };
17
- rules: Record<string, _eslint_react_shared0.CompatibleRule>;
4
+ type ConfigName = "all";
5
+ declare const finalPlugin: ESLint.Plugin & {
6
+ configs: Record<ConfigName, Linter.Config>;
18
7
  };
19
8
  //#endregion
20
- export { _default as default };
9
+ export { finalPlugin as default };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener, getConfigAdapters, getSettingsFromContext, report } from "@eslint-react/shared";
1
+ import { DEFAULT_ESLINT_REACT_SETTINGS, WEBSITE_URL, defineRuleListener, getSettingsFromContext, report } from "@eslint-react/shared";
2
2
  import * as core from "@eslint-react/core";
3
+ import { JsxEmit, JsxInspector } from "@eslint-react/core";
3
4
  import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
4
5
  import { flow } from "@eslint-react/eff";
5
6
  import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/types";
@@ -21,28 +22,10 @@ var __exportAll = (all, no_symbols) => {
21
22
  return target;
22
23
  };
23
24
 
24
- //#endregion
25
- //#region src/configs/all.ts
26
- var all_exports = /* @__PURE__ */ __exportAll({
27
- name: () => name$1,
28
- rules: () => rules,
29
- settings: () => settings
30
- });
31
- const name$1 = "react-debug/all";
32
- const rules = {
33
- "react-debug/class-component": "warn",
34
- "react-debug/function-component": "warn",
35
- "react-debug/hook": "warn",
36
- "react-debug/is-from-react": "warn",
37
- "react-debug/is-from-ref": "warn",
38
- "react-debug/jsx": "warn"
39
- };
40
- const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
41
-
42
25
  //#endregion
43
26
  //#region package.json
44
- var name = "eslint-plugin-react-debug";
45
- var version = "3.0.0-next.7";
27
+ var name$1 = "eslint-plugin-react-debug";
28
+ var version = "3.0.0-next.70";
46
29
 
47
30
  //#endregion
48
31
  //#region src/utils/create-rule.ts
@@ -58,7 +41,7 @@ function stringify(value) {
58
41
  }
59
42
 
60
43
  //#endregion
61
- //#region src/rules/class-component.ts
44
+ //#region src/rules/class-component/class-component.ts
62
45
  const RULE_NAME$5 = "class-component";
63
46
  var class_component_default = createRule({
64
47
  meta: {
@@ -75,15 +58,15 @@ function create$5(context) {
75
58
  const { ctx, visitor } = core.useComponentCollectorLegacy(context);
76
59
  return defineRuleListener(visitor, { "Program:exit"(program) {
77
60
  for (const { name = "anonymous", node: component } of ctx.getAllComponents(program)) context.report({
61
+ data: { json: stringify({ name }) },
78
62
  messageId: "default",
79
- node: component,
80
- data: { json: stringify({ name }) }
63
+ node: component
81
64
  });
82
65
  } });
83
66
  }
84
67
 
85
68
  //#endregion
86
- //#region src/rules/function-component.ts
69
+ //#region src/rules/function-component/function-component.ts
87
70
  const RULE_NAME$4 = "function-component";
88
71
  var function_component_default = createRule({
89
72
  meta: {
@@ -102,22 +85,22 @@ function create$4(context) {
102
85
  hint: core.DEFAULT_COMPONENT_DETECTION_HINT
103
86
  });
104
87
  return defineRuleListener(visitor, { "Program:exit"(program) {
105
- for (const { name = "anonymous", node, displayName, flag, hookCalls } of ctx.getAllComponents(program)) context.report({
106
- messageId: "default",
107
- node,
88
+ for (const { name, displayName, flag, hookCalls, node } of ctx.getAllComponents(program)) context.report({
108
89
  data: { json: stringify({
109
- name,
90
+ name: name ?? "anonymous",
110
91
  displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
111
92
  forwardRef: (flag & core.ComponentFlag.ForwardRef) > 0n,
112
93
  hookCalls: hookCalls.length,
113
94
  memo: (flag & core.ComponentFlag.Memo) > 0n
114
- }) }
95
+ }) },
96
+ messageId: "default",
97
+ node
115
98
  });
116
99
  } });
117
100
  }
118
101
 
119
102
  //#endregion
120
- //#region src/rules/hook.ts
103
+ //#region src/rules/hook/hook.ts
121
104
  const RULE_NAME$3 = "hook";
122
105
  var hook_default = createRule({
123
106
  meta: {
@@ -133,19 +116,19 @@ var hook_default = createRule({
133
116
  function create$3(context) {
134
117
  const { ctx, visitor } = core.useHookCollector(context);
135
118
  return defineRuleListener(visitor, { "Program:exit"(program) {
136
- for (const { name, node, hookCalls } of ctx.getAllHooks(program)) context.report({
137
- messageId: "default",
138
- node,
119
+ for (const { name, hookCalls, node } of ctx.getAllHooks(program)) context.report({
139
120
  data: { json: stringify({
140
121
  name,
141
122
  hookCalls: hookCalls.length
142
- }) }
123
+ }) },
124
+ messageId: "default",
125
+ node
143
126
  });
144
127
  } });
145
128
  }
146
129
 
147
130
  //#endregion
148
- //#region src/rules/is-from-react.ts
131
+ //#region src/rules/is-from-react/is-from-react.ts
149
132
  const RULE_NAME$2 = "is-from-react";
150
133
  var is_from_react_default = createRule({
151
134
  meta: {
@@ -165,18 +148,18 @@ function create$2(context) {
165
148
  const name = node.name;
166
149
  if (!isFromReact(node, context.sourceCode.getScope(node), importSource)) return;
167
150
  context.report({
168
- messageId: "default",
169
- node,
170
151
  data: { json: stringify({
171
152
  name,
172
153
  importSource
173
- }) }
154
+ }) },
155
+ messageId: "default",
156
+ node
174
157
  });
175
158
  }
176
- return {
159
+ return defineRuleListener({
177
160
  Identifier: visitorFunction,
178
161
  JSXIdentifier: visitorFunction
179
- };
162
+ });
180
163
  }
181
164
  /**
182
165
  * Check if an identifier node is initialized from React
@@ -195,7 +178,7 @@ function isFromReact(node, initialScope, importSource = "react") {
195
178
  }
196
179
 
197
180
  //#endregion
198
- //#region src/rules/is-from-ref.ts
181
+ //#region src/rules/is-from-ref/is-from-ref.ts
199
182
  const RULE_NAME$1 = "is-from-ref";
200
183
  var is_from_ref_default = createRule({
201
184
  meta: {
@@ -217,16 +200,16 @@ function create$1(context) {
217
200
  init: context.sourceCode.getText(refInit)
218
201
  });
219
202
  context.report({
203
+ data: { json },
220
204
  messageId: "default",
221
- node,
222
- data: { json }
205
+ node
223
206
  });
224
207
  }
225
208
  }
226
- return {
209
+ return defineRuleListener({
227
210
  Identifier: visitorFunction,
228
211
  JSXIdentifier: visitorFunction
229
- };
212
+ });
230
213
  }
231
214
  function getRefInitNode(node, initialScope) {
232
215
  const name = node.name;
@@ -238,8 +221,7 @@ function getRefInitNode(node, initialScope) {
238
221
  }
239
222
 
240
223
  //#endregion
241
- //#region src/rules/jsx.ts
242
- const { JsxEmit } = core;
224
+ //#region src/rules/jsx/jsx.ts
243
225
  const RULE_NAME = "jsx";
244
226
  var jsx_default = createRule({
245
227
  meta: {
@@ -253,35 +235,31 @@ var jsx_default = createRule({
253
235
  defaultOptions: []
254
236
  });
255
237
  function create(context) {
256
- const jsxConfigFromContext = core.getJsxConfigFromContext(context);
257
- const jsxConfigFromAnnotation = core.getJsxConfigFromAnnotation(context);
258
- const jsxConfig = {
259
- ...jsxConfigFromContext,
260
- ...jsxConfigFromAnnotation
261
- };
238
+ const jsx = JsxInspector.from(context);
239
+ const jsxConfig = jsx.jsxConfig;
262
240
  function getReportDescriptor(context) {
263
241
  return (node) => ({
264
- messageId: "default",
265
- node,
266
242
  data: { json: stringify({
267
- 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(),
268
- type: core.getJsxElementType(context, node),
243
+ kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => jsx.isFragmentElement(n) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
244
+ type: jsx.getElementType(node),
269
245
  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"),
270
246
  jsxFactory: jsxConfig.jsxFactory,
271
247
  jsxFragmentFactory: jsxConfig.jsxFragmentFactory,
272
248
  jsxImportSource: jsxConfig.jsxImportSource,
273
249
  jsxRuntime: match(jsxConfig.jsx).with(P.union(JsxEmit.None, JsxEmit.ReactJSX, JsxEmit.ReactJSXDev), () => "automatic").otherwise(() => "classic")
274
- }) }
250
+ }) },
251
+ messageId: "default",
252
+ node
275
253
  });
276
254
  }
277
- return { "JSXElement, JSXFragment": flow(getReportDescriptor(context), report(context)) };
255
+ return defineRuleListener({ "JSXElement, JSXFragment": flow(getReportDescriptor(context), report(context)) });
278
256
  }
279
257
 
280
258
  //#endregion
281
259
  //#region src/plugin.ts
282
260
  const plugin = {
283
261
  meta: {
284
- name,
262
+ name: name$1,
285
263
  version
286
264
  },
287
265
  rules: {
@@ -294,13 +272,32 @@ const plugin = {
294
272
  }
295
273
  };
296
274
 
275
+ //#endregion
276
+ //#region src/configs/all.ts
277
+ var all_exports = /* @__PURE__ */ __exportAll({
278
+ name: () => name,
279
+ plugins: () => plugins,
280
+ rules: () => rules,
281
+ settings: () => settings
282
+ });
283
+ const name = "react-debug/all";
284
+ const rules = {
285
+ "react-debug/class-component": "warn",
286
+ "react-debug/function-component": "warn",
287
+ "react-debug/hook": "warn",
288
+ "react-debug/is-from-react": "warn",
289
+ "react-debug/is-from-ref": "warn",
290
+ "react-debug/jsx": "warn"
291
+ };
292
+ const plugins = { "react-debug": plugin };
293
+ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
294
+
297
295
  //#endregion
298
296
  //#region src/index.ts
299
- const { toFlatConfig } = getConfigAdapters("react-debug", plugin);
300
- var src_default = {
297
+ const finalPlugin = {
301
298
  ...plugin,
302
- configs: { ["all"]: toFlatConfig(all_exports) }
299
+ configs: { ["all"]: all_exports }
303
300
  };
304
301
 
305
302
  //#endregion
306
- export { src_default as default };
303
+ export { finalPlugin as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-react-debug",
3
- "version": "3.0.0-next.7",
3
+ "version": "3.0.0-next.70",
4
4
  "description": "ESLint React's ESLint plugin for debugging related rules.",
5
5
  "keywords": [
6
6
  "react",
@@ -43,16 +43,17 @@
43
43
  "@typescript-eslint/types": "canary",
44
44
  "@typescript-eslint/utils": "canary",
45
45
  "ts-pattern": "^5.9.0",
46
- "@eslint-react/ast": "3.0.0-next.7",
47
- "@eslint-react/core": "3.0.0-next.7",
48
- "@eslint-react/eff": "3.0.0-next.7",
49
- "@eslint-react/var": "3.0.0-next.7",
50
- "@eslint-react/shared": "3.0.0-next.7"
46
+ "@eslint-react/ast": "3.0.0-next.70",
47
+ "@eslint-react/core": "3.0.0-next.70",
48
+ "@eslint-react/eff": "3.0.0-next.70",
49
+ "@eslint-react/shared": "3.0.0-next.70",
50
+ "@eslint-react/var": "3.0.0-next.70"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/react": "^19.2.14",
54
54
  "@types/react-dom": "^19.2.3",
55
- "tsdown": "^0.20.3",
55
+ "eslint": "^10.0.2",
56
+ "tsdown": "^0.21.0-beta.2",
56
57
  "@local/configs": "0.0.0"
57
58
  },
58
59
  "peerDependencies": {
@@ -68,6 +69,6 @@
68
69
  "scripts": {
69
70
  "build": "tsdown",
70
71
  "lint:publish": "publint",
71
- "lint:ts": "tsc --noEmit"
72
+ "lint:ts": "tsl"
72
73
  }
73
74
  }