-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalues.js
80 lines (73 loc) · 1.77 KB
/
values.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
/**
* @see https://drafts.csswg.org/css-values-4/#viewport-relative-lengths
*/
const VIEWPORT_PERCENTAGE_LENGTHS = '[ls]?v(?:w|h|i|d|max|min)';
const PERCENTATE_UNITS = `(?:%|${VIEWPORT_PERCENTAGE_LENGTHS})`;
module.exports = {
plugins: ['@d-zero/stylelint-rules'],
rules: {
'declaration-property-value-disallowed-list': {
'/^(?:color|background|background-color|border|border-color|outline|outline-color)$/':
[/#[0-9a-f]{3}/, /(?:rgb|hsl)a?\(.+?\)/],
content: [/^"\\[0-9a-f]{1,6}"$/i],
},
'declaration-property-value-allowed-list': {
'font-size': [
'inherit',
/^\$[a-z][a-z0-9]*-font-size(?:-[a-z0-9]+)?$/,
'1em',
/^calc\(\s*(?:(?:\d*\.)?\d+|var\(\s*--[a-z][a-z0-9_-]+\s*\))\s*\/\s*(?:(?:\d*\.)?\d+|var\(\s*--[a-z][a-z0-9_-]+\s*\))\s*\*\s*(?:1em|1rem|100vw)\s*\)$/,
/^(?:\d*\.)?\d+rem/,
/^clamp\(/,
// Custom properties
/^var\(/,
],
flex: [
/^\s*[01]\s+[01]\s.+/,
// Custom properties
/^var\(/,
],
'flex-grow': ['0', '1'],
'flex-shrink': ['0', '1'],
},
'unit-disallowed-list': [
'ex',
'ch',
'mm',
'q',
'cm',
'in',
'pt',
'pc',
'vm',
's',
'grad',
'rad',
'turn',
],
'value-keyword-case': [
'lower',
{
ignoreProperties: [/^\$font-family-/],
},
],
'@d-zero/declaration-value-type-disallowed-list': {
'/^length|percentage$/': {
ignoreProperties: ['font-size'],
patterns: [
// float
`/[0-9]*?\\.[0-9]+?${PERCENTATE_UNITS}/`,
// 1000% or larger
`/[1-9][0-9]{3,}?${PERCENTATE_UNITS}/`,
// 200% - 999%
`/[2-9][0-9][0-9]${PERCENTATE_UNITS}/`,
// 101% - 199%
`/1[0-9][1-9]${PERCENTATE_UNITS}/`,
`/1[1-9][0-9]${PERCENTATE_UNITS}/`,
// 1% - 99%
`/[1-9][0-9]?${PERCENTATE_UNITS}/`,
],
},
},
},
};