0.4.0 • Published 12 months ago

@salesforce-ux/sds-stylelint-config v0.4.0

Weekly downloads
25
License
SEE LICENSE IN RE...
Repository
-
Last release
12 months ago

@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 stylelint

Use npm to install the SDS stylelint configuration:

npm install --save-dev @salesforce-ux/sds-stylelint-config

Usage

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"]
  }
}
1.0.1

12 months ago

1.0.0

1 year ago

0.5.0

2 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.3.0-alpha.0

3 years ago

0.3.0-alpha.1

3 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.5-alpha.0

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.0

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago