@salesforce-ux/sds-stylelint-config v0.4.0
@salesforce-ux/sds-stylelint-config
About
The Salesforce Design System shareable config for stylelint.
Use it "as is" or as a foundation for your own config.
Installation
Pre-requisite
Install stylelint from npm:
npm install --save-dev stylelintUse npm to install the SDS stylelint configuration:
npm install --save-dev @salesforce-ux/sds-stylelint-configUsage
Create .stylelintrc.json configuration file in the root of your project:
{
"extends": "@salesforce-ux/sds-stylelint-config"
}Run stylelint, for example, all the CSS files in your project:
npx stylelint "**/*.css"Plugins
sds-stylelint-plugin/namespace-pattern
Custom plugin for SDS to lint custom property declaration for namespace and scope syntax.
Usage
In your stylelint config, add the plugin sds-stylelint-plugin/namespace-pattern to your rules array. Lint rules check for the namespace provided, it can either be a string or an array of namespaces; additionally the plugin checks for a scope of -g-, -s-, or -c-. See SDS Styling Hooks for more information.
module.exports = {
extends: ['@salesforce-ux/sds-stylelint-config'],
rules: {
'sds-stylelint-plugin/namespace-pattern': [true, { namespace: 'sds', property: true, value: true }],
},
};Options
namespace
Lints for the namespace(s) defined in your subsystem.
array|string: ["array", "of", "namespaces"]|"namespace"
property
Lints property declarations.
boolean: true|false
value
Lints value declarations within a var() function. Additionally this will lint all fallbacks declaraed.
boolean: true|false
sds-stylelint-plugin/component-pattern
Custom plugin for SDS to lint that the custom property declaration is authored in the correct component folder.
Usage
In your stylelint config, add the plugin sds-stylelint-plugin/component-pattern to your rules array. Lint rules check a custom property is owned by the component it is being authored within.
module.exports = {
extends: ['@salesforce-ux/sds-stylelint-config'],
rules: {
'sds-stylelint-plugin/component-pattern': true,
},
};Ignoring rules
If you need to disable any of these rules for development purposes, please follow the guidance provided by stylelint. https://stylelint.io/user-guide/ignore-code.
Extending rules for your sub-system
Simply add a rules key to your config, then add your overrides and additions there.
For example, to change the indentation to tabs, turn off the number-leading-zero rule, change the property-no-unknown rule to use its ignoreAtRules option and add the unit-whitelist rule:
See all stylelint rules here
{
"extends": "@salesforce-ux/sds-stylelint-config",
"rules": {
"indentation": "tab",
"number-leading-zero": null,
"property-no-unknown": [ true, {
"ignoreProperties": [
"composes"
]
}],
"unit-whitelist": ["em", "rem", "s"]
}
}2 years ago
2 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago