-
Notifications
You must be signed in to change notification settings - Fork 1
/
stylelint.config.mjs
106 lines (93 loc) · 3.54 KB
/
stylelint.config.mjs
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
import { dedent } from 'ts-dedent';
/** @type {import('stylelint').Config} */
export default {
extends: 'stylelint-config-standard-scss',
ignoreFiles: [
'node_modules/**/*',
'dist/**/*',
],
// Override `stylelint-config-standard-scss` rules
rules: {
// Modules
'scss/load-partial-extension': 'always', // Must include the file extension
// Formatting
'comment-empty-line-before': null,
'comment-whitespace-inside': null,
'scss/comment-no-empty': null,
'scss/double-slash-comment-empty-line-before': null,
'scss/double-slash-comment-whitespace-inside': null,
'custom-property-empty-line-before': null,
'rule-empty-line-before': null,
'scss/operator-no-newline-before': null,
'declaration-empty-line-before': null,
'at-rule-empty-line-before': null,
'value-keyword-case': [
'lower',
{ camelCaseSvgKeywords: true },
],
'font-family-name-quotes': 'always-unless-keyword',
'number-max-precision': null,
'color-hex-length': null,
'scss/operator-no-unspaced': null,
'scss/dollar-variable-empty-line-before': null,
// Selectors
'selector-class-pattern': [
'^([a-z][a-z0-9]*)((-|--|_|__)[a-z0-9]+)*$',
{ message: (selector) => `Expected class selector "${selector}" to be in BEM format` },
],
'selector-id-pattern': [
'^([a-z][a-z0-9]*)((-|--|_|__)[a-z0-9]+)*$',
{ message: (selector) => `Expected id selector "${selector}" to be in BEM format` },
],
'selector-no-vendor-prefix': [
true,
{ ignoreSelectors: ['::-webkit-input-placeholder', '/-moz-.*/'] },
],
// Disallow `&` selector concatenation to be forward-compatible with native CSS
'selector-disallowed-list': [
['/&__/', '/&--/'],
{
message: (selector) => dedent`
Do not use '&'-concatenation in selectors, this conflicts with native CSS. Found: ${selector}.
`,
},
],
// Properties
//'declaration-no-important': true, // No !important
'declaration-property-value-disallowed-list': [
{
// Disallow auto/scroll. This requires a tabindex="0" for accessibility, which should be handled through the
// `useScroller()` hook instead.
'/^overflow(-x|-y)?/': ['auto', 'scroll'],
},
{
message: (selector, value) => {
if (selector.match(/overflow/)) {
return `Do not declare '${selector}: ${value}' directly, use the useScroller() hook instead.`;
}
return `The rule '${selector}: ${value}' is disallowed, see stylelint config for more information.`;
},
},
],
// Expressions
// Workaround for `round()`, re-enable once https://github.com/stylelint-scss/stylelint-scss/pull/1097 lands
'scss/no-global-function-names': null,
// CSS extensions (e.g. CSS modules, or future CSS)
//'property-no-unknown': [true, { ignoreProperties: [] }],
//'scss/at-rule-no-unknown': [true, { ignoreAtRules: [] }],
'selector-pseudo-class-no-unknown': [true, { ignorePseudoClasses: ['global', 'local'] }],
'selector-pseudo-element-no-unknown': [true, { ignorePseudoElements: ['details-content'] }],
'no-descending-specificity': null, // Does not work properly with a lot of nesting (see docs page also)
},
overrides: [
{
files: ['*.scss', '**/*.scss'],
// Rules to apply only to Sass and not to CSS
rules: {
'at-rule-disallowed-list': [
'import', // @import in Sass is deprecated (in vanilla CSS this is still fine)
],
}
}
]
};