-
Notifications
You must be signed in to change notification settings - Fork 0
/
.stylelintrc.js
271 lines (270 loc) · 7.68 KB
/
.stylelintrc.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
const varPattern = '^cvi-([a-z][a-z0-9]*)(-{1,2}[a-z0-9]+)*$';
module.exports = {
extends: ['stylelint-config-standard-scss', 'stylelint-config-prettier-scss'],
rules: {
'value-keyword-case': [
'lower',
{
camelCaseSvgKeywords: true,
ignoreProperties: ['font-family'],
severity: 'warning',
},
],
'color-hex-length': 'long',
'no-descending-specificity': true,
'color-hex-alpha': 'never',
'declaration-block-no-duplicate-custom-properties': true,
'declaration-property-unit-allowed-list': [
{ 'line-height': [] },
// This relies on a Stylelint feature be released soon (see https://github.com/stylelint/stylelint/pull/6570)
// {
// message: (propertyName, _units) => {
// switch (propertyName) {
// case 'line-height':
// return 'Prefer unitless numbers for line-height values';
// }
// },
// },
],
'at-rule-allowed-list': ['use', 'include', 'mixin', 'at-root', 'each'],
'at-rule-disallowed-list': [
'debug',
{
message:
"Please don't forget to remove @debug at-rule from the final code. If necessary use @warn instead",
},
],
'at-rule-disallowed-list': [
'media',
{
message:
'Please use cvi-breakpoint-down and cvi-breakpoint-up mixins instead of custom @media rules. Add an ignore comment if needed',
},
],
'selector-max-type': [
0,
{
message:
'Avoid tag (type) selectors. Add a class to template and utilise it in Sass code instead',
},
],
'selector-max-attribute': [
0,
{
message:
'Avoid attribute selectors. Add a class to template and utilise it in Sass code instead',
},
],
'declaration-block-no-redundant-longhand-properties': null,
'declaration-no-important': true,
'selector-max-compound-selectors': 2,
'max-nesting-depth': 3,
'number-max-precision': [
0,
{
ignoreUnits: [
'', // ignore unitless values, like line-height or opacity
's',
],
},
],
'selector-max-id': 0,
'selector-max-specificity': '0,3,0',
'color-no-hex': [
true,
{
message:
'Only use colors from _colors.scss file. If "%s" color is not there, add it as a new variable. Also consider using a similar color which is already set',
},
],
'alpha-value-notation': null,
'selector-type-no-unknown': true,
'selector-no-qualifying-type': [
true,
{
ignore: ['attribute'],
},
],
'scss/double-slash-comment-empty-line-before': null,
'scss/dollar-variable-empty-line-before': null,
'custom-property-empty-line-before': null,
'selector-pseudo-class-disallowed-list': [['/^nth-child/']],
'selector-combinator-disallowed-list': [
['>'],
{
message:
'Avoid child combinator as it does not allow to specify which elements apply the rule to. Add a class to chidlren in template and utilise it in Sass code instead',
},
],
'declaration-property-max-values': [
{
'/^margin/': 1,
'/^padding/': 2,
'/^border-radius/': 1,
},
],
'declaration-property-value-allowed-list': [
{
margin: ['auto', '0'],
'/color$/': [
'/^var\\(/',
'currentColor',
'/^color\\./',
'transparent',
'inherit',
'/^rgba\\(/',
'/^get-color\\(/',
'/^\\$color-/',
],
'box-shadow': ['/^var\\(--cvi-shadow-/', 'none'],
'/border-([a-z]+-[a-z]+-)*radius/': [
'/^var\\(/',
'50%',
'51%',
'100%',
'/^var\\(--cvi-radius-/',
'/^map\\.get\\(\\$cvi-radii/',
],
'font-size': [
'/^var\\(/',
'/^get-font-size\\(/',
'inherit',
'/^typography\\./',
],
'font-weight': ['/^get-font-weight\\(/'],
'line-height': ['/^var\\(/', '/^get-line-height\\(/', '0'],
'z-index': ['/^get-z-index\\(/', '/^var\\(/', '-1'],
},
],
'property-disallowed-list': [
['background', 'flex'],
{
message:
'Shorthand properties like "%s" are not obvious and hard to read. Use separate longhand properties instead, eg "background-color" instead of "background"',
},
],
'unit-disallowed-list': [
['rem', 'em'],
{
message:
'Use px instead of rem and em. Both are hard to read, and px-to-rem conversion should happen only on production',
},
],
'comment-word-disallowed-list': [
['/^TODO:/'],
{
severity: 'warning',
message:
'A todo comment was found. Consider resolving the issue in future',
},
],
'selector-class-pattern': [
'^((#\\{\\$base\\}|u-|s-|no-|has-|is-)[a-z]+|hidden)',
{
resolveNestedSelectors: true,
message:
'Please use `#{$base}__`/`#{$base}--` or other allowed prefixes when naming classes',
},
],
'scss/at-mixin-pattern': [
'^(cvi-).+',
{
severity: 'error',
message:
'Please use cvi- prefix when naming component or utility mixins',
},
],
'custom-property-pattern': [
'^([a-z][a-z0-9]*)(-{1,2}[a-z0-9]+)*$|^comment$',
{ message: 'Expected custom property name to be kebab-case' },
],
'scss/dollar-variable-pattern': [
'^([a-z][a-z0-9]*)(-{1,2}[a-z0-9]+)*$',
{ message: 'Expected variable name to be kebab-case' },
],
},
overrides: [
{
files: ['libs/styles/src/lib/scss/settings/variables/*.scss'],
rules: {
'custom-property-pattern': [
varPattern,
{
message:
'Expected custom property name to start from cvi- prefix and be kebab-case',
},
],
'scss/dollar-variable-pattern': [
varPattern,
{
message:
'Expected variable name to start from cvi- prefix and be kebab-case',
},
],
},
},
{
files: ['libs/styles/src/lib/scss/tools/*.scss'],
rules: {
'at-rule-allowed-list': [
'function',
'if',
'else',
'warn',
'return',
'use',
],
},
},
{
files: ['libs/styles/src/lib/scss/generic/*.scss'],
rules: {
'at-rule-disallowed-list': [],
'declaration-property-value-allowed-list': null,
'at-rule-allowed-list': ['use', 'include', 'each', 'media'],
'selector-max-type': null,
'selector-max-attribute': null,
},
},
{
files: ['libs/styles/src/lib/scss/settings/_mixins.scss'],
rules: {
'at-rule-disallowed-list': [],
'at-rule-allowed-list': ['mixin', 'use', 'include', 'each', 'media'],
},
},
{
files: [
'libs/styles/src/lib/scss/settings/_utility-classes.scss',
'libs/styles/src/lib/scss/_apply.scss',
],
rules: {
'selector-class-pattern': [
'^(cvi-[a-z]+|hidden)',
{
resolveNestedSelectors: true,
message: 'Please use cvi- prefix when naming utility classes',
},
],
},
},
{
files: ['libs/styles/src/lib/scss/settings/variables/_colors.scss'],
rules: {
'color-no-hex': null,
},
},
{
files: ['libs/styles/src/lib/scss/main.scss'],
rules: {
'at-rule-allowed-list': ['import'],
},
},
{
files: ['libs/styles/src/lib/scss/generic/_animations.scss'],
rules: {
'at-rule-allowed-list': ['keyframes'],
},
},
],
};