-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathstrict.ts
58 lines (51 loc) · 1.38 KB
/
strict.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
import { SnapshotRuleTester } from "eslint-snapshot-rule-tester"
import rule from "../../../lib/rules/strict"
const tester = new SnapshotRuleTester({
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
})
tester.run("strict", rule as any, {
valid: [
`/regexp/`,
String.raw`/\{\}\]/`,
String.raw`/[-\w-]/`,
String.raw`/[a-b-\w]/`,
String.raw`/\0/`,
String.raw`/()\1/`,
String.raw`/(?<foo>)\k<foo>/`,
String.raw`/\p{L}/u`,
String.raw`/ \( \) \[ \] \{ \} \| \* \+ \? \^ \$ \\ \/ \./`,
String.raw`/[\( \) \[ \] \{ \} \| \* \+ \? \^ \$ \\ \/ \. \-]/`,
"/\\u000f/",
"/\\x000f/",
String.raw`/[A--B]/v`,
],
invalid: [
// source characters
String.raw`/]/`,
String.raw`/{/`,
String.raw`/}/`,
// invalid or incomplete escape sequences
String.raw`/\u{42}/`,
"/\\u000;/",
"/\\x4/",
"/\\c;/",
"/\\p/",
"/\\p{H}/",
"/\\012/",
"/\\12/",
// incomplete backreference
"/\\k<foo/",
"/\\k<foo>/",
// useless escape
"/\\; \\_ \\a \\- \\'/",
"/[\\; \\_ \\a \\']/",
// invalid ranges
String.raw`/[\w-a]/`,
String.raw`/[a-\w]/`,
// quantified assertions
String.raw`/(?!a)+/`,
],
})