eslint-plugin-react-dom 1.17.4-next.9 → 1.18.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 +16 -16
- package/dist/index.mjs +16 -16
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var core = require('@eslint-react/core');
|
|
4
3
|
var JSX9 = require('@eslint-react/jsx');
|
|
5
4
|
var tools = require('@eslint-react/tools');
|
|
6
5
|
var shared = require('@eslint-react/shared');
|
|
7
6
|
var types = require('@typescript-eslint/types');
|
|
7
|
+
var core = require('@eslint-react/core');
|
|
8
8
|
var AST = require('@eslint-react/ast');
|
|
9
9
|
var compareVersions = require('compare-versions');
|
|
10
10
|
var tsPattern = require('ts-pattern');
|
|
@@ -32,7 +32,7 @@ var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
|
|
|
32
32
|
|
|
33
33
|
// package.json
|
|
34
34
|
var name = "eslint-plugin-react-dom";
|
|
35
|
-
var version = "1.
|
|
35
|
+
var version = "1.18.0";
|
|
36
36
|
var createRule = shared.createRuleForPlugin("dom");
|
|
37
37
|
function findAttrInCustomAttributes(name2, attributes) {
|
|
38
38
|
return tools.F.pipe(
|
|
@@ -44,7 +44,7 @@ function findAttrInCustomAttributes(name2, attributes) {
|
|
|
44
44
|
|
|
45
45
|
// src/rules/no-children-in-void-dom-elements.ts
|
|
46
46
|
var RULE_NAME = "no-children-in-void-dom-elements";
|
|
47
|
-
var voidElements =
|
|
47
|
+
var voidElements = [
|
|
48
48
|
"area",
|
|
49
49
|
"base",
|
|
50
50
|
"br",
|
|
@@ -61,7 +61,7 @@ var voidElements = /* @__PURE__ */ new Set([
|
|
|
61
61
|
"source",
|
|
62
62
|
"track",
|
|
63
63
|
"wbr"
|
|
64
|
-
]
|
|
64
|
+
];
|
|
65
65
|
var no_children_in_void_dom_elements_default = createRule({
|
|
66
66
|
meta: {
|
|
67
67
|
type: "problem",
|
|
@@ -77,14 +77,14 @@ var no_children_in_void_dom_elements_default = createRule({
|
|
|
77
77
|
create(context) {
|
|
78
78
|
return {
|
|
79
79
|
JSXElement(node) {
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
80
|
+
const elementName = JSX9__namespace.getElementName(node.openingElement);
|
|
81
|
+
if (!elementName || !voidElements.includes(elementName)) return;
|
|
82
82
|
if (node.children.length > 0) {
|
|
83
83
|
context.report({
|
|
84
84
|
messageId: "noChildrenInVoidDomElements",
|
|
85
85
|
node,
|
|
86
86
|
data: {
|
|
87
|
-
element:
|
|
87
|
+
element: elementName
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
}
|
|
@@ -97,7 +97,7 @@ var no_children_in_void_dom_elements_default = createRule({
|
|
|
97
97
|
messageId: "noChildrenInVoidDomElements",
|
|
98
98
|
node,
|
|
99
99
|
data: {
|
|
100
|
-
element:
|
|
100
|
+
element: elementName
|
|
101
101
|
}
|
|
102
102
|
});
|
|
103
103
|
}
|
|
@@ -221,8 +221,8 @@ var no_missing_button_type_default = createRule({
|
|
|
221
221
|
create(context) {
|
|
222
222
|
return {
|
|
223
223
|
JSXElement(node) {
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
224
|
+
const elementName = core.getElementRepresentName(node.openingElement, context);
|
|
225
|
+
if (elementName !== "button") return;
|
|
226
226
|
const { attributes } = node.openingElement;
|
|
227
227
|
const initialScope = context.sourceCode.getScope(node);
|
|
228
228
|
const maybeTypeAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("type");
|
|
@@ -270,8 +270,8 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
270
270
|
create(context) {
|
|
271
271
|
return {
|
|
272
272
|
JSXElement(node) {
|
|
273
|
-
const
|
|
274
|
-
if (
|
|
273
|
+
const elementName = core.getElementRepresentName(node.openingElement, context);
|
|
274
|
+
if (elementName !== "iframe") return;
|
|
275
275
|
const { attributes } = node.openingElement;
|
|
276
276
|
const initialScope = context.sourceCode.getScope(node);
|
|
277
277
|
const maybeSandboxAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
|
|
@@ -1482,8 +1482,8 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1482
1482
|
create(context) {
|
|
1483
1483
|
return {
|
|
1484
1484
|
JSXElement(node) {
|
|
1485
|
-
const
|
|
1486
|
-
if (
|
|
1485
|
+
const elementName = core.getElementRepresentName(node.openingElement, context);
|
|
1486
|
+
if (elementName !== "iframe") return;
|
|
1487
1487
|
const { attributes } = node.openingElement;
|
|
1488
1488
|
const initialScope = context.sourceCode.getScope(node);
|
|
1489
1489
|
const maybeSandboxAttribute = JSX9__namespace.findPropInAttributes(attributes, initialScope)("sandbox");
|
|
@@ -1533,8 +1533,8 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1533
1533
|
const additionalComponents = settings.additionalComponents.filter((c) => c.as === "a");
|
|
1534
1534
|
function getReportDescriptor(node) {
|
|
1535
1535
|
const name2 = JSX9__namespace.getElementName(node.openingElement);
|
|
1536
|
-
const
|
|
1537
|
-
if (
|
|
1536
|
+
const elementName = core.getElementRepresentName(node.openingElement, context);
|
|
1537
|
+
if (elementName !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return tools.O.none();
|
|
1538
1538
|
const { attributes } = node.openingElement;
|
|
1539
1539
|
const initialScope = context.sourceCode.getScope(node);
|
|
1540
1540
|
const additionalAttributes = additionalComponents.findLast((c) => c.re.test(name2))?.attributes ?? [];
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { getElementType } from '@eslint-react/core';
|
|
2
1
|
import * as JSX9 from '@eslint-react/jsx';
|
|
3
2
|
import { O, F, isString, isNullable } from '@eslint-react/tools';
|
|
4
3
|
import { createRuleForPlugin, RE_JAVASCRIPT_PROTOCOL, normalizeSettings, decodeSettings } from '@eslint-react/shared';
|
|
5
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
|
+
import { getElementRepresentName } from '@eslint-react/core';
|
|
6
6
|
import * as AST from '@eslint-react/ast';
|
|
7
7
|
import { compare } from 'compare-versions';
|
|
8
8
|
import { match, P } from 'ts-pattern';
|
|
9
9
|
|
|
10
10
|
// package.json
|
|
11
11
|
var name = "eslint-plugin-react-dom";
|
|
12
|
-
var version = "1.
|
|
12
|
+
var version = "1.18.0";
|
|
13
13
|
var createRule = createRuleForPlugin("dom");
|
|
14
14
|
function findAttrInCustomAttributes(name2, attributes) {
|
|
15
15
|
return F.pipe(
|
|
@@ -21,7 +21,7 @@ function findAttrInCustomAttributes(name2, attributes) {
|
|
|
21
21
|
|
|
22
22
|
// src/rules/no-children-in-void-dom-elements.ts
|
|
23
23
|
var RULE_NAME = "no-children-in-void-dom-elements";
|
|
24
|
-
var voidElements =
|
|
24
|
+
var voidElements = [
|
|
25
25
|
"area",
|
|
26
26
|
"base",
|
|
27
27
|
"br",
|
|
@@ -38,7 +38,7 @@ var voidElements = /* @__PURE__ */ new Set([
|
|
|
38
38
|
"source",
|
|
39
39
|
"track",
|
|
40
40
|
"wbr"
|
|
41
|
-
]
|
|
41
|
+
];
|
|
42
42
|
var no_children_in_void_dom_elements_default = createRule({
|
|
43
43
|
meta: {
|
|
44
44
|
type: "problem",
|
|
@@ -54,14 +54,14 @@ var no_children_in_void_dom_elements_default = createRule({
|
|
|
54
54
|
create(context) {
|
|
55
55
|
return {
|
|
56
56
|
JSXElement(node) {
|
|
57
|
-
const
|
|
58
|
-
if (!
|
|
57
|
+
const elementName = JSX9.getElementName(node.openingElement);
|
|
58
|
+
if (!elementName || !voidElements.includes(elementName)) return;
|
|
59
59
|
if (node.children.length > 0) {
|
|
60
60
|
context.report({
|
|
61
61
|
messageId: "noChildrenInVoidDomElements",
|
|
62
62
|
node,
|
|
63
63
|
data: {
|
|
64
|
-
element:
|
|
64
|
+
element: elementName
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
}
|
|
@@ -74,7 +74,7 @@ var no_children_in_void_dom_elements_default = createRule({
|
|
|
74
74
|
messageId: "noChildrenInVoidDomElements",
|
|
75
75
|
node,
|
|
76
76
|
data: {
|
|
77
|
-
element:
|
|
77
|
+
element: elementName
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
}
|
|
@@ -198,8 +198,8 @@ var no_missing_button_type_default = createRule({
|
|
|
198
198
|
create(context) {
|
|
199
199
|
return {
|
|
200
200
|
JSXElement(node) {
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
201
|
+
const elementName = getElementRepresentName(node.openingElement, context);
|
|
202
|
+
if (elementName !== "button") return;
|
|
203
203
|
const { attributes } = node.openingElement;
|
|
204
204
|
const initialScope = context.sourceCode.getScope(node);
|
|
205
205
|
const maybeTypeAttribute = JSX9.findPropInAttributes(attributes, initialScope)("type");
|
|
@@ -247,8 +247,8 @@ var no_missing_iframe_sandbox_default = createRule({
|
|
|
247
247
|
create(context) {
|
|
248
248
|
return {
|
|
249
249
|
JSXElement(node) {
|
|
250
|
-
const
|
|
251
|
-
if (
|
|
250
|
+
const elementName = getElementRepresentName(node.openingElement, context);
|
|
251
|
+
if (elementName !== "iframe") return;
|
|
252
252
|
const { attributes } = node.openingElement;
|
|
253
253
|
const initialScope = context.sourceCode.getScope(node);
|
|
254
254
|
const maybeSandboxAttribute = JSX9.findPropInAttributes(attributes, initialScope)("sandbox");
|
|
@@ -1459,8 +1459,8 @@ var no_unsafe_iframe_sandbox_default = createRule({
|
|
|
1459
1459
|
create(context) {
|
|
1460
1460
|
return {
|
|
1461
1461
|
JSXElement(node) {
|
|
1462
|
-
const
|
|
1463
|
-
if (
|
|
1462
|
+
const elementName = getElementRepresentName(node.openingElement, context);
|
|
1463
|
+
if (elementName !== "iframe") return;
|
|
1464
1464
|
const { attributes } = node.openingElement;
|
|
1465
1465
|
const initialScope = context.sourceCode.getScope(node);
|
|
1466
1466
|
const maybeSandboxAttribute = JSX9.findPropInAttributes(attributes, initialScope)("sandbox");
|
|
@@ -1510,8 +1510,8 @@ var no_unsafe_target_blank_default = createRule({
|
|
|
1510
1510
|
const additionalComponents = settings.additionalComponents.filter((c) => c.as === "a");
|
|
1511
1511
|
function getReportDescriptor(node) {
|
|
1512
1512
|
const name2 = JSX9.getElementName(node.openingElement);
|
|
1513
|
-
const
|
|
1514
|
-
if (
|
|
1513
|
+
const elementName = getElementRepresentName(node.openingElement, context);
|
|
1514
|
+
if (elementName !== "a" && !additionalComponents.some((c) => c.re.test(name2))) return O.none();
|
|
1515
1515
|
const { attributes } = node.openingElement;
|
|
1516
1516
|
const initialScope = context.sourceCode.getScope(node);
|
|
1517
1517
|
const additionalAttributes = additionalComponents.findLast((c) => c.re.test(name2))?.attributes ?? [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-react-dom",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "ESLint React's ESLint plugin for React DOM related rules.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"@typescript-eslint/utils": "^8.17.0",
|
|
48
48
|
"compare-versions": "^6.1.1",
|
|
49
49
|
"ts-pattern": "^5.5.0",
|
|
50
|
-
"@eslint-react/ast": "1.
|
|
51
|
-
"@eslint-react/jsx": "1.
|
|
52
|
-
"@eslint-react/core": "1.
|
|
53
|
-
"@eslint-react/
|
|
54
|
-
"@eslint-react/tools": "1.
|
|
55
|
-
"@eslint-react/
|
|
56
|
-
"@eslint-react/
|
|
50
|
+
"@eslint-react/ast": "1.18.0",
|
|
51
|
+
"@eslint-react/jsx": "1.18.0",
|
|
52
|
+
"@eslint-react/core": "1.18.0",
|
|
53
|
+
"@eslint-react/types": "1.18.0",
|
|
54
|
+
"@eslint-react/tools": "1.18.0",
|
|
55
|
+
"@eslint-react/var": "1.18.0",
|
|
56
|
+
"@eslint-react/shared": "1.18.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/react": "^19.0.1",
|