forked from solidjs-community/eslint-plugin-solid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-react-specific-props.test.ts
69 lines (68 loc) · 3.04 KB
/
no-react-specific-props.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { run } from "../ruleTester";
import rule from "../../src/rules/no-react-specific-props";
export const cases = run("no-react-specific-props", rule, {
valid: [
`let el = <div>Hello world!</div>;`,
`let el = <div class="greeting">Hello world!</div>;`,
`let el = <div class={"greeting"}>Hello world!</div>;`,
`let el = <div many other attributes class="greeting">Hello world!</div>;`,
`let el = <label for="id">Hello world!</label>;`,
`let el = <label for="id">Hello world!</label>`,
`let el = <label for={"id"}>Hello world!</label>`,
`let el = <label many other attributes for="id">Hello world!</label>`,
`let el = <PascalComponent class="greeting" for="id" />`,
`let el = <PascalComponent key={item.id} />`,
],
invalid: [
{
code: `let el = <div className="greeting">Hello world!</div>`,
errors: [{ messageId: "prefer", data: { from: "className", to: "class" } }],
output: `let el = <div class="greeting">Hello world!</div>`,
},
{
code: `let el = <div className={"greeting"}>Hello world!</div>`,
errors: [{ messageId: "prefer", data: { from: "className", to: "class" } }],
output: `let el = <div class={"greeting"}>Hello world!</div>`,
},
{
code: `let el = <div className="greeting" />`,
errors: [{ messageId: "prefer", data: { from: "className", to: "class" } }],
output: `let el = <div class="greeting" />`,
},
{
code: `let el = <div many other attributes className="greeting">Hello world!</div>`,
errors: [{ messageId: "prefer", data: { from: "className", to: "class" } }],
output: `let el = <div many other attributes class="greeting">Hello world!</div>`,
},
{
code: `let el = <PascalComponent className="greeting">Hello world!</PascalComponent>`,
errors: [{ messageId: "prefer", data: { from: "className", to: "class" } }],
output: `let el = <PascalComponent class="greeting">Hello world!</PascalComponent>`,
},
{
code: `let el = <label htmlFor="id">Hello world!</label>`,
errors: [{ messageId: "prefer", data: { from: "htmlFor", to: "for" } }],
output: `let el = <label for="id">Hello world!</label>`,
},
{
code: `let el = <label htmlFor={"id"}>Hello world!</label>`,
errors: [{ messageId: "prefer", data: { from: "htmlFor", to: "for" } }],
output: `let el = <label for={"id"}>Hello world!</label>`,
},
{
code: `let el = <label many other attributes htmlFor="id">Hello world!</label>`,
errors: [{ messageId: "prefer", data: { from: "htmlFor", to: "for" } }],
output: `let el = <label many other attributes for="id">Hello world!</label>`,
},
{
code: `let el = <PascalComponent htmlFor="id">Hello world!</PascalComponent>`,
errors: [{ messageId: "prefer", data: { from: "htmlFor", to: "for" } }],
output: `let el = <PascalComponent for="id">Hello world!</PascalComponent>`,
},
{
code: `let el = <div key={item.id} />`,
errors: [{ messageId: "noUselessKey" }],
output: `let el = <div />`,
},
],
});