-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefer-spelling.test.js
75 lines (72 loc) · 2.61 KB
/
prefer-spelling.test.js
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
70
71
72
73
74
75
const { RuleTester } = require("eslint");
const preferSpellingRule = require("./prefer-spelling");
const ruleTester = new RuleTester({
parserOptions: { ecmaVersion: 2015 },
});
ruleTester.run("prefer-spelling", preferSpellingRule, {
valid: [
{
code: "const text = 'colour';",
options: [{ words: { color: "colour" } }],
},
{
code: "const text = 'canceled';",
options: [{ words: { cancelled: "canceled" } }],
},
{
code: "const isCancelled = true;",
options: [{ words: { canceled: "cancelled" } }],
},
{
code: "function checkIfCancelled() {}",
options: [{ words: { canceled: "cancelled" } }],
},
{
code: "const checkIfCancelled = function() {}",
options: [{ words: { canceled: "cancelled" } }],
},
{
code: "const checkIfCancelled = () => {}",
options: [{ words: { canceled: "cancelled" } }],
},
],
invalid: [
{
code: "const text = 'color';",
output: "const text = 'colour';",
options: [{ words: { color: "colour" } }],
errors: [{ message: "Use 'colour' instead of 'color'." }],
},
{
code: "const text = 'cancelled';",
output: "const text = 'canceled';",
options: [{ words: { cancelled: "canceled" } }],
errors: [{ message: "Use 'canceled' instead of 'cancelled'." }],
},
{
code: "const isCanceled = true;",
output: "const isCancelled = true;",
options: [{ words: { canceled: "cancelled" } }],
errors: [{ message: "Use 'cancelled' instead of 'canceled'." }],
},
{
code: "function checkIfCanceled() {}",
output: "function checkIfCancelled() {}",
options: [{ words: { canceled: "cancelled" } }],
errors: [{ message: "Use 'cancelled' instead of 'canceled'." }],
},
{
code: "const checkIfCanceled = function() {}",
output: "const checkIfCancelled = function() {}",
options: [{ words: { canceled: "cancelled" } }],
errors: [{ message: "Use 'cancelled' instead of 'canceled'." }],
},
{
code: "const checkIfCanceled = () => {}",
output: "const checkIfCancelled = () => {}",
options: [{ words: { canceled: "cancelled" } }],
errors: [{ message: "Use 'cancelled' instead of 'canceled'." }],
},
],
});
console.log("All tests passed!");