-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathno-obscure-range.ts
55 lines (48 loc) · 1.33 KB
/
no-obscure-range.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
import { SnapshotRuleTester } from "eslint-snapshot-rule-tester"
import rule from "../../../lib/rules/no-obscure-range"
const tester = new SnapshotRuleTester({
languageOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
})
tester.run("no-obscure-range", rule as any, {
valid: [
"/[\\d\\0-\\x1f\\cA-\\cZ\\2-\\5\\012-\\123\\x10-\\uffff a-z a-f]/",
{
code: "/[а-я А-Я]/",
options: [{ allowed: ["alphanumeric", "а-я", "А-Я"] }],
},
{
code: "/[а-я А-Я]/",
settings: {
regexp: {
allowedCharacterRanges: ["alphanumeric", "а-я", "А-Я"],
},
},
},
"/[[0-9]--[6-8]]/v",
],
invalid: [
{
// rule options override settings
code: "/[а-я А-Я]/",
options: [{ allowed: "alphanumeric" }],
settings: {
regexp: {
allowedCharacterRanges: ["alphanumeric", "а-я", "А-Я"],
},
},
},
"/[\\1-\\x13]/",
"/[\\x20-\\113]/",
"/[\\n-\\r]/",
"/[\\cA-Z]/",
"/[A-z]/",
"/[0-A]/",
"/[Z-a]/",
"/[A-\\x43]/",
"/[*+-/]/",
String.raw`/[[ -\/]--+]/v`,
],
})