eslint-plugin-react-debug 2.0.0-next.146 → 2.0.0-next.147
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 +38 -37
- package/dist/index.js +263 -280
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { RulePreset } from "@eslint-react/kit";
|
|
2
|
+
import * as _typescript_eslint_utils_ts_eslint0 from "@typescript-eslint/utils/ts-eslint";
|
|
3
3
|
|
|
4
|
+
//#region src/index.d.ts
|
|
4
5
|
declare const _default: {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
name: string;
|
|
23
|
-
rules: RulePreset;
|
|
6
|
+
configs: {
|
|
7
|
+
all: {
|
|
8
|
+
plugins: {
|
|
9
|
+
"react-debug": {
|
|
10
|
+
readonly meta: {
|
|
11
|
+
readonly name: string;
|
|
12
|
+
readonly version: string;
|
|
13
|
+
};
|
|
14
|
+
readonly rules: {
|
|
15
|
+
readonly "class-component": _typescript_eslint_utils_ts_eslint0.RuleModule<"classComponent", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
16
|
+
readonly "function-component": _typescript_eslint_utils_ts_eslint0.RuleModule<"functionComponent", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
17
|
+
readonly hook: _typescript_eslint_utils_ts_eslint0.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
18
|
+
readonly "is-from-react": _typescript_eslint_utils_ts_eslint0.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
19
|
+
readonly jsx: _typescript_eslint_utils_ts_eslint0.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
20
|
+
};
|
|
24
21
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
meta: {
|
|
31
|
-
readonly name: string;
|
|
32
|
-
readonly version: string;
|
|
22
|
+
};
|
|
23
|
+
name: string;
|
|
24
|
+
rules: RulePreset;
|
|
33
25
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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>;
|
|
26
|
+
"all-legacy": {
|
|
27
|
+
plugins: string[];
|
|
28
|
+
rules: RulePreset;
|
|
40
29
|
};
|
|
30
|
+
};
|
|
31
|
+
meta: {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly version: string;
|
|
34
|
+
};
|
|
35
|
+
rules: {
|
|
36
|
+
readonly "class-component": _typescript_eslint_utils_ts_eslint0.RuleModule<"classComponent", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
37
|
+
readonly "function-component": _typescript_eslint_utils_ts_eslint0.RuleModule<"functionComponent", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
38
|
+
readonly hook: _typescript_eslint_utils_ts_eslint0.RuleModule<"hook", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
39
|
+
readonly "is-from-react": _typescript_eslint_utils_ts_eslint0.RuleModule<"isFromReact", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
40
|
+
readonly jsx: _typescript_eslint_utils_ts_eslint0.RuleModule<"jsx", [], unknown, _typescript_eslint_utils_ts_eslint0.RuleListener>;
|
|
41
|
+
};
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
export { _default as default };
|
|
43
|
+
//#endregion
|
|
44
|
+
export { _default as default };
|
package/dist/index.js
CHANGED
|
@@ -1,319 +1,302 @@
|
|
|
1
|
-
import { getDocsUrl, getSettingsFromContext
|
|
2
|
-
import * as
|
|
3
|
-
import {
|
|
4
|
-
import { flow } from
|
|
5
|
-
import { JsxConfig, Reporter } from
|
|
6
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES$1 } from
|
|
7
|
-
import {
|
|
1
|
+
import { DEFAULT_ESLINT_REACT_SETTINGS, getDocsUrl, getSettingsFromContext } from "@eslint-react/shared";
|
|
2
|
+
import * as ER from "@eslint-react/core";
|
|
3
|
+
import { AST_NODE_TYPES, ESLintUtils } 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 { P, match } from "ts-pattern";
|
|
8
8
|
|
|
9
|
+
//#region rolldown:runtime
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
10
11
|
var __export = (target, all) => {
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
for (var name$2 in all) __defProp(target, name$2, {
|
|
13
|
+
get: all[name$2],
|
|
14
|
+
enumerable: true
|
|
15
|
+
});
|
|
13
16
|
};
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/configs/all.ts
|
|
16
20
|
var all_exports = {};
|
|
17
21
|
__export(all_exports, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
name: () => name$1,
|
|
23
|
+
rules: () => rules,
|
|
24
|
+
settings: () => settings
|
|
21
25
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
var settings = {
|
|
31
|
-
"react-x": DEFAULT_ESLINT_REACT_SETTINGS
|
|
26
|
+
const name$1 = "react-debug/all";
|
|
27
|
+
const rules = {
|
|
28
|
+
"react-debug/class-component": "warn",
|
|
29
|
+
"react-debug/function-component": "warn",
|
|
30
|
+
"react-debug/hook": "warn",
|
|
31
|
+
"react-debug/is-from-react": "warn",
|
|
32
|
+
"react-debug/jsx": "warn"
|
|
32
33
|
};
|
|
34
|
+
const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region package.json
|
|
38
|
+
var name = "eslint-plugin-react-debug";
|
|
39
|
+
var version = "2.0.0-next.147";
|
|
33
40
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/utils/create-rule.ts
|
|
43
|
+
const createRule = ESLintUtils.RuleCreator(getDocsUrl("debug"));
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/utils/stringify.ts
|
|
40
47
|
function stringify(value) {
|
|
41
|
-
|
|
48
|
+
return JSON.stringify(value, null, 2);
|
|
42
49
|
}
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
];
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/rules/class-component.ts
|
|
53
|
+
const RULE_NAME$4 = "class-component";
|
|
54
|
+
const RULE_FEATURES$4 = ["DBG"];
|
|
49
55
|
var class_component_default = createRule({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
create,
|
|
63
|
-
defaultOptions: []
|
|
56
|
+
meta: {
|
|
57
|
+
type: "problem",
|
|
58
|
+
docs: {
|
|
59
|
+
description: "Reports all class components.",
|
|
60
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$4
|
|
61
|
+
},
|
|
62
|
+
messages: { classComponent: "{{json}}" },
|
|
63
|
+
schema: []
|
|
64
|
+
},
|
|
65
|
+
name: RULE_NAME$4,
|
|
66
|
+
create: create$4,
|
|
67
|
+
defaultOptions: []
|
|
64
68
|
});
|
|
65
|
-
function create(context) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
69
|
+
function create$4(context) {
|
|
70
|
+
const { ctx, listeners } = ER.useComponentCollectorLegacy();
|
|
71
|
+
return {
|
|
72
|
+
...listeners,
|
|
73
|
+
"Program:exit"(program) {
|
|
74
|
+
const components = ctx.getAllComponents(program);
|
|
75
|
+
for (const { name: name$2 = "anonymous", node: component } of components.values()) context.report({
|
|
76
|
+
messageId: "classComponent",
|
|
77
|
+
node: component,
|
|
78
|
+
data: { json: stringify({ name: name$2 }) }
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/rules/function-component.ts
|
|
86
|
+
const RULE_NAME$3 = "function-component";
|
|
87
|
+
const RULE_FEATURES$3 = ["DBG"];
|
|
87
88
|
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: []
|
|
89
|
+
meta: {
|
|
90
|
+
type: "problem",
|
|
91
|
+
docs: {
|
|
92
|
+
description: "Reports all function components.",
|
|
93
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$3
|
|
94
|
+
},
|
|
95
|
+
messages: { functionComponent: "{{json}}" },
|
|
96
|
+
schema: []
|
|
97
|
+
},
|
|
98
|
+
name: RULE_NAME$3,
|
|
99
|
+
create: create$3,
|
|
100
|
+
defaultOptions: []
|
|
103
101
|
});
|
|
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
|
-
};
|
|
102
|
+
function create$3(context) {
|
|
103
|
+
const { ctx, listeners } = ER.useComponentCollector(context, {
|
|
104
|
+
collectDisplayName: true,
|
|
105
|
+
collectHookCalls: true,
|
|
106
|
+
hint: ER.DEFAULT_COMPONENT_DETECTION_HINT
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
...listeners,
|
|
110
|
+
"Program:exit"(program) {
|
|
111
|
+
const components = ctx.getAllComponents(program);
|
|
112
|
+
for (const { name: name$2 = "anonymous", node, displayName, flag, hookCalls } of components.values()) context.report({
|
|
113
|
+
messageId: "functionComponent",
|
|
114
|
+
node,
|
|
115
|
+
data: { json: stringify({
|
|
116
|
+
name: name$2,
|
|
117
|
+
displayName: displayName == null ? "none" : context.sourceCode.getText(displayName),
|
|
118
|
+
forwardRef: (flag & ER.ComponentFlag.ForwardRef) > 0n,
|
|
119
|
+
hookCalls: hookCalls.length,
|
|
120
|
+
memo: (flag & ER.ComponentFlag.Memo) > 0n
|
|
121
|
+
}) }
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
134
125
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
126
|
+
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/rules/hook.ts
|
|
129
|
+
const RULE_NAME$2 = "hook";
|
|
130
|
+
const RULE_FEATURES$2 = ["DBG"];
|
|
139
131
|
var hook_default = createRule({
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
create: create3,
|
|
153
|
-
defaultOptions: []
|
|
132
|
+
meta: {
|
|
133
|
+
type: "problem",
|
|
134
|
+
docs: {
|
|
135
|
+
description: "Reports all React Hooks.",
|
|
136
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$2
|
|
137
|
+
},
|
|
138
|
+
messages: { hook: "{{json}}" },
|
|
139
|
+
schema: []
|
|
140
|
+
},
|
|
141
|
+
name: RULE_NAME$2,
|
|
142
|
+
create: create$2,
|
|
143
|
+
defaultOptions: []
|
|
154
144
|
});
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
};
|
|
145
|
+
function create$2(context) {
|
|
146
|
+
const { ctx, listeners } = ER.useHookCollector();
|
|
147
|
+
return {
|
|
148
|
+
...listeners,
|
|
149
|
+
"Program:exit"(program) {
|
|
150
|
+
const allHooks = ctx.getAllHooks(program);
|
|
151
|
+
for (const { name: name$2, node, hookCalls } of allHooks.values()) context.report({
|
|
152
|
+
messageId: "hook",
|
|
153
|
+
node,
|
|
154
|
+
data: { json: stringify({
|
|
155
|
+
name: name$2,
|
|
156
|
+
hookCalls: hookCalls.length
|
|
157
|
+
}) }
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
};
|
|
175
161
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
162
|
+
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/rules/is-from-react.ts
|
|
165
|
+
const RULE_NAME$1 = "is-from-react";
|
|
166
|
+
const RULE_FEATURES$1 = ["DBG"];
|
|
180
167
|
var is_from_react_default = createRule({
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
create: create4,
|
|
194
|
-
defaultOptions: []
|
|
168
|
+
meta: {
|
|
169
|
+
type: "problem",
|
|
170
|
+
docs: {
|
|
171
|
+
description: "Reports all identifiers that are initialized from React.",
|
|
172
|
+
[Symbol.for("rule_features")]: RULE_FEATURES$1
|
|
173
|
+
},
|
|
174
|
+
messages: { isFromReact: "{{json}}" },
|
|
175
|
+
schema: []
|
|
176
|
+
},
|
|
177
|
+
name: RULE_NAME$1,
|
|
178
|
+
create: create$1,
|
|
179
|
+
defaultOptions: []
|
|
195
180
|
});
|
|
196
|
-
function
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
JSXIdentifier: visitorFunction
|
|
218
|
-
};
|
|
181
|
+
function create$1(context) {
|
|
182
|
+
const { importSource = "react" } = getSettingsFromContext(context);
|
|
183
|
+
function visitorFunction(node) {
|
|
184
|
+
const shouldSkipDuplicate = node.parent.type === AST_NODE_TYPES.ImportSpecifier && node.parent.imported === node && node.parent.imported.name === node.parent.local.name;
|
|
185
|
+
if (shouldSkipDuplicate) return;
|
|
186
|
+
const name$2 = node.name;
|
|
187
|
+
const initialScope = context.sourceCode.getScope(node);
|
|
188
|
+
if (!isFromReact(node, importSource, initialScope)) return;
|
|
189
|
+
context.report({
|
|
190
|
+
messageId: "isFromReact",
|
|
191
|
+
node,
|
|
192
|
+
data: { json: stringify({
|
|
193
|
+
name: name$2,
|
|
194
|
+
importSource
|
|
195
|
+
}) }
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
Identifier: visitorFunction,
|
|
200
|
+
JSXIdentifier: visitorFunction
|
|
201
|
+
};
|
|
219
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Check if an identifier node is initialized from React
|
|
205
|
+
* @param node The identifier node to check
|
|
206
|
+
* @param importSource The import source to check against
|
|
207
|
+
* @param initialScope Initial scope to search for the identifier
|
|
208
|
+
* @returns Whether the identifier node is initialized from React
|
|
209
|
+
*/
|
|
220
210
|
function isFromReact(node, importSource, initialScope) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
default:
|
|
228
|
-
return ER2.isInitializedFromReact(name3, importSource, initialScope);
|
|
229
|
-
}
|
|
211
|
+
const name$2 = node.name;
|
|
212
|
+
switch (true) {
|
|
213
|
+
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);
|
|
214
|
+
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);
|
|
215
|
+
default: return ER.isInitializedFromReact(name$2, importSource, initialScope);
|
|
216
|
+
}
|
|
230
217
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/rules/jsx.ts
|
|
221
|
+
const { JsxEmit } = JsxConfig;
|
|
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 = JsxConfig.getFromContext(context);
|
|
240
|
+
const jsxConfigFromAnnotation = JsxConfig.getFromAnnotation(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) => ER.isFragmentElement(context$1, n) ? "fragment" : "element").with({ type: AST_NODE_TYPES$1.JSXFragment }, () => "fragment").exhaustive(),
|
|
251
|
+
type: ER.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), Reporter.make(context).send) };
|
|
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
|
-
|
|
279
|
+
//#endregion
|
|
280
|
+
//#region src/index.ts
|
|
297
281
|
function makeConfig(config) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
};
|
|
282
|
+
return {
|
|
283
|
+
...config,
|
|
284
|
+
plugins: { "react-debug": plugin }
|
|
285
|
+
};
|
|
304
286
|
}
|
|
305
|
-
function makeLegacyConfig({ rules:
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
287
|
+
function makeLegacyConfig({ rules: rules$1 }) {
|
|
288
|
+
return {
|
|
289
|
+
plugins: ["react-debug"],
|
|
290
|
+
rules: rules$1
|
|
291
|
+
};
|
|
310
292
|
}
|
|
311
|
-
var
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
293
|
+
var src_default = {
|
|
294
|
+
...plugin,
|
|
295
|
+
configs: {
|
|
296
|
+
["all"]: makeConfig(all_exports),
|
|
297
|
+
["all-legacy"]: makeLegacyConfig(all_exports)
|
|
298
|
+
}
|
|
317
299
|
};
|
|
318
300
|
|
|
319
|
-
|
|
301
|
+
//#endregion
|
|
302
|
+
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.0-next.
|
|
3
|
+
"version": "2.0.0-next.147",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for debugging related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"@typescript-eslint/utils": "^8.40.0",
|
|
42
42
|
"string-ts": "^2.2.1",
|
|
43
43
|
"ts-pattern": "^5.8.0",
|
|
44
|
-
"@eslint-react/ast": "2.0.0-next.
|
|
45
|
-
"@eslint-react/core": "2.0.0-next.
|
|
46
|
-
"@eslint-react/kit": "2.0.0-next.
|
|
47
|
-
"@eslint-react/shared": "2.0.0-next.
|
|
48
|
-
"@eslint-react/var": "2.0.0-next.
|
|
49
|
-
"@eslint-react/eff": "2.0.0-next.
|
|
44
|
+
"@eslint-react/ast": "2.0.0-next.147",
|
|
45
|
+
"@eslint-react/core": "2.0.0-next.147",
|
|
46
|
+
"@eslint-react/kit": "2.0.0-next.147",
|
|
47
|
+
"@eslint-react/shared": "2.0.0-next.147",
|
|
48
|
+
"@eslint-react/var": "2.0.0-next.147",
|
|
49
|
+
"@eslint-react/eff": "2.0.0-next.147"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/react": "^19.1.11",
|
|
53
53
|
"@types/react-dom": "^19.1.7",
|
|
54
|
-
"
|
|
54
|
+
"tsdown": "^0.14.2",
|
|
55
55
|
"@local/configs": "0.0.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
75
|
"scripts": {
|
|
76
|
-
"build": "
|
|
76
|
+
"build": "tsdown --dts-resolve",
|
|
77
77
|
"lint:publish": "publint",
|
|
78
78
|
"lint:ts": "tsc --noEmit"
|
|
79
79
|
}
|