Skip to content

Commit cf80a29

Browse files
committed
flatten config
1 parent 56b8cc9 commit cf80a29

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

docs/rules/no-restricted-html-elements.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ This rule reports to usage of resticted HTML elements.
2121

2222
```svelte
2323
<script>
24-
/* eslint svelte/no-restricted-html-elements: ["error", ["h1", "h2", "h3", "h4", "h5", "h6"]] */
24+
/* eslint svelte/no-restricted-html-elements: ["error", "h1", "h2", "h3", "h4", "h5", "h6"] */
2525
</script>
2626
2727
<!-- ✓ GOOD -->
@@ -73,7 +73,12 @@ This rule takes a list of strings, where each string is an HTML element name to
7373
{
7474
"svelte/no-restricted-html-elements": [
7575
"error",
76-
["h1", "h2", "h3", "h4", "h5", "h6"]
76+
"h1",
77+
"h2",
78+
"h3",
79+
"h4",
80+
"h5",
81+
"h6"
7782
]
7883
}
7984
```
@@ -85,7 +90,7 @@ Alternatively, the rule also accepts objects.
8590
"svelte/no-restricted-html-elements": [
8691
"error",
8792
{
88-
"elements": ["h1", "h2", "h3", "h4", "h5", "h6"],
93+
"elements": "h1", "h2", "h3", "h4", "h5", "h6",
8994
"message": "Prefer use of our custom <Heading /> component"
9095
},
9196
{

src/rules/no-restricted-html-elements.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,7 @@ export default createRule("no-restricted-html-elements", {
1111
type: "array",
1212
items: {
1313
oneOf: [
14-
{
15-
type: "array",
16-
items: {
17-
type: ["string"],
18-
},
19-
uniqueItems: true,
20-
minItems: 1,
21-
},
14+
{ type: "string" },
2215
{
2316
type: "object",
2417
properties: {
@@ -53,7 +46,7 @@ export default createRule("no-restricted-html-elements", {
5346
const message =
5447
option.message ||
5548
`Unexpected use of forbidden HTML element ${name.name}.`
56-
const elements = option.elements || option
49+
const elements = option.elements || [option]
5750
for (const element of elements) {
5851
if (element === name.name) {
5952
context.report({
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"options": [["h1", "h2", "h3", "h4", "h5", "h6"]]
2+
"options": ["h1", "h2", "h3", "h4", "h5", "h6"]
33
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"options": [["h1", "h2", "h3", "h4", "h5", "h6"]]
2+
"options": ["h1", "h2", "h3", "h4", "h5", "h6"]
33
}

0 commit comments

Comments
 (0)