eslint-plugin-react-dom 2.0.1-beta.4 → 2.0.1-next.1
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 +28 -28
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS, getConfigAdapters, getDocsUrl, getSettingsFromContext } from "@eslint-react/shared";
|
|
2
|
-
import
|
|
2
|
+
import * as ER from "@eslint-react/core";
|
|
3
3
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
4
4
|
import { AST_NODE_TYPES } from "@typescript-eslint/types";
|
|
5
5
|
import { compare } from "compare-versions";
|
|
@@ -47,7 +47,7 @@ const settings = { "react-x": DEFAULT_ESLINT_REACT_SETTINGS };
|
|
|
47
47
|
//#endregion
|
|
48
48
|
//#region package.json
|
|
49
49
|
var name = "eslint-plugin-react-dom";
|
|
50
|
-
var version = "2.0.1-
|
|
50
|
+
var version = "2.0.1-next.1";
|
|
51
51
|
|
|
52
52
|
//#endregion
|
|
53
53
|
//#region src/utils/create-jsx-element-resolver.ts
|
|
@@ -65,15 +65,15 @@ var version = "2.0.1-beta.4";
|
|
|
65
65
|
function createJsxElementResolver(context) {
|
|
66
66
|
const { polymorphicPropName } = getSettingsFromContext(context);
|
|
67
67
|
return { resolve(node) {
|
|
68
|
-
const elementName = getElementType(context, node);
|
|
68
|
+
const elementName = ER.getElementType(context, node);
|
|
69
69
|
const result = {
|
|
70
70
|
domElementType: elementName,
|
|
71
71
|
jsxElementType: elementName
|
|
72
72
|
};
|
|
73
73
|
if (elementName === elementName.toLowerCase() || polymorphicPropName == null) return result;
|
|
74
|
-
const polymorphicProp = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))(polymorphicPropName);
|
|
74
|
+
const polymorphicProp = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))(polymorphicPropName);
|
|
75
75
|
if (polymorphicProp != null) {
|
|
76
|
-
const staticValue = resolveAttributeValue(context, polymorphicProp).toStatic(polymorphicPropName);
|
|
76
|
+
const staticValue = ER.resolveAttributeValue(context, polymorphicProp).toStatic(polymorphicPropName);
|
|
77
77
|
if (typeof staticValue === "string") return {
|
|
78
78
|
...result,
|
|
79
79
|
domElementType: staticValue
|
|
@@ -109,7 +109,7 @@ const dangerouslySetInnerHTML$1 = "dangerouslySetInnerHTML";
|
|
|
109
109
|
function create$16(context) {
|
|
110
110
|
if (!context.sourceCode.text.includes(dangerouslySetInnerHTML$1)) return {};
|
|
111
111
|
return { JSXElement(node) {
|
|
112
|
-
const attribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))(dangerouslySetInnerHTML$1);
|
|
112
|
+
const attribute = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))(dangerouslySetInnerHTML$1);
|
|
113
113
|
if (attribute == null) return;
|
|
114
114
|
context.report({
|
|
115
115
|
messageId: "noDangerouslySetInnerhtml",
|
|
@@ -142,7 +142,7 @@ function create$15(context) {
|
|
|
142
142
|
return { JSXElement(node) {
|
|
143
143
|
const attributes = node.openingElement.attributes;
|
|
144
144
|
const initialScope = context.sourceCode.getScope(node);
|
|
145
|
-
if ((node.children.some(isSignificantChildren) || hasAttribute(context, "children", attributes, initialScope)) && hasAttribute(context, dangerouslySetInnerHTML, attributes, initialScope)) context.report({
|
|
145
|
+
if ((node.children.some(isSignificantChildren) || ER.hasAttribute(context, "children", attributes, initialScope)) && ER.hasAttribute(context, dangerouslySetInnerHTML, attributes, initialScope)) context.report({
|
|
146
146
|
messageId: "noDangerouslySetInnerhtmlWithChildren",
|
|
147
147
|
node
|
|
148
148
|
});
|
|
@@ -162,7 +162,7 @@ function isWhiteSpace(node) {
|
|
|
162
162
|
* @returns boolean
|
|
163
163
|
*/
|
|
164
164
|
function isPaddingSpaces(node) {
|
|
165
|
-
return isJsxText(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
165
|
+
return ER.isJsxText(node) && isWhiteSpace(node) && node.raw.includes("\n");
|
|
166
166
|
}
|
|
167
167
|
function isSignificantChildren(node) {
|
|
168
168
|
return node.type !== AST_NODE_TYPES.JSXText || !isPaddingSpaces(node);
|
|
@@ -350,7 +350,7 @@ function create$11(context) {
|
|
|
350
350
|
return { JSXElement(node) {
|
|
351
351
|
const { domElementType } = resolver.resolve(node);
|
|
352
352
|
if (domElementType !== "button") return;
|
|
353
|
-
const typeAttribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("type");
|
|
353
|
+
const typeAttribute = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("type");
|
|
354
354
|
if (typeAttribute == null) {
|
|
355
355
|
context.report({
|
|
356
356
|
messageId: "noMissingButtonType",
|
|
@@ -361,7 +361,7 @@ function create$11(context) {
|
|
|
361
361
|
});
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
|
-
if (typeof resolveAttributeValue(context, typeAttribute).toStatic("type") === "string") return;
|
|
364
|
+
if (typeof ER.resolveAttributeValue(context, typeAttribute).toStatic("type") === "string") return;
|
|
365
365
|
context.report({
|
|
366
366
|
messageId: "noMissingButtonType",
|
|
367
367
|
node: typeAttribute,
|
|
@@ -407,7 +407,7 @@ function create$10(context) {
|
|
|
407
407
|
return { JSXElement(node) {
|
|
408
408
|
const { domElementType } = resolver.resolve(node);
|
|
409
409
|
if (domElementType !== "iframe") return;
|
|
410
|
-
const sandboxAttribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("sandbox");
|
|
410
|
+
const sandboxAttribute = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("sandbox");
|
|
411
411
|
if (sandboxAttribute == null) {
|
|
412
412
|
context.report({
|
|
413
413
|
messageId: "noMissingIframeSandbox",
|
|
@@ -422,7 +422,7 @@ function create$10(context) {
|
|
|
422
422
|
});
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
const sandboxAttributeValue = resolveAttributeValue(context, sandboxAttribute);
|
|
425
|
+
const sandboxAttributeValue = ER.resolveAttributeValue(context, sandboxAttribute);
|
|
426
426
|
if (typeof sandboxAttributeValue.toStatic("sandbox") === "string") return;
|
|
427
427
|
context.report({
|
|
428
428
|
messageId: "noMissingIframeSandbox",
|
|
@@ -459,7 +459,7 @@ var no_namespace_default = createRule({
|
|
|
459
459
|
});
|
|
460
460
|
function create$9(context) {
|
|
461
461
|
return { JSXElement(node) {
|
|
462
|
-
const name$2 = getElementType(context, node);
|
|
462
|
+
const name$2 = ER.getElementType(context, node);
|
|
463
463
|
if (typeof name$2 !== "string" || !name$2.includes(":")) return;
|
|
464
464
|
context.report({
|
|
465
465
|
messageId: "noNamespace",
|
|
@@ -621,7 +621,7 @@ var no_script_url_default = createRule({
|
|
|
621
621
|
function create$6(context) {
|
|
622
622
|
return { JSXAttribute(node) {
|
|
623
623
|
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) return;
|
|
624
|
-
const value = resolveAttributeValue(context, node).toStatic();
|
|
624
|
+
const value = ER.resolveAttributeValue(context, node).toStatic();
|
|
625
625
|
if (typeof value === "string" && RE_JAVASCRIPT_PROTOCOL.test(value)) context.report({
|
|
626
626
|
messageId: "noScriptUrl",
|
|
627
627
|
node: node.value
|
|
@@ -649,10 +649,10 @@ var no_string_style_prop_default = createRule({
|
|
|
649
649
|
});
|
|
650
650
|
function create$5(context) {
|
|
651
651
|
return { JSXElement(node) {
|
|
652
|
-
if (!isHostElement(context, node)) return;
|
|
653
|
-
const attribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("style");
|
|
652
|
+
if (!ER.isHostElement(context, node)) return;
|
|
653
|
+
const attribute = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("style");
|
|
654
654
|
if (attribute == null) return;
|
|
655
|
-
const attributeValue = resolveAttributeValue(context, attribute);
|
|
655
|
+
const attributeValue = ER.resolveAttributeValue(context, attribute);
|
|
656
656
|
if (typeof attributeValue.toStatic() === "string") context.report({
|
|
657
657
|
messageId: "noStringStyleProp",
|
|
658
658
|
node: attributeValue.node ?? attribute
|
|
@@ -1824,9 +1824,9 @@ function create$3(context) {
|
|
|
1824
1824
|
return { JSXElement(node) {
|
|
1825
1825
|
const { domElementType } = resolver.resolve(node);
|
|
1826
1826
|
if (domElementType !== "iframe") return;
|
|
1827
|
-
const sandboxAttribute = getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("sandbox");
|
|
1827
|
+
const sandboxAttribute = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node))("sandbox");
|
|
1828
1828
|
if (sandboxAttribute == null) return;
|
|
1829
|
-
const sandboxValue = resolveAttributeValue(context, sandboxAttribute);
|
|
1829
|
+
const sandboxValue = ER.resolveAttributeValue(context, sandboxAttribute);
|
|
1830
1830
|
const sandboxValueStatic = sandboxValue.toStatic("sandbox");
|
|
1831
1831
|
if (!isSafeSandbox(sandboxValueStatic)) context.report({
|
|
1832
1832
|
messageId: "noUnsafeIframeSandbox",
|
|
@@ -1883,15 +1883,15 @@ function create$2(context) {
|
|
|
1883
1883
|
return { JSXElement(node) {
|
|
1884
1884
|
const { domElementType } = resolver.resolve(node);
|
|
1885
1885
|
if (domElementType !== "a") return;
|
|
1886
|
-
const
|
|
1887
|
-
const targetAttribute =
|
|
1886
|
+
const getAttributes = ER.getAttribute(context, node.openingElement.attributes, context.sourceCode.getScope(node));
|
|
1887
|
+
const targetAttribute = getAttributes("target");
|
|
1888
1888
|
if (targetAttribute == null) return;
|
|
1889
|
-
if (resolveAttributeValue(context, targetAttribute).toStatic("target") !== "_blank") return;
|
|
1890
|
-
const hrefAttribute =
|
|
1889
|
+
if (ER.resolveAttributeValue(context, targetAttribute).toStatic("target") !== "_blank") return;
|
|
1890
|
+
const hrefAttribute = getAttributes("href");
|
|
1891
1891
|
if (hrefAttribute == null) return;
|
|
1892
|
-
const hrefAttributeValue = resolveAttributeValue(context, hrefAttribute).toStatic("href");
|
|
1892
|
+
const hrefAttributeValue = ER.resolveAttributeValue(context, hrefAttribute).toStatic("href");
|
|
1893
1893
|
if (!isExternalLinkLike(hrefAttributeValue)) return;
|
|
1894
|
-
const relAttribute =
|
|
1894
|
+
const relAttribute = getAttributes("rel");
|
|
1895
1895
|
if (relAttribute == null) {
|
|
1896
1896
|
context.report({
|
|
1897
1897
|
messageId: "noUnsafeTargetBlank",
|
|
@@ -1905,7 +1905,7 @@ function create$2(context) {
|
|
|
1905
1905
|
});
|
|
1906
1906
|
return;
|
|
1907
1907
|
}
|
|
1908
|
-
const relAttributeValue = resolveAttributeValue(context, relAttribute).toStatic("rel");
|
|
1908
|
+
const relAttributeValue = ER.resolveAttributeValue(context, relAttribute).toStatic("rel");
|
|
1909
1909
|
if (isSafeRel(relAttributeValue)) return;
|
|
1910
1910
|
context.report({
|
|
1911
1911
|
messageId: "noUnsafeTargetBlank",
|
|
@@ -2035,8 +2035,8 @@ function create(context) {
|
|
|
2035
2035
|
});
|
|
2036
2036
|
const { attributes } = node.openingElement;
|
|
2037
2037
|
const initialScope = context.sourceCode.getScope(node);
|
|
2038
|
-
const
|
|
2039
|
-
if (
|
|
2038
|
+
const hasAttribute = (name$2) => ER.hasAttribute(context, name$2, attributes, initialScope);
|
|
2039
|
+
if (hasAttribute("children") || hasAttribute("dangerouslySetInnerHTML")) context.report({
|
|
2040
2040
|
messageId: "noVoidElementsWithChildren",
|
|
2041
2041
|
node,
|
|
2042
2042
|
data: { element: elementName }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "2.0.1-
|
|
3
|
+
"version": "2.0.1-next.1",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"compare-versions": "^6.1.1",
|
|
42
42
|
"string-ts": "^2.2.1",
|
|
43
43
|
"ts-pattern": "^5.8.0",
|
|
44
|
-
"@eslint-react/ast": "2.0.1-
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
44
|
+
"@eslint-react/ast": "2.0.1-next.1",
|
|
45
|
+
"@eslint-react/eff": "2.0.1-next.1",
|
|
46
|
+
"@eslint-react/core": "2.0.1-next.1",
|
|
47
|
+
"@eslint-react/shared": "2.0.1-next.1",
|
|
48
|
+
"@eslint-react/var": "2.0.1-next.1",
|
|
49
|
+
"@eslint-react/kit": "2.0.1-next.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@types/react": "^19.1.
|
|
52
|
+
"@types/react": "^19.1.13",
|
|
53
53
|
"@types/react-dom": "^19.1.9",
|
|
54
54
|
"tsdown": "^0.15.4",
|
|
55
55
|
"@local/configs": "0.0.0"
|