-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathprefer-quantifier.ts
43 lines (41 loc) · 1.02 KB
/
prefer-quantifier.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
import { SnapshotRuleTester } from "eslint-snapshot-rule-tester"
import rule from "../../../lib/rules/prefer-quantifier"
const tester = new SnapshotRuleTester({
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
})
tester.run("prefer-quantifier", rule as any, {
valid: [
`/regexp/`,
`/\\d_\\d/`,
`/Google/`,
`/2000/`,
`/<!--/`,
`/\`\`\`/`,
`/---/`,
`/a.{1,3}?.{2,4}c/`,
`/a.{1,3}.{2,4}?c/`,
],
invalid: [
`/\\d\\d/`,
`/ /`,
`/ /v`,
String.raw`/\p{ASCII}\p{ASCII}/u`,
String.raw`/\p{Basic_Emoji}\p{Basic_Emoji}/v`,
`/(\\d\\d\\d*)/`,
String.raw`/\d\d\d\d-\d\d-\d\d/`,
String.raw`/aaa..\s\s\S\S\p{ASCII}\p{ASCII}/u`,
`/aaaa(aaa)/u`,
`/(b)?aaaa(b)?/u`,
`
const s = "\\\\d\\\\d"
new RegExp(s)
`,
`
const s = "\\\\d"+"\\\\d"
new RegExp(s)
`,
],
})