-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathhexadecimal-escape.ts
64 lines (62 loc) · 1.61 KB
/
hexadecimal-escape.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
import { SnapshotRuleTester } from "eslint-snapshot-rule-tester"
import rule from "../../../lib/rules/hexadecimal-escape"
const tester = new SnapshotRuleTester({
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
})
tester.run("hexadecimal-escape", rule as any, {
valid: [
String.raw`/a \x0a \cM \0 \u0100 \u{100}/u`,
String.raw`/\7/`,
{
code: String.raw`/a \x0a \cM \0 \u0100 \u{100}/u`,
options: ["always"],
},
{
code: String.raw`/\7/`,
options: ["always"],
},
{
code: String.raw`/a \u000a \u{a} \cM \0 \u0100 \u{100}/u`,
options: ["never"],
},
{
code: String.raw`/\7/`,
options: ["never"],
},
String.raw`/\cA \cB \cM/`,
{
code: String.raw`/[\q{\x0a}]/v`,
options: ["always"],
},
{
code: String.raw`/[\q{\u000a}]/v`,
options: ["never"],
},
],
invalid: [
String.raw`/\u000a \u{00000a}/u`,
{
code: String.raw`/\u000a \u{00000a}/u`,
options: ["always"],
},
{
code: String.raw`/\x0f \xff/u`,
options: ["never"],
},
{
code: String.raw`/\x0a \x0b \x41/u`,
options: ["never"],
},
{
code: String.raw`/[\q{\u000a \u{00000a}}]/v`,
options: ["always"],
},
{
code: String.raw`/[\q{\x0f \xff}]/v`,
options: ["never"],
},
],
})