-
Notifications
You must be signed in to change notification settings - Fork 92
/
index.js
88 lines (83 loc) · 1.81 KB
/
index.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
"use strict";
const { messages, ruleName } = require("..");
// Testing single value
testRule({
ruleName,
config: ["random"],
customSyntax: "postcss-scss",
accept: [
{
code: `
@use "sass:math"
.a { margin-left: math.round(100.5); }
`,
description: "Math library function, allowed."
}
],
reject: [
{
code: `
@use "sass:math"
.a { margin-left: math.random(100); }
`,
line: 3,
column: 18,
message: messages.rejected("random"),
description: "Math library function, not allowed."
}
]
});
// Testing an array
testRule({
ruleName,
config: [["random", /test/]],
customSyntax: "postcss-scss",
accept: [
{
code: `
@use "sass:math"
.a { margin-left: math.round(100.5); }
`,
description: "Math library function, allowed."
},
{
code: `
@function funcName($num){@return $num;}
.a { margin-left: funcName(3); }
`,
description: "Declared function is allowed."
}
],
reject: [
{
code: `
@use "sass:math"
.a { margin-left: math.random(100); }
`,
line: 3,
column: 16,
message: messages.rejected("random"),
description: "Math library function, not allowed."
},
{
code: `
@function test($num){@return $num;}
.a { margin-left: test(3); }
`,
line: 3,
column: 14,
message: messages.rejected("test"),
description: "Declared function is not allowed (regex)."
},
{
code: `
@function random($num){@return $num;}
.a { margin-left: random(5); }
`,
line: 3,
column: 14,
message: messages.rejected("random"),
description: "Declared function is not allowed."
}
]
});