Skip to content

Commit

Permalink
Fixed solid/no-innerhtml tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwilsonvu committed Jul 10, 2022
1 parent 8b2536b commit 8cbf184
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 27 deletions.
14 changes: 5 additions & 9 deletions docs/no-innerhtml.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,39 +31,38 @@ Options shown here are the defaults.
These snippets cause lint errors, and some can be auto-fixed.

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

/* eslint solid/no-innerhtml: ["error", { "allowStatic": false }] */
let el = <div innerHTML={"<p>Hello</p><p>world!</p>"} />;

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

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

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

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

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

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

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

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

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

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

```
Expand Down
28 changes: 10 additions & 18 deletions test/rules/no-innerhtml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,32 @@ export const cases = run("no-innerhtml", rule, {
valid: [
`let el = <div prop1 prop2={2}>Hello world!</div>`,
`let el = <Box prop1 prop2={2}>Hello world!</Box>`,
{
code: `let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>" />`,
options: [{ allowStatic: true }],
},
{
code: `let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />`,
options: [{ allowStatic: true }],
},
{
code: `let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>"></div>`,
options: [{ allowStatic: true }],
},
`let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>" />`,
`let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />`,
`let el = <div prop1 prop2={2} innerHTML="<p>Hello</p><p>world!</p>"></div>`,
],
invalid: [
{
code: `let el = <div prop1 prop2={2} innerHTML="<p>Hello</><p>world!</p>" />`,
options: [{ allowStatic: false }],
errors: [{ messageId: "dangerous" }],
},
{
code: `let el = <div innerHTML={"<p>Hello</p><p>world!</p>"} />`,
options: [{ allowStatic: false }],
errors: [{ messageId: "dangerous" }],
},
{
code: `let el = <div prop1 prop2={2} innerHTML={"<p>Hello</p>" + "<p>world!</p>"} />`,
options: [{ allowStatic: false }],
errors: [{ messageId: "dangerous" }],
},
{
code: `let el = <div prop1 prop2={2} innerHTML={Math.random()} />`,
options: [{ allowStatic: true }],
errors: [{ messageId: "dangerous" }],
},
{
code: `let el = <div prop1 prop2={2} innerHTML="Hello world!" />`,
options: [{ allowStatic: true }],
errors: [
{
messageId: "notHtml",
Expand All @@ -56,7 +52,6 @@ export const cases = run("no-innerhtml", rule, {
</div>
);
`,
options: [{ allowStatic: true }],
errors: [{ messageId: "conflict", type: T.JSXElement }],
},
{
Expand All @@ -68,7 +63,6 @@ export const cases = run("no-innerhtml", rule, {
</div>
);
`,
options: [{ allowStatic: true }],
errors: [{ messageId: "conflict", type: T.JSXElement }],
},
{
Expand All @@ -79,7 +73,6 @@ export const cases = run("no-innerhtml", rule, {
</div>
);
`,
options: [{ allowStatic: true }],
errors: [{ messageId: "conflict", type: T.JSXElement }],
},
{
Expand All @@ -90,7 +83,6 @@ export const cases = run("no-innerhtml", rule, {
</div>
);
`,
options: [{ allowStatic: true }],
errors: [{ messageId: "conflict", type: T.JSXElement }],
},
{
Expand Down

0 comments on commit 8cbf184

Please sign in to comment.