-
-
Notifications
You must be signed in to change notification settings - Fork 929
/
index.js
116 lines (107 loc) · 2.01 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
'use strict';
const { messages, ruleName } = require('..');
testRule({
ruleName,
config: true,
accept: [
{
code: 'a { transform: translate(1px); }',
},
{
code: 'a { transform: TRANSLATE(1px); }',
},
{
code: 'a { transform: --custom-function(1px); }',
},
{
code: 'a { transform: scale(0.5) translate(-100%, -100%); }',
},
{
code: 'a { animation-timeline: scroll(); }',
},
{
code: 'a { background: -webkit-gradient(linear, 0 50%, 0 100%, from(white), color-stop(0.5, yellow), to(red)); }',
},
{
code: 'a { height: calc(10px*(5*(10 - 5))); }',
},
{
code: 'a { transform: color.adjust(1px); transform: rgb(color.adjust(1px)); }',
description: 'ignore scss namespaced functions',
},
],
reject: [
{
code: 'a { transform: unknown(4); }',
message: messages.rejected('unknown'),
line: 1,
column: 16,
endLine: 1,
endColumn: 23,
},
{
code: 'a { transform: UNKNOWN(4); }',
message: messages.rejected('UNKNOWN'),
line: 1,
column: 16,
endLine: 1,
endColumn: 23,
},
{
code: 'a { width: calc(10% * unknown(1)); }',
message: messages.rejected('unknown'),
line: 1,
column: 23,
endLine: 1,
endColumn: 30,
},
],
});
testRule({
ruleName,
config: true,
customSyntax: 'postcss-scss',
accept: [
{
code: 'a { $list: (list) }',
},
{
code: 'a { --primary-color: #{theme(1px)}; }',
},
],
});
testRule({
ruleName,
config: [true, { ignoreFunctions: ['theme', '/^foo-/', /^bar$/i] }],
accept: [
{
code: 'a { transform: translate(1px); }',
},
{
code: 'a { transform: theme(1px); }',
},
{
code: 'a { transform: foo-func(1px); }',
},
{
code: 'a { transform: bar(1px); }',
},
{
code: 'a { transform: BAR(1px); }',
},
],
reject: [
{
code: 'a { transform: unknown(1px); }',
message: messages.rejected('unknown'),
line: 1,
column: 16,
},
{
code: 'a { transform: theme-custom(1px); }',
message: messages.rejected('theme-custom'),
line: 1,
column: 16,
},
],
});