eslint-plugin-react-debug 2.0.0-next.9 → 2.0.1-beta.0
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/README.md +20 -17
- package/dist/index.d.ts +16 -39
- package/dist/index.js +257 -288
- package/package.json +18 -27
package/README.md
CHANGED
|
@@ -19,27 +19,30 @@ npm install --save-dev eslint-plugin-react-debug
|
|
|
19
19
|
// @ts-check
|
|
20
20
|
import js from "@eslint/js";
|
|
21
21
|
import reactDebug from "eslint-plugin-react-debug";
|
|
22
|
+
import { defineConfig } from "eslint/config";
|
|
22
23
|
import tseslint from "typescript-eslint";
|
|
23
24
|
|
|
24
|
-
export default
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
export default defineConfig([
|
|
26
|
+
{
|
|
27
|
+
files: ["**/*.ts", "**/*.tsx"],
|
|
28
|
+
extends: [
|
|
29
|
+
js.configs.recommended,
|
|
30
|
+
tseslint.configs.recommended,
|
|
31
|
+
reactDebug.configs.all,
|
|
32
|
+
],
|
|
33
|
+
languageOptions: {
|
|
34
|
+
parser: tseslint.parser,
|
|
35
|
+
parserOptions: {
|
|
36
|
+
projectService: true,
|
|
37
|
+
tsconfigRootDir: import.meta.dirname,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
rules: {
|
|
41
|
+
// Put rules you want to override here
|
|
42
|
+
"react-debug/function-component": "warn",
|
|
36
43
|
},
|
|
37
44
|
},
|
|
38
|
-
|
|
39
|
-
// Put rules you want to override here
|
|
40
|
-
"react-debug/function-component": "warn",
|
|
41
|
-
},
|
|
42
|
-
});
|
|
45
|
+
]);
|
|
43
46
|
```
|
|
44
47
|
|
|
45
48
|
## Rules
|
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,20 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { RulePreset } from '@eslint-react/kit';
|
|
1
|
+
import * as _eslint_react_kit0 from "@eslint-react/kit";
|
|
3
2
|
|
|
3
|
+
//#region src/index.d.ts
|
|
4
4
|
declare const _default: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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>;
|
|
5
|
+
configs: {
|
|
6
|
+
all: {
|
|
7
|
+
plugins: {};
|
|
8
|
+
name?: string;
|
|
9
|
+
rules?: Record<string, _eslint_react_kit0.RuleConfig>;
|
|
10
|
+
settings?: _eslint_react_kit0.SettingsConfig;
|
|
40
11
|
};
|
|
12
|
+
};
|
|
13
|
+
meta: {
|
|
14
|
+
name: string;
|
|
15
|
+
version: string;
|
|
16
|
+
};
|
|
17
|
+
rules: Record<string, _eslint_react_kit0.CompatibleRule>;
|
|
41
18
|
};
|
|
42
|
-
|
|
43
|
-
export { _default as default };
|
|
19
|
+
//#endregion
|
|
20
|
+
export { _default as default };
|
package/dist/index.js
CHANGED
|
@@ -1,319 +1,288 @@
|
|
|
1
|
-
import { getDocsUrl, getSettingsFromContext
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { DEFAULT_ESLINT_REACT_SETTINGS, getConfigAdapters, getDocsUrl, getSettingsFromContext } from "@eslint-react/shared";
|
|
2
|
+
import * as ER from "@eslint-react/core";
|
|
3
|
+
import { JsxEmit, getElementType, getJsxConfigFromAnnotation, getJsxConfigFromContext, isFragmentElement } from "@eslint-react/core";
|
|
4
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
5
|
+
import { flow } from "@eslint-react/eff";
|
|
6
|
+
import { report } from "@eslint-react/kit";
|
|
7
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from "@typescript-eslint/types";
|
|
8
|
+
import { P, match } from "ts-pattern";
|
|
8
9
|
|
|
10
|
+
//#region rolldown:runtime
|
|
9
11
|
var __defProp = Object.defineProperty;
|
|
10
|
-
var __export = (
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
var __export = (all) => {
|
|
13
|
+
let target = {};
|
|
14
|
+
for (var name$2 in all) __defProp(target, name$2, {
|
|
15
|
+
get: all[name$2],
|
|
16
|
+
enumerable: true
|
|
17
|
+
});
|
|
18
|
+
return target;
|
|
13
19
|
};
|
|
14
20
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
__export(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/configs/all.ts
|
|
23
|
+
var all_exports = /* @__PURE__ */ __export({
|
|
24
|
+
name: () => name$1,
|
|
25
|
+
rules: () => rules,
|
|
26
|
+
settings: () => settings
|
|
21
27
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
var settings = {
|
|
31
|
-
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
28
|
+
const name$1 = "react-debug/all";
|
|
29
|
+
const rules = {
|
|
30
|
+
"react-debug/class-component": "warn",
|
|
31
|
+
"react-debug/function-component": "warn",
|
|
32
|
+
"react-debug/hook": "warn",
|
|
33
|
+
"react-debug/is-from-react": "warn",
|
|
34
|
+
"react-debug/jsx": "warn"
|
|
32
35
|
};
|
|
36
|
+
const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
37
|
+
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region package.json
|
|
40
|
+
var name = "eslint-plugin-react-debug";
|
|
41
|
+
var version = "2.0.1-beta.0";
|
|
33
42
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/utils/create-rule.ts
|
|
45
|
+
const createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/utils/stringify.ts
|
|
40
49
|
function stringify(value) {
|
|
41
|
-
|
|
50
|
+
return JSON.stringify(value, null, 2);
|
|
42
51
|
}
|
|
43
52
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
];
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/rules/class-component.ts
|
|
55
|
+
const RULE_NAME$4 = "class-component";
|
|
56
|
+
const RULE_FEATURES$4 = ["DBG"];
|
|
49
57
|
var class_component_default = createRule({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
create,
|
|
63
|
-
defaultOptions: []
|
|
58
|
+
meta: {
|
|
59
|
+
type: "problem",
|
|
60
|
+
docs: {
|
|
61
|
+
description: "Reports all class components.",
|
|
62
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$4
|
|
63
|
+
},
|
|
64
|
+
messages: { classComponent: "{{json}}" },
|
|
65
|
+
schema: []
|
|
66
|
+
},
|
|
67
|
+
name: RULE_NAME$4,
|
|
68
|
+
create: create$4,
|
|
69
|
+
defaultOptions: []
|
|
64
70
|
});
|
|
65
|
-
function create(context) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
71
|
+
function create$4(context) {
|
|
72
|
+
const { ctx, listeners } = ER.useComponentCollectorLegacy();
|
|
73
|
+
return {
|
|
74
|
+
...listeners,
|
|
75
|
+
"Program:exit"(program) {
|
|
76
|
+
const components = ctx.getAllComponents(program);
|
|
77
|
+
for (const { name: name$2 = "anonymous", node: component } of components.values()) context.report({
|
|
78
|
+
messageId: "classComponent",
|
|
79
|
+
node: component,
|
|
80
|
+
data: { json: stringify({ name: name$2 }) }
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
82
84
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/rules/function-component.ts
|
|
88
|
+
const RULE_NAME$3 = "function-component";
|
|
89
|
+
const RULE_FEATURES$3 = ["DBG"];
|
|
87
90
|
var function_component_default = createRule({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
name: RULE_NAME2,
|
|
101
|
-
create: create2,
|
|
102
|
-
defaultOptions: []
|
|
91
|
+
meta: {
|
|
92
|
+
type: "problem",
|
|
93
|
+
docs: {
|
|
94
|
+
description: "Reports all function components.",
|
|
95
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$3
|
|
96
|
+
},
|
|
97
|
+
messages: { functionComponent: "{{json}}" },
|
|
98
|
+
schema: []
|
|
99
|
+
},
|
|
100
|
+
name: RULE_NAME$3,
|
|
101
|
+
create: create$3,
|
|
102
|
+
defaultOptions: []
|
|
103
103
|
});
|
|
104
|
-
function
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
memo: (flag & ER2.ComponentFlag.Memo) > 0n
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
};
|
|
104
|
+
function create$3(context) {
|
|
105
|
+
const { ctx, listeners } = ER.useComponentCollector(context, {
|
|
106
|
+
collectDisplayName: true,
|
|
107
|
+
collectHookCalls: true,
|
|
108
|
+
hint: ER.DEFAULT_COMPONENT_DETECTION_HINT
|
|
109
|
+
});
|
|
110
|
+
return {
|
|
111
|
+
...listeners,
|
|
112
|
+
"Program:exit"(program) {
|
|
113
|
+
const components = ctx.getAllComponents(program);
|
|
114
|
+
for (const { name: name$2 = "anonymous", node, displayName, flag, hookCalls } of components.values()) context.report({
|
|
115
|
+
messageId: "functionComponent",
|
|
116
|
+
node,
|
|
117
|
+
data: { json: stringify({
|
|
118
|
+
name: name$2,
|
|
119
|
+
displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
|
|
120
|
+
forwardRef: (flag & ER.ComponentFlag.ForwardRef) > 0n,
|
|
121
|
+
hookCalls: hookCalls.length,
|
|
122
|
+
memo: (flag & ER.ComponentFlag.Memo) > 0n
|
|
123
|
+
}) }
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
};
|
|
134
127
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
128
|
+
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/rules/hook.ts
|
|
131
|
+
const RULE_NAME$2 = "hook";
|
|
132
|
+
const RULE_FEATURES$2 = ["DBG"];
|
|
139
133
|
var hook_default = createRule({
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
create: create3,
|
|
153
|
-
defaultOptions: []
|
|
134
|
+
meta: {
|
|
135
|
+
type: "problem",
|
|
136
|
+
docs: {
|
|
137
|
+
description: "Reports all React Hooks.",
|
|
138
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$2
|
|
139
|
+
},
|
|
140
|
+
messages: { hook: "{{json}}" },
|
|
141
|
+
schema: []
|
|
142
|
+
},
|
|
143
|
+
name: RULE_NAME$2,
|
|
144
|
+
create: create$2,
|
|
145
|
+
defaultOptions: []
|
|
154
146
|
});
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
147
|
+
function create$2(context) {
|
|
148
|
+
const { ctx, listeners } = ER.useHookCollector();
|
|
149
|
+
return {
|
|
150
|
+
...listeners,
|
|
151
|
+
"Program:exit"(program) {
|
|
152
|
+
const allHooks = ctx.getAllHooks(program);
|
|
153
|
+
for (const { name: name$2, node, hookCalls } of allHooks.values()) context.report({
|
|
154
|
+
messageId: "hook",
|
|
155
|
+
node,
|
|
156
|
+
data: { json: stringify({
|
|
157
|
+
name: name$2,
|
|
158
|
+
hookCalls: hookCalls.length
|
|
159
|
+
}) }
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
};
|
|
175
163
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
164
|
+
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/rules/is-from-react.ts
|
|
167
|
+
const RULE_NAME$1 = "is-from-react";
|
|
168
|
+
const RULE_FEATURES$1 = ["DBG"];
|
|
180
169
|
var is_from_react_default = createRule({
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
create: create4,
|
|
194
|
-
defaultOptions: []
|
|
170
|
+
meta: {
|
|
171
|
+
type: "problem",
|
|
172
|
+
docs: {
|
|
173
|
+
description: "Reports all identifiers that are initialized from React.",
|
|
174
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$1
|
|
175
|
+
},
|
|
176
|
+
messages: { isFromReact: "{{json}}" },
|
|
177
|
+
schema: []
|
|
178
|
+
},
|
|
179
|
+
name: RULE_NAME$1,
|
|
180
|
+
create: create$1,
|
|
181
|
+
defaultOptions: []
|
|
195
182
|
});
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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
|
-
};
|
|
183
|
+
function create$1(context) {
|
|
184
|
+
const { importSource = "react" } = getSettingsFromContext(context);
|
|
185
|
+
function visitorFunction(node) {
|
|
186
|
+
if (node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name) return;
|
|
187
|
+
const name$2 = node.name;
|
|
188
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
189
|
+
if (!isFromReact(node, importSource, initialScope)) return;
|
|
190
|
+
context.report({
|
|
191
|
+
messageId: "isFromReact",
|
|
192
|
+
node,
|
|
193
|
+
data: { json: stringify({
|
|
194
|
+
name: name$2,
|
|
195
|
+
importSource
|
|
196
|
+
}) }
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
Identifier: visitorFunction,
|
|
201
|
+
JSXIdentifier: visitorFunction
|
|
202
|
+
};
|
|
230
203
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Check if an identifier node is initialized from React
|
|
206
|
+
* @param node The identifier node to check
|
|
207
|
+
* @param importSource The import source to check against
|
|
208
|
+
* @param initialScope Initial scope to search for the identifier
|
|
209
|
+
* @returns Whether the identifier node is initialized from React
|
|
210
|
+
*/
|
|
211
|
+
function isFromReact(node, importSource, initialScope) {
|
|
212
|
+
const name$2 = node.name;
|
|
213
|
+
switch (true) {
|
|
214
|
+
case node.parent.type === AST_NODE_TYPES.MemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.Identifier: return ER.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
|
|
215
|
+
case node.parent.type === AST_NODE_TYPES.JSXMemberExpression && node.parent.property === node && node.parent.object.type === AST_NODE_TYPES.JSXIdentifier: return ER.isInitializedFromReact(node.parent.object.name, importSource, initialScope);
|
|
216
|
+
default: return ER.isInitializedFromReact(name$2, importSource, initialScope);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/rules/jsx.ts
|
|
222
|
+
const RULE_NAME = "jsx";
|
|
223
|
+
const RULE_FEATURES = ["DBG"];
|
|
236
224
|
var jsx_default = createRule({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
create: create5,
|
|
250
|
-
defaultOptions: []
|
|
225
|
+
meta: {
|
|
226
|
+
type: "problem",
|
|
227
|
+
docs: {
|
|
228
|
+
description: "Reports all JSX elements and fragments.",
|
|
229
|
+
[Symbol.for("rule_features")]: RULE_FEATURES
|
|
230
|
+
},
|
|
231
|
+
messages: { jsx: "{{json}}" },
|
|
232
|
+
schema: []
|
|
233
|
+
},
|
|
234
|
+
name: RULE_NAME,
|
|
235
|
+
create,
|
|
236
|
+
defaultOptions: []
|
|
251
237
|
});
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
276
|
-
return {
|
|
277
|
-
"JSXElement, JSXFragment": flow(getReportDescriptor(context), Reporter.make(context).send)
|
|
278
|
-
};
|
|
238
|
+
function create(context) {
|
|
239
|
+
const jsxConfigFromContext = getJsxConfigFromContext(context);
|
|
240
|
+
const jsxConfigFromAnnotation = getJsxConfigFromAnnotation(context);
|
|
241
|
+
const jsxConfig = {
|
|
242
|
+
...jsxConfigFromContext,
|
|
243
|
+
...jsxConfigFromAnnotation
|
|
244
|
+
};
|
|
245
|
+
function getReportDescriptor(context$1) {
|
|
246
|
+
return (node) => ({
|
|
247
|
+
messageId: "jsx",
|
|
248
|
+
node,
|
|
249
|
+
data: { json: stringify({
|
|
250
|
+
kind: match(node).with({ type: AST_NODE_TYPES$1.JSXElement }, (n) => isFragmentElement(context$1, n) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
|
|
251
|
+
type: getElementType(context$1, node),
|
|
252
|
+
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"),
|
|
253
|
+
jsxFactory: jsxConfig.jsxFactory,
|
|
254
|
+
jsxFragmentFactory: jsxConfig.jsxFragmentFactory,
|
|
255
|
+
jsxImportSource: jsxConfig.jsxImportSource,
|
|
256
|
+
jsxRuntime: match(jsxConfig.jsx).with(P.union(JsxEmit.None, JsxEmit.ReactJSX, JsxEmit.ReactJSXDev), () => "automatic").otherwise(() => "classic")
|
|
257
|
+
}) }
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
return { "JSXElement, JSXFragment": flow(getReportDescriptor(context), report(context)) };
|
|
279
261
|
}
|
|
280
262
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/plugin.ts
|
|
265
|
+
const plugin = {
|
|
266
|
+
meta: {
|
|
267
|
+
name,
|
|
268
|
+
version
|
|
269
|
+
},
|
|
270
|
+
rules: {
|
|
271
|
+
["class-component"]: class_component_default,
|
|
272
|
+
["function-component"]: function_component_default,
|
|
273
|
+
["hook"]: hook_default,
|
|
274
|
+
["is-from-react"]: is_from_react_default,
|
|
275
|
+
["jsx"]: jsx_default
|
|
276
|
+
}
|
|
294
277
|
};
|
|
295
278
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
}
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/index.ts
|
|
281
|
+
const { toFlatConfig } = getConfigAdapters("react-debug", plugin);
|
|
282
|
+
var src_default = {
|
|
283
|
+
...plugin,
|
|
284
|
+
configs: { ["all"]: toFlatConfig(all_exports) }
|
|
317
285
|
};
|
|
318
286
|
|
|
319
|
-
|
|
287
|
+
//#endregion
|
|
288
|
+
export { src_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-debug",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1-beta.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for debugging related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,46 +35,37 @@
|
|
|
35
35
|
"./package.json"
|
|
36
36
|
],
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@typescript-eslint/scope-manager": "^8.
|
|
39
|
-
"@typescript-eslint/type-utils": "^8.
|
|
40
|
-
"@typescript-eslint/types": "^8.
|
|
41
|
-
"@typescript-eslint/utils": "^8.
|
|
38
|
+
"@typescript-eslint/scope-manager": "^8.44.1",
|
|
39
|
+
"@typescript-eslint/type-utils": "^8.44.1",
|
|
40
|
+
"@typescript-eslint/types": "^8.44.1",
|
|
41
|
+
"@typescript-eslint/utils": "^8.44.1",
|
|
42
42
|
"string-ts": "^2.2.1",
|
|
43
|
-
"ts-pattern": "^5.
|
|
44
|
-
"@eslint-react/ast": "2.0.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/kit": "2.0.
|
|
48
|
-
"@eslint-react/shared": "2.0.
|
|
49
|
-
"@eslint-react/var": "2.0.
|
|
43
|
+
"ts-pattern": "^5.8.0",
|
|
44
|
+
"@eslint-react/ast": "2.0.1-beta.0",
|
|
45
|
+
"@eslint-react/core": "2.0.1-beta.0",
|
|
46
|
+
"@eslint-react/eff": "2.0.1-beta.0",
|
|
47
|
+
"@eslint-react/kit": "2.0.1-beta.0",
|
|
48
|
+
"@eslint-react/shared": "2.0.1-beta.0",
|
|
49
|
+
"@eslint-react/var": "2.0.1-beta.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/react": "^19.1.
|
|
53
|
-
"@types/react-dom": "^19.1.
|
|
54
|
-
"
|
|
52
|
+
"@types/react": "^19.1.13",
|
|
53
|
+
"@types/react-dom": "^19.1.9",
|
|
54
|
+
"tsdown": "^0.15.4",
|
|
55
55
|
"@local/configs": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"eslint": "^9.
|
|
59
|
-
"typescript": "^
|
|
60
|
-
},
|
|
61
|
-
"peerDependenciesMeta": {
|
|
62
|
-
"eslint": {
|
|
63
|
-
"optional": false
|
|
64
|
-
},
|
|
65
|
-
"typescript": {
|
|
66
|
-
"optional": true
|
|
67
|
-
}
|
|
58
|
+
"eslint": "^9.36.0",
|
|
59
|
+
"typescript": "^5.9.2"
|
|
68
60
|
},
|
|
69
61
|
"engines": {
|
|
70
|
-
"bun": ">=1.0.15",
|
|
71
62
|
"node": ">=20.19.0"
|
|
72
63
|
},
|
|
73
64
|
"publishConfig": {
|
|
74
65
|
"access": "public"
|
|
75
66
|
},
|
|
76
67
|
"scripts": {
|
|
77
|
-
"build": "
|
|
68
|
+
"build": "tsdown",
|
|
78
69
|
"lint:publish": "publint",
|
|
79
70
|
"lint:ts": "tsc --noEmit"
|
|
80
71
|
}
|