forked from stylelint/stylelint
/
index.js
118 lines (111 loc) · 2.24 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
117
118
'use strict';
const { messages, ruleName } = require('..');
testRule({
ruleName,
config: [true],
accept: [
{
code: 'a { color: pink; }',
},
{
code: 'a { color: #000; }',
},
{
code: 'a { something: #000, #fff, #ababab; }',
},
{
code: 'a { color: #0000ffcc; }',
description: 'eight digits',
},
{
code: 'a { color:#00fc; }',
description: 'four digits',
},
{
code: 'a { padding: 000; }',
},
{
code: 'a::before { content: "#ababa"; }',
},
{
code: 'a { border-#$side: 0; }',
description: 'ignore sass-like interpolation',
},
{
code: 'a { box-sizing: #$type-box; }',
description: 'ignore sass-like interpolation',
},
{
code: "a { background-image: svg-load('x.svg', fill=url(#a)); }",
description: 'svg-load url with fill',
},
{
code: 'a { background-image: url(#a); }',
description: 'url standalone hash',
},
{
code: 'a { background-image: url(x.svg#a); }',
description: 'url with hash',
},
{
code:
'@font-face {\n' +
'font-family: dashicons;\n' +
'src: url(data:application/font-woff;charset=utf-8;base64, ABCDEF==) format("woff"),\n' +
'url(../fonts/dashicons.ttf) format("truetype"),\n' +
'url(../fonts/dashicons.svg#dashicons) format("svg");\n' +
'font-weight: normal;\n' +
'font-style: normal;\n' +
'}',
},
{
code: 'a { color: #colors[somecolor]; }',
description: 'Less map usage',
},
],
reject: [
{
code: 'a { color: #ababa; }',
message: messages.rejected('#ababa'),
line: 1,
column: 12,
},
{
code: 'a { something: #00, #fff, #ababab; }',
message: messages.rejected('#00'),
line: 1,
column: 16,
},
{
code: 'a { something: #000, #fff1az, #ababab; }',
message: messages.rejected('#fff1az'),
line: 1,
column: 22,
},
{
code: 'a { something:#000,#fff,#12345aa; }',
message: messages.rejected('#12345aa'),
line: 1,
column: 25,
},
],
});
testRule({
skip: true,
ruleName,
config: [true],
syntax: 'css-in-js',
accept: [
{
code: 'export default <h1 style={{ color: "#ffff" }}>Test</h1>;',
},
],
reject: [
{
code: 'export default <h1 style={{ color: "#fffff" }}>Test</h1>;',
message: messages.rejected('#fffff'),
line: 1,
column: 36,
},
],
});