stylelint-config-material is a shareable stylelint config for Material Components Web (MDC Web).
npm install --save-dev stylelint-config-material
Extend this config within your stylelint configuration object, and add your rules if needed.
{
"extends": "stylelint-config-material",
"ignoreFiles": [
"node_modules/**/*",
"dist/**/*"
],
"rules": {
"string-quotes": "single"
}
}
extends: stylelint-config-material
ignoreFiles:
- node_modules/**/*
- dist/**/*
rules:
string-quotes: single
Below are example rules for using custom component prefix. Replace "mdc" with your own abbreviation.
{
"rules": {
"custom-media-pattern": "^mdc?-.+",
"custom-property-pattern": "^mdc?-.+",
"selector-class-pattern": ["^mdc?-.+", {
"resolveNestedSelectors": true
}],
"selector-id-pattern": "^mdc?-.+",
"plugin/selector-bem-pattern": {
"componentSelectors": "^\\.mdc?-{componentName}(?:__[a-z]+(?:-[a-z]+)*)*(?:--[a-z]+(?:-[a-z]+)*)*(?:\\[.+\\])*$"
},
"scss/dollar-variable-pattern": ["^_?mdc-.+", {
"ignore": "local"
}],
"scss/at-function-pattern": "^mdc-.+",
"scss/at-mixin-pattern": "^mdc-.+"
}
}
rules:
custom-media-pattern: ^mdc?-.+
custom-property-pattern: ^mdc?-.+
selector-class-pattern:
- ^mdc?-.+
- resolveNestedSelectors: true
selector-id-pattern: ^mdc?-.+
plugin/selector-bem-pattern:
componentSelectors: ^\.mdc?-{componentName}(?:__[a-z]+(?:-[a-z]+)*)*(?:--[a-z]+(?:-[a-z]+)*)*(?:\[.+\])*$
scss/dollar-variable-pattern:
- ^_?mdc-.+
- ignore: local
scss/at-function-pattern: ^mdc-.+
scss/at-mixin-pattern: ^mdc-.+