Skip to content

Commit 8cbf184

Browse files
committed
Fixed solid/no-innerhtml tests
1 parent 8b2536b commit 8cbf184

File tree

2 files changed

+15
-27
lines changed

2 files changed

+15
-27
lines changed

docs/no-innerhtml.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,38 @@ Options shown here are the defaults.
3131
These snippets cause lint errors, and some can be auto-fixed.
3232

3333
```js
34+
/* eslint solid/no-innerhtml: ["error", { "allowStatic": false }] */
3435
let el = <div prop1 prop2={2} innerHTML="<p>Hello</><p>world!</p>" />;
3536

37+
/* eslint solid/no-innerhtml: ["error", { "allowStatic": false }] */
38+
let el = <div innerHTML={"<p>Hello</p><p>world!</p>"} />;
39+
40+
/* eslint solid/no-innerhtml: ["error", { "allowStatic": false }] */
3641
let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />;
3742

38-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
3943
let el = <div prop1 prop2={2} innerHTML={Math.random()} />;
4044

41-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
4245
let el = <div prop1 prop2={2} innerHTML="Hello world!" />;
4346

44-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
4547
let el = (
4648
<div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>">
4749
<p>Child element content</p>
4850
</div>
4951
);
5052

51-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
5253
let el = (
5354
<div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>">
5455
<p>Child element content 1</p>
5556
<p>Child element context 2</p>
5657
</div>
5758
);
5859

59-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
6060
let el = (
6161
<div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>">
6262
{"Child text content"}
6363
</div>
6464
);
6565

66-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
6766
let el = (
6867
<div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>">
6968
{identifier}
@@ -99,13 +98,10 @@ let el = (
9998
</Box>
10099
);
101100

102-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
103101
let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>" />;
104102

105-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
106103
let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />;
107104

108-
/* eslint solid/no-innerhtml: ["error", { "allowStatic": true }] */
109105
let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>"></div>;
110106

111107
```

test/rules/no-innerhtml.test.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,32 @@ export const cases = run("no-innerhtml", rule, {
66
valid: [
77
`let el = <div prop1 prop2={2}>Hello world!</div>`,
88
`let el = <Box prop1 prop2={2}>Hello world!</Box>`,
9-
{
10-
code: `let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>" />`,
11-
options: [{ allowStatic: true }],
12-
},
13-
{
14-
code: `let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />`,
15-
options: [{ allowStatic: true }],
16-
},
17-
{
18-
code: `let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>"></div>`,
19-
options: [{ allowStatic: true }],
20-
},
9+
`let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>" />`,
10+
`let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />`,
11+
`let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>"></div>`,
2112
],
2213
invalid: [
2314
{
2415
code: `let el = <div prop1 prop2={2} innerHTML="<p>Hello</><p>world!</p>" />`,
16+
options: [{ allowStatic: false }],
17+
errors: [{ messageId: "dangerous" }],
18+
},
19+
{
20+
code: `let el = <div innerHTML={"<p>Hello</p><p>world!</p>"} />`,
21+
options: [{ allowStatic: false }],
2522
errors: [{ messageId: "dangerous" }],
2623
},
2724
{
2825
code: `let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />`,
26+
options: [{ allowStatic: false }],
2927
errors: [{ messageId: "dangerous" }],
3028
},
3129
{
3230
code: `let el = <div prop1 prop2={2} innerHTML={Math.random()} />`,
33-
options: [{ allowStatic: true }],
3431
errors: [{ messageId: "dangerous" }],
3532
},
3633
{
3734
code: `let el = <div prop1 prop2={2} innerHTML="Hello world!" />`,
38-
options: [{ allowStatic: true }],
3935
errors: [
4036
{
4137
messageId: "notHtml",
@@ -56,7 +52,6 @@ export const cases = run("no-innerhtml", rule, {
5652
</div>
5753
);
5854
`,
59-
options: [{ allowStatic: true }],
6055
errors: [{ messageId: "conflict", type: T.JSXElement }],
6156
},
6257
{
@@ -68,7 +63,6 @@ export const cases = run("no-innerhtml", rule, {
6863
</div>
6964
);
7065
`,
71-
options: [{ allowStatic: true }],
7266
errors: [{ messageId: "conflict", type: T.JSXElement }],
7367
},
7468
{
@@ -79,7 +73,6 @@ export const cases = run("no-innerhtml", rule, {
7973
</div>
8074
);
8175
`,
82-
options: [{ allowStatic: true }],
8376
errors: [{ messageId: "conflict", type: T.JSXElement }],
8477
},
8578
{
@@ -90,7 +83,6 @@ export const cases = run("no-innerhtml", rule, {
9083
</div>
9184
);
9285
`,
93-
options: [{ allowStatic: true }],
9486
errors: [{ messageId: "conflict", type: T.JSXElement }],
9587
},
9688
{

0 commit comments

Comments
 (0)