eslint-plugin-react-dom 2.8.1 → 2.8.2-next.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/dist/index.js +23 -23
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DEFAULT_ESLINT_REACT_SETTINGS, RE_JAVASCRIPT_PROTOCOL, WEBSITE_URL, getConfigAdapters, getSettingsFromContext } from "@eslint-react/shared";
|
|
2
|
-
import
|
|
2
|
+
import * as core 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";
|
|
@@ -23,7 +23,7 @@ var __exportAll = (all, symbols) => {
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region package.json
|
|
25
25
|
var name$2 = "eslint-plugin-react-dom";
|
|
26
|
-
var version = "2.8.
|
|
26
|
+
var version = "2.8.2-next.0";
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/utils/create-jsx-element-resolver.ts
|
|
@@ -41,15 +41,15 @@ var version = "2.8.1";
|
|
|
41
41
|
function createJsxElementResolver(context) {
|
|
42
42
|
const { polymorphicPropName } = getSettingsFromContext(context);
|
|
43
43
|
return { resolve(node) {
|
|
44
|
-
const elementName = getJsxElementType(context, node);
|
|
44
|
+
const elementName = core.getJsxElementType(context, node);
|
|
45
45
|
const result = {
|
|
46
46
|
domElementType: elementName,
|
|
47
47
|
jsxElementType: elementName
|
|
48
48
|
};
|
|
49
49
|
if (elementName === elementName.toLowerCase() || polymorphicPropName == null) return result;
|
|
50
|
-
const polymorphicProp = getJsxAttribute(context, node)(polymorphicPropName);
|
|
50
|
+
const polymorphicProp = core.getJsxAttribute(context, node)(polymorphicPropName);
|
|
51
51
|
if (polymorphicProp != null) {
|
|
52
|
-
const staticValue = resolveJsxAttributeValue(context, polymorphicProp).toStatic(polymorphicPropName);
|
|
52
|
+
const staticValue = core.resolveJsxAttributeValue(context, polymorphicProp).toStatic(polymorphicPropName);
|
|
53
53
|
if (typeof staticValue === "string") return {
|
|
54
54
|
...result,
|
|
55
55
|
domElementType: staticValue
|
|
@@ -84,7 +84,7 @@ var no_dangerously_set_innerhtml_default = createRule({
|
|
|
84
84
|
function create$17(context) {
|
|
85
85
|
if (!context.sourceCode.text.includes(DSIH$1)) return {};
|
|
86
86
|
return { JSXElement(node) {
|
|
87
|
-
const dsihProp = getJsxAttribute(context, node)(DSIH$1);
|
|
87
|
+
const dsihProp = core.getJsxAttribute(context, node)(DSIH$1);
|
|
88
88
|
if (dsihProp == null) return;
|
|
89
89
|
context.report({
|
|
90
90
|
messageId: "noDangerouslySetInnerhtml",
|
|
@@ -114,13 +114,13 @@ const DSIH = "dangerouslySetInnerHTML";
|
|
|
114
114
|
* @returns `true` if the node is significant, `false` otherwise
|
|
115
115
|
*/
|
|
116
116
|
function isSignificantChildren(node) {
|
|
117
|
-
if (!isJsxText(node)) return true;
|
|
117
|
+
if (!core.isJsxText(node)) return true;
|
|
118
118
|
return !(node.raw.trim() === "" && node.raw.includes("\n"));
|
|
119
119
|
}
|
|
120
120
|
function create$16(context) {
|
|
121
121
|
if (!context.sourceCode.text.includes(DSIH)) return {};
|
|
122
122
|
return { JSXElement(node) {
|
|
123
|
-
const findJsxAttribute = getJsxAttribute(context, node);
|
|
123
|
+
const findJsxAttribute = core.getJsxAttribute(context, node);
|
|
124
124
|
if (findJsxAttribute(DSIH) == null) return;
|
|
125
125
|
const childrenPropOrNode = findJsxAttribute("children") ?? node.children.find(isSignificantChildren);
|
|
126
126
|
if (childrenPropOrNode == null) return;
|
|
@@ -295,7 +295,7 @@ function create$12(context) {
|
|
|
295
295
|
const resolver = createJsxElementResolver(context);
|
|
296
296
|
return { JSXElement(node) {
|
|
297
297
|
if (resolver.resolve(node).domElementType !== "button") return;
|
|
298
|
-
if (getJsxAttribute(context, node)("type") != null) return;
|
|
298
|
+
if (core.getJsxAttribute(context, node)("type") != null) return;
|
|
299
299
|
context.report({
|
|
300
300
|
messageId: "missingTypeAttribute",
|
|
301
301
|
node: node.openingElement,
|
|
@@ -332,7 +332,7 @@ function create$11(context) {
|
|
|
332
332
|
return { JSXElement(node) {
|
|
333
333
|
const { domElementType } = resolver.resolve(node);
|
|
334
334
|
if (domElementType !== "iframe") return;
|
|
335
|
-
const sandboxProp = getJsxAttribute(context, node)("sandbox");
|
|
335
|
+
const sandboxProp = core.getJsxAttribute(context, node)("sandbox");
|
|
336
336
|
if (sandboxProp == null) {
|
|
337
337
|
context.report({
|
|
338
338
|
messageId: "missingSandboxAttribute",
|
|
@@ -347,7 +347,7 @@ function create$11(context) {
|
|
|
347
347
|
});
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
|
-
const sandboxValue = resolveJsxAttributeValue(context, sandboxProp);
|
|
350
|
+
const sandboxValue = core.resolveJsxAttributeValue(context, sandboxProp);
|
|
351
351
|
if (typeof sandboxValue.toStatic("sandbox") === "string") return;
|
|
352
352
|
context.report({
|
|
353
353
|
messageId: "missingSandboxAttribute",
|
|
@@ -380,7 +380,7 @@ var no_namespace_default = createRule({
|
|
|
380
380
|
});
|
|
381
381
|
function create$10(context) {
|
|
382
382
|
return { JSXElement(node) {
|
|
383
|
-
const name = getJsxElementType(context, node);
|
|
383
|
+
const name = core.getJsxElementType(context, node);
|
|
384
384
|
if (typeof name !== "string" || !name.includes(":")) return;
|
|
385
385
|
context.report({
|
|
386
386
|
messageId: "noNamespace",
|
|
@@ -535,7 +535,7 @@ var no_script_url_default = createRule({
|
|
|
535
535
|
function create$7(context) {
|
|
536
536
|
return { JSXAttribute(node) {
|
|
537
537
|
if (node.name.type !== AST_NODE_TYPES.JSXIdentifier || node.value == null) return;
|
|
538
|
-
const value = resolveJsxAttributeValue(context, node).toStatic();
|
|
538
|
+
const value = core.resolveJsxAttributeValue(context, node).toStatic();
|
|
539
539
|
if (typeof value === "string" && RE_JAVASCRIPT_PROTOCOL.test(value)) context.report({
|
|
540
540
|
messageId: "noScriptUrl",
|
|
541
541
|
node: node.value
|
|
@@ -559,10 +559,10 @@ var no_string_style_prop_default = createRule({
|
|
|
559
559
|
});
|
|
560
560
|
function create$6(context) {
|
|
561
561
|
return { JSXElement(node) {
|
|
562
|
-
if (!isJsxHostElement(context, node)) return;
|
|
563
|
-
const styleProp = getJsxAttribute(context, node)("style");
|
|
562
|
+
if (!core.isJsxHostElement(context, node)) return;
|
|
563
|
+
const styleProp = core.getJsxAttribute(context, node)("style");
|
|
564
564
|
if (styleProp == null) return;
|
|
565
|
-
const styleValue = resolveJsxAttributeValue(context, styleProp);
|
|
565
|
+
const styleValue = core.resolveJsxAttributeValue(context, styleProp);
|
|
566
566
|
if (typeof styleValue.toStatic() === "string") context.report({
|
|
567
567
|
messageId: "noStringStyleProp",
|
|
568
568
|
node: styleValue.node ?? styleProp
|
|
@@ -1734,9 +1734,9 @@ function create$4(context) {
|
|
|
1734
1734
|
const resolver = createJsxElementResolver(context);
|
|
1735
1735
|
return { JSXElement(node) {
|
|
1736
1736
|
if (resolver.resolve(node).domElementType !== "iframe") return;
|
|
1737
|
-
const sandboxProp = getJsxAttribute(context, node)("sandbox");
|
|
1737
|
+
const sandboxProp = core.getJsxAttribute(context, node)("sandbox");
|
|
1738
1738
|
if (sandboxProp == null) return;
|
|
1739
|
-
const sandboxValue = resolveJsxAttributeValue(context, sandboxProp);
|
|
1739
|
+
const sandboxValue = core.resolveJsxAttributeValue(context, sandboxProp);
|
|
1740
1740
|
if (isUnsafeSandboxCombination(sandboxValue.toStatic("sandbox"))) context.report({
|
|
1741
1741
|
messageId: "noUnsafeIframeSandbox",
|
|
1742
1742
|
node: sandboxValue.node ?? sandboxProp
|
|
@@ -1788,13 +1788,13 @@ function create$3(context) {
|
|
|
1788
1788
|
return { JSXElement(node) {
|
|
1789
1789
|
const { domElementType } = resolver.resolve(node);
|
|
1790
1790
|
if (domElementType !== "a") return;
|
|
1791
|
-
const findAttribute = getJsxAttribute(context, node);
|
|
1791
|
+
const findAttribute = core.getJsxAttribute(context, node);
|
|
1792
1792
|
const targetProp = findAttribute("target");
|
|
1793
1793
|
if (targetProp == null) return;
|
|
1794
|
-
if (resolveJsxAttributeValue(context, targetProp).toStatic("target") !== "_blank") return;
|
|
1794
|
+
if (core.resolveJsxAttributeValue(context, targetProp).toStatic("target") !== "_blank") return;
|
|
1795
1795
|
const hrefProp = findAttribute("href");
|
|
1796
1796
|
if (hrefProp == null) return;
|
|
1797
|
-
if (!isExternalLinkLike(resolveJsxAttributeValue(context, hrefProp).toStatic("href"))) return;
|
|
1797
|
+
if (!isExternalLinkLike(core.resolveJsxAttributeValue(context, hrefProp).toStatic("href"))) return;
|
|
1798
1798
|
const relProp = findAttribute("rel");
|
|
1799
1799
|
if (relProp == null) {
|
|
1800
1800
|
context.report({
|
|
@@ -1809,7 +1809,7 @@ function create$3(context) {
|
|
|
1809
1809
|
});
|
|
1810
1810
|
return;
|
|
1811
1811
|
}
|
|
1812
|
-
if (isSafeRel(resolveJsxAttributeValue(context, relProp).toStatic("rel"))) return;
|
|
1812
|
+
if (isSafeRel(core.resolveJsxAttributeValue(context, relProp).toStatic("rel"))) return;
|
|
1813
1813
|
context.report({
|
|
1814
1814
|
messageId: "noUnsafeTargetBlank",
|
|
1815
1815
|
node: relProp,
|
|
@@ -1922,7 +1922,7 @@ function create$1(context) {
|
|
|
1922
1922
|
return { JSXElement(node) {
|
|
1923
1923
|
const { domElementType } = resolver.resolve(node);
|
|
1924
1924
|
if (!voidElements.has(domElementType)) return;
|
|
1925
|
-
const findJsxAttribute = getJsxAttribute(context, node);
|
|
1925
|
+
const findJsxAttribute = core.getJsxAttribute(context, node);
|
|
1926
1926
|
const hasChildrenProp = findJsxAttribute("children") != null;
|
|
1927
1927
|
const hasDangerouslySetInnerHTML = findJsxAttribute("dangerouslySetInnerHTML") != null;
|
|
1928
1928
|
if (node.children.length > 0 || hasChildrenProp || hasDangerouslySetInnerHTML) context.report({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2-next.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"compare-versions": "^6.1.1",
|
|
45
45
|
"string-ts": "^2.3.1",
|
|
46
46
|
"ts-pattern": "^5.9.0",
|
|
47
|
-
"@eslint-react/ast": "2.8.
|
|
48
|
-
"@eslint-react/
|
|
49
|
-
"@eslint-react/
|
|
50
|
-
"@eslint-react/
|
|
51
|
-
"@eslint-react/
|
|
47
|
+
"@eslint-react/ast": "2.8.2-next.0",
|
|
48
|
+
"@eslint-react/core": "2.8.2-next.0",
|
|
49
|
+
"@eslint-react/shared": "2.8.2-next.0",
|
|
50
|
+
"@eslint-react/var": "2.8.2-next.0",
|
|
51
|
+
"@eslint-react/eff": "2.8.2-next.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/react": "^19.2.10",
|