eslint-plugin-react-dom 5.5.6-next.0 → 5.6.0-beta.2
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 +57 -47
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { merge } from "@eslint-react/eslint";
|
|
|
3
3
|
import { findAttribute, getAttributeStaticValue, getElementFullType, hasAnyAttribute, hasAttribute, isHostElement, isWhitespace, resolveAttributeValue } from "@eslint-react/jsx";
|
|
4
4
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
5
5
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
6
|
+
import { Check, Extract } from "@eslint-react/ast";
|
|
6
7
|
import { compare } from "compare-versions";
|
|
7
8
|
|
|
8
9
|
//#region \0rolldown/runtime.js
|
|
@@ -24,45 +25,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
24
25
|
//#endregion
|
|
25
26
|
//#region package.json
|
|
26
27
|
var name$2 = "eslint-plugin-react-dom";
|
|
27
|
-
var version = "5.
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/utils/create-jsx-element-resolver.ts
|
|
31
|
-
/**
|
|
32
|
-
* Creates a resolver for JSX elements that determines both the JSX element type
|
|
33
|
-
* and the underlying DOM element type.
|
|
34
|
-
*
|
|
35
|
-
* This resolver handles:
|
|
36
|
-
* 1. Regular HTML elements (div, span, etc.)
|
|
37
|
-
* 2. Polymorphic components (components that can render as different elements via a prop)
|
|
38
|
-
*
|
|
39
|
-
* @param context The ESLint rule context
|
|
40
|
-
* @returns An object with a resolve method to determine element types
|
|
41
|
-
*/
|
|
42
|
-
function createJsxElementResolver(context) {
|
|
43
|
-
const { polymorphicPropName } = getSettingsFromContext(context);
|
|
44
|
-
return {
|
|
45
|
-
/**
|
|
46
|
-
* Resolves the JSX element to determine its type and the underlying DOM element type
|
|
47
|
-
*
|
|
48
|
-
* @param node The JSX element node to resolve
|
|
49
|
-
* @returns An object containing the JSX element type and DOM element type
|
|
50
|
-
*/
|
|
51
|
-
resolve(node) {
|
|
52
|
-
const elementName = getElementFullType(node);
|
|
53
|
-
const result = {
|
|
54
|
-
domElementType: elementName,
|
|
55
|
-
jsxElementType: elementName
|
|
56
|
-
};
|
|
57
|
-
if (elementName === elementName.toLowerCase() || polymorphicPropName == null) return result;
|
|
58
|
-
const polyPropValue = getAttributeStaticValue(context, node, polymorphicPropName);
|
|
59
|
-
if (typeof polyPropValue === "string") return {
|
|
60
|
-
...result,
|
|
61
|
-
domElementType: polyPropValue
|
|
62
|
-
};
|
|
63
|
-
return result;
|
|
64
|
-
} };
|
|
65
|
-
}
|
|
28
|
+
var version = "5.6.0-beta.2";
|
|
66
29
|
|
|
67
30
|
//#endregion
|
|
68
31
|
//#region src/utils/create-rule.ts
|
|
@@ -221,15 +184,16 @@ function create$11(context) {
|
|
|
221
184
|
const hydrateNames = /* @__PURE__ */ new Set();
|
|
222
185
|
return merge({
|
|
223
186
|
CallExpression(node) {
|
|
187
|
+
const callee = Extract.unwrap(node.callee);
|
|
224
188
|
switch (true) {
|
|
225
|
-
case
|
|
189
|
+
case callee.type === AST_NODE_TYPES.Identifier && hydrateNames.has(callee.name):
|
|
226
190
|
context.report({
|
|
227
191
|
fix: getFix$2(context, node),
|
|
228
192
|
messageId: "default",
|
|
229
193
|
node
|
|
230
194
|
});
|
|
231
195
|
return;
|
|
232
|
-
case
|
|
196
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === hydrate && reactDomNames.has(callee.object.name):
|
|
233
197
|
context.report({
|
|
234
198
|
fix: getFix$2(context, node),
|
|
235
199
|
messageId: "default",
|
|
@@ -263,6 +227,44 @@ function getFix$2(context, node) {
|
|
|
263
227
|
};
|
|
264
228
|
}
|
|
265
229
|
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/utils/create-jsx-element-resolver.ts
|
|
232
|
+
/**
|
|
233
|
+
* Creates a resolver for JSX elements that determines both the JSX element type
|
|
234
|
+
* and the underlying DOM element type.
|
|
235
|
+
*
|
|
236
|
+
* This resolver handles:
|
|
237
|
+
* 1. Regular HTML elements (div, span, etc.)
|
|
238
|
+
* 2. Polymorphic components (components that can render as different elements via a prop)
|
|
239
|
+
*
|
|
240
|
+
* @param context The ESLint rule context
|
|
241
|
+
* @returns An object with a resolve method to determine element types
|
|
242
|
+
*/
|
|
243
|
+
function createJsxElementResolver(context) {
|
|
244
|
+
const { polymorphicPropName } = getSettingsFromContext(context);
|
|
245
|
+
return {
|
|
246
|
+
/**
|
|
247
|
+
* Resolves the JSX element to determine its type and the underlying DOM element type
|
|
248
|
+
*
|
|
249
|
+
* @param node The JSX element node to resolve
|
|
250
|
+
* @returns An object containing the JSX element type and DOM element type
|
|
251
|
+
*/
|
|
252
|
+
resolve(node) {
|
|
253
|
+
const elementName = getElementFullType(node);
|
|
254
|
+
const result = {
|
|
255
|
+
domElementType: elementName,
|
|
256
|
+
jsxElementType: elementName
|
|
257
|
+
};
|
|
258
|
+
if (elementName === elementName.toLowerCase() || polymorphicPropName == null) return result;
|
|
259
|
+
const polyPropValue = getAttributeStaticValue(context, node, polymorphicPropName);
|
|
260
|
+
if (typeof polyPropValue === "string") return {
|
|
261
|
+
...result,
|
|
262
|
+
domElementType: polyPropValue
|
|
263
|
+
};
|
|
264
|
+
return result;
|
|
265
|
+
} };
|
|
266
|
+
}
|
|
267
|
+
|
|
266
268
|
//#endregion
|
|
267
269
|
//#region src/rules/no-missing-button-type/no-missing-button-type.ts
|
|
268
270
|
const RULE_NAME$10 = "no-missing-button-type";
|
|
@@ -370,6 +372,11 @@ const banParentTypes = [
|
|
|
370
372
|
AST_NODE_TYPES.ArrowFunctionExpression,
|
|
371
373
|
AST_NODE_TYPES.AssignmentExpression
|
|
372
374
|
];
|
|
375
|
+
function isReturnValueUsed(node) {
|
|
376
|
+
let parent = node.parent;
|
|
377
|
+
while (Check.isTypeExpression(parent)) parent = parent.parent;
|
|
378
|
+
return banParentTypes.includes(parent.type);
|
|
379
|
+
}
|
|
373
380
|
var no_render_return_value_default = createRule({
|
|
374
381
|
meta: {
|
|
375
382
|
type: "problem",
|
|
@@ -386,14 +393,15 @@ function create$8(context) {
|
|
|
386
393
|
const renderNames = /* @__PURE__ */ new Set();
|
|
387
394
|
return merge({
|
|
388
395
|
CallExpression(node) {
|
|
396
|
+
const callee = Extract.unwrap(node.callee);
|
|
389
397
|
switch (true) {
|
|
390
|
-
case
|
|
398
|
+
case callee.type === AST_NODE_TYPES.Identifier && renderNames.has(callee.name) && isReturnValueUsed(node):
|
|
391
399
|
context.report({
|
|
392
400
|
messageId: "default",
|
|
393
401
|
node
|
|
394
402
|
});
|
|
395
403
|
return;
|
|
396
|
-
case
|
|
404
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "render" && reactDomNames.has(callee.object.name) && isReturnValueUsed(node):
|
|
397
405
|
context.report({
|
|
398
406
|
messageId: "default",
|
|
399
407
|
node
|
|
@@ -440,15 +448,16 @@ function create$7(context) {
|
|
|
440
448
|
const renderNames = /* @__PURE__ */ new Set();
|
|
441
449
|
return merge({
|
|
442
450
|
CallExpression(node) {
|
|
451
|
+
const callee = Extract.unwrap(node.callee);
|
|
443
452
|
switch (true) {
|
|
444
|
-
case
|
|
453
|
+
case callee.type === AST_NODE_TYPES.Identifier && renderNames.has(callee.name):
|
|
445
454
|
context.report({
|
|
446
455
|
fix: getFix$1(context, node),
|
|
447
456
|
messageId: "default",
|
|
448
457
|
node
|
|
449
458
|
});
|
|
450
459
|
return;
|
|
451
|
-
case
|
|
460
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "render" && reactDomNames.has(callee.object.name):
|
|
452
461
|
context.report({
|
|
453
462
|
fix: getFix$1(context, node),
|
|
454
463
|
messageId: "default",
|
|
@@ -1820,15 +1829,16 @@ function create$1(context) {
|
|
|
1820
1829
|
const useFormStateNames = /* @__PURE__ */ new Set();
|
|
1821
1830
|
return merge({
|
|
1822
1831
|
CallExpression(node) {
|
|
1832
|
+
const callee = Extract.unwrap(node.callee);
|
|
1823
1833
|
switch (true) {
|
|
1824
|
-
case
|
|
1834
|
+
case callee.type === AST_NODE_TYPES.Identifier && useFormStateNames.has(callee.name):
|
|
1825
1835
|
context.report({
|
|
1826
1836
|
fix: getFix(context, node),
|
|
1827
1837
|
messageId: "default",
|
|
1828
1838
|
node
|
|
1829
1839
|
});
|
|
1830
1840
|
return;
|
|
1831
|
-
case
|
|
1841
|
+
case callee.type === AST_NODE_TYPES.MemberExpression && callee.object.type === AST_NODE_TYPES.Identifier && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "useFormState" && reactDomNames.has(callee.object.name):
|
|
1832
1842
|
context.report({
|
|
1833
1843
|
fix: getFix(context, node),
|
|
1834
1844
|
messageId: "default",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0-beta.2",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -40,9 +40,10 @@
|
|
|
40
40
|
"@typescript-eslint/types": "^8.59.1",
|
|
41
41
|
"@typescript-eslint/utils": "^8.59.1",
|
|
42
42
|
"compare-versions": "^6.1.1",
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/jsx": "5.
|
|
45
|
-
"@eslint-react/
|
|
43
|
+
"@eslint-react/ast": "5.6.0-beta.2",
|
|
44
|
+
"@eslint-react/jsx": "5.6.0-beta.2",
|
|
45
|
+
"@eslint-react/eslint": "5.6.0-beta.2",
|
|
46
|
+
"@eslint-react/shared": "5.6.0-beta.2"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@types/react": "^19.2.14",
|