-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathno-useless-lazy.ts
43 lines (39 loc) · 988 Bytes
/
no-useless-lazy.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/no-useless-lazy"
const tester = new SnapshotRuleTester({
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
})
tester.run("no-useless-lazy", rule as any, {
valid: [
`/a*?/`,
`/a+?/`,
`/a{4,}?/`,
`/a{2,4}?/`,
`/a{2,2}/`,
`/a{3}/`,
`/a+?b*/`,
`/[\\s\\S]+?bar/`,
`/a??a?/`,
],
invalid: [
`/a{1}?/`,
`/a{1}?/v`,
`/a{4}?/`,
`/a{2,2}?/`,
String.raw`const s = "\\d{1}?"
new RegExp(s)`,
String.raw`const s = "\\d"+"{1}?"
new RegExp(s)`,
`/a+?b+/`,
String.raw`/[\q{aa|ab}]+?b+/v`,
`/a*?b+/`,
`/(?:a|cd)+?(?:b+|zzz)/`,
String.raw`/\b\w+?(?=\W)/`,
String.raw`/\b\w+?(?!\w)/`,
String.raw`/\b\w+?\b/`,
String.raw`/\b\w+?$/`,
],
})