UNPKG

2.06 kBJavaScriptView Raw
1const prettierOptions = require('./.prettierrc')
2
3function suitSelector(componentName) {
4 const ns = '[a-z]{2,3}'
5 const WORD = '[a-z0-9][a-zA-Z0-9]*'
6 const descendant = `(?:-${WORD})?`
7 const modifier = `(?:--${WORD}(?:\\.${ns}${componentName}${descendant}--${WORD})*)?`
8 const attribute = '(?:\\[.+\\])?'
9 const state = `(?:\\.(is|has)-${WORD})*`
10 const body = descendant + modifier + attribute + state
11 return new RegExp(`^\\.${ns}${componentName}\\b${body}$`)
12}
13
14module.exports = {
15 plugins: [
16 'stylelint-selector-bem-pattern',
17 'stylelint-scss',
18 'stylelint-prettier'
19 ],
20 rules: {
21 'prettier/prettier': [true, prettierOptions],
22 'plugin/selector-bem-pattern': {
23 componentName: /^[a-zA-Z]+$/,
24 componentSelectors: suitSelector
25 },
26 'scss/at-rule-no-unknown': true,
27 'at-rule-no-unknown': null,
28 'block-no-empty': true,
29 'color-no-invalid-hex': true,
30 'comment-no-empty': true,
31 'declaration-block-no-duplicate-properties': [
32 true,
33 {
34 ignore: ['consecutive-duplicates-with-different-values'] // useful for fallback properties
35 }
36 ],
37 'declaration-block-no-shorthand-property-overrides': true,
38 'font-family-no-duplicate-names': true,
39 'font-family-no-missing-generic-family-keyword': true,
40 // 'function-calc-no-invalid': true,
41 'function-calc-no-unspaced-operator': true,
42 'function-linear-gradient-no-nonstandard-direction': true,
43 'keyframe-declaration-no-important': true,
44 'media-feature-name-no-unknown': true,
45 'no-descending-specificity': null, // we must activate this sometime
46 'no-duplicate-at-import-rules': true,
47 'no-duplicate-selectors': true,
48 'no-empty-source': true,
49 'no-invalid-double-slash-comments': true,
50 'number-leading-zero': 'always',
51 'property-no-unknown': true,
52 'selector-pseudo-class-no-unknown': true,
53 'selector-pseudo-element-no-unknown': true,
54 'selector-type-no-unknown': true,
55 'string-quotes': 'single',
56 'string-no-newline': true,
57 'unit-no-unknown': true
58 }
59}