/
no-numeric-separators.js
72 lines (69 loc) · 1.81 KB
/
no-numeric-separators.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
/**
* @author Toru Nagashima <https://github.com/mysticatea>
* See LICENSE file in root directory for full license.
*/
"use strict"
const RuleTester = require("../../tester")
const rule = require("../../../lib/rules/no-numeric-separators.js")
if (!RuleTester.isSupported(2021)) {
//eslint-disable-next-line no-console
console.log("Skip the tests of no-numeric-separators.")
return
}
new RuleTester().run("no-numeric-separators", rule, {
valid: [
"123456",
"-123",
"123.456",
"123.0",
"NaN",
"123e-1",
"0x11",
"0b11",
"0o11",
"Infinity",
"123456n",
],
invalid: [
{
code: "123_456",
output: "123456",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "5_000",
output: "5000",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "1_234_56",
output: "123456",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "5.00_00",
output: "5.0000",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "0b11_01",
output: "0b1101",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "5e1_000",
output: "5e1000",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "0xBE_EF",
output: "0xBEEF",
errors: ["ES2021 numeric separators are forbidden."],
},
{
code: "123_456n",
output: "123456n",
errors: ["ES2021 numeric separators are forbidden."],
},
],
})