@justeattakeaway/stylelint-config-pie
v3.0.1
Published
Shareable Stylelint config for use with any front-end web projects across JET.
Readme
stylelint-config-pie
PIE shareable stylelint config.
A Stylelint config used in PIE – Just Eat Takeaway’s design system.
Use it as is or as a foundation for your own config.
To see the rules that this config uses, please read the config itself.
Installation
npm install @justeattakeaway/stylelint-config-pie --save-devUsage
Rules
Currently there are 4 different sets of rules:
base- the base rules that we'd advise all projects use and extend as needed.strict- a smaller collection of optional opinionated rules.ordering- an even smaller collection of optional rules that specify the ordering of CSS Variables.style- an optional stylistic ruleset powered by@stylistic/stylelint-plugin.
In your projects
If you've installed stylelint-config-pie locally within your project, just set your stylelint config to:
{
"extends": "@justeattakeaway/stylelint-config-pie/base"
}The easiest way to do this is by adding the following section to your package.json:
"stylelint": {
"extends": "@justeattakeaway/stylelint-config-pie/base"
}You may only want to use specific rulesets such as base, strict, ordering or style. If so, simply point to the ones you'd like to use:
"stylelint": {
"extends": [
"@justeattakeaway/stylelint-config-pie/base",
"@justeattakeaway/stylelint-config-pie/strict",
"@justeattakeaway/stylelint-config-pie/ordering",
"@justeattakeaway/stylelint-config-pie/style"
]
}Note: @justeattakeaway/stylelint-config-pie includes all rules. We would strongly recommend using @justeattakeaway/stylelint-config-pie/base and going from there.
If you've globally installed stylelint-config-pie using the -g flag, then you'll need to use the absolute path to stylelint-config-pie in your config e.g.
{
"extends": "/absolute/path/to/@justeattakeaway/stylelint-config-pie/base"
}Extending the config
Simply add a "rules" key to your config, then add your overrides and additions there.
For example, to change the indentation to tabs, and turn off the number-leading-zero rule:
{
"extends": "@justeattakeaway/stylelint-config-pie/base",
"rules": {
"indentation": "tab",
"number-leading-zero": null
}
}Plugins
@justeattakeaway/pie-design-tokens
A built-in plugin that validates PIE design token usage (--dt- prefixed custom properties). Not enabled by default — opt in via your rules:
{
"extends": "@justeattakeaway/stylelint-config-pie/base",
"rules": {
"@justeattakeaway/pie-design-tokens": true
}
}Checks:
- Global tokens — Warns when global tokens are used directly instead of alias tokens.
- Deprecated tokens — Warns when a deprecated token is used and suggests a replacement.
- Invalid tokens — Warns when a
--dt-token does not exist. - Font token
calc()enforcement — Warns when--dt-font-*-sizeor--dt-font-*-line-heighttokens are used infont-sizeorline-heightwithoutcalc()wrapping.
Requires
@justeat/pie-design-tokensas a dependency. Optionally loads@justeattakeaway/pie-cssfor additional tokens (e.g. z-index).
Documentation
Configured Lints
stylelint-config-pie is a great foundation for your own config. Here is a list of the rules turned on in this config, and what they do:
Base
- alpha-value-notation
- at-rule-empty-line-before
- at-rule-name-case
- at-rule-name-space-after
- at-rule-no-vendor-prefix
- block-closing-brace-newline-after
- block-closing-brace-newline-before
- block-closing-brace-space-before
- block-opening-brace-newline-after
- block-opening-brace-space-after
- block-opening-brace-space-before
- color-function-notation
- color-hex-case
- color-hex-length
- color-no-invalid-hex
- comment-empty-line-before
- comment-whitespace-inside
- declaration-bang-space-after
- declaration-bang-space-before
- declaration-block-no-duplicate-properties
- declaration-block-no-shorthand-property-overrides
- declaration-block-semicolon-newline-after
- declaration-block-semicolon-newline-before
- declaration-block-semicolon-space-before
- declaration-block-trailing-semicolon
- declaration-colon-newline-after
- declaration-colon-space-after
- declaration-colon-space-before
- font-family-name-quotes
- font-weight-notation
- function-calc-no-unspaced-operator
- function-comma-newline-after
- function-comma-newline-before
- function-comma-space-after
- function-comma-space-before
- function-linear-gradient-no-nonstandard-direction
- function-name-case
- function-parentheses-space-inside
- function-url-quotes
- function-whitespace-after
- indentation
- keyframes-name-pattern
- length-zero-no-unit
- max-empty-lines
- media-feature-colon-space-after
- media-feature-colon-space-before
- media-feature-name-case
- media-feature-name-no-vendor-prefix
- media-feature-parentheses-space-inside
- media-feature-range-operator-space-after
- media-feature-range-operator-space-before
- media-query-list-comma-newline-before
- media-query-list-comma-space-after
- media-query-list-comma-space-before
- no-duplicate-selectors
- no-eol-whitespace
- no-missing-end-of-source-newline
- number-leading-zero
- number-max-precision
- number-no-trailing-zeros
- property-case
- property-no-unknown
- property-no-vendor-prefix
- rule-empty-line-before
- scss/at-else-closing-brace-newline-after
- scss/at-else-closing-brace-space-after
- scss/at-else-empty-line-before
- scss/at-else-if-parentheses-space-before
- scss/at-if-closing-brace-newline-after
- selector-attribute-quotes
- selector-class-pattern
- selector-combinator-space-after
- selector-combinator-space-before
- selector-descendant-combinator-no-non-space
- selector-list-comma-newline-after
- selector-list-comma-newline-before
- selector-list-comma-space-before
- selector-max-empty-lines
- selector-max-universal
- selector-no-vendor-prefix
- selector-pseudo-element-colon-notation
- selector-type-case
- string-quotes
- unit-no-unknown
- value-list-comma-newline-after
- value-list-comma-newline-before
- value-list-comma-space-after
- value-list-comma-space-before
- value-no-vendor-prefix
Strict
- color-named
- max-nesting-depth
- media-query-list-comma-newline-after
- selector-max-compound-selectors
- selector-max-id
Ordering
Style
Stylistic rules (e.g. indentation, casing) were moved out of the core Stylelint package to instead be optionally included via plugins from Stylelint v15. We use the @stylistic/stylelint-plugin to allow these stylistic rules to be optionally included in your rulesets.
Configured rules:
- @stylistic/at-rule-name-case
- @stylistic/at-rule-name-space-after
- @stylistic/at-rule-semicolon-newline-after
- @stylistic/block-closing-brace-empty-line-before
- @stylistic/block-closing-brace-newline-after
- @stylistic/block-closing-brace-newline-before
- @stylistic/block-closing-brace-space-before
- @stylistic/block-opening-brace-newline-after
- @stylistic/block-opening-brace-space-after
- @stylistic/block-opening-brace-space-before
- @stylistic/color-hex-case
- @stylistic/declaration-bang-space-after
- @stylistic/declaration-bang-space-before
- @stylistic/declaration-block-semicolon-newline-after
- @stylistic/declaration-block-semicolon-space-after
- @stylistic/declaration-block-semicolon-space-before
- @stylistic/declaration-block-trailing-semicolon
- @stylistic/declaration-colon-newline-after
- @stylistic/declaration-colon-space-after
- @stylistic/declaration-colon-space-before
- @stylistic/function-comma-newline-after
- @stylistic/function-comma-space-after
- @stylistic/function-comma-space-before
- @stylistic/function-max-empty-lines
- @stylistic/function-parentheses-newline-inside
- @stylistic/function-parentheses-space-inside
- @stylistic/function-whitespace-after
- @stylistic/indentation
- @stylistic/max-empty-lines
- @stylistic/max-line-length
- @stylistic/media-feature-colon-space-after
- @stylistic/media-feature-colon-space-before
- @stylistic/media-feature-name-case
- @stylistic/media-feature-parentheses-space-inside
- @stylistic/media-feature-range-operator-space-after
- @stylistic/media-feature-range-operator-space-before
- @stylistic/media-query-list-comma-newline-after
- @stylistic/media-query-list-comma-space-after
- @stylistic/media-query-list-comma-space-before
- @stylistic/no-empty-first-line
- @stylistic/no-eol-whitespace
- @stylistic/no-extra-semicolons
- @stylistic/no-missing-end-of-source-newline
- @stylistic/number-leading-zero
- @stylistic/number-no-trailing-zeros
- @stylistic/property-case
- @stylistic/selector-attribute-brackets-space-inside
- @stylistic/selector-attribute-operator-space-after
- @stylistic/selector-attribute-operator-space-before
- @stylistic/selector-combinator-space-after
- @stylistic/selector-combinator-space-before
- @stylistic/selector-descendant-combinator-no-non-space
- @stylistic/selector-list-comma-newline-after
- @stylistic/selector-list-comma-space-before
- @stylistic/selector-max-empty-lines
- @stylistic/selector-pseudo-class-case
- @stylistic/selector-pseudo-class-parentheses-space-inside
- @stylistic/selector-pseudo-element-case
- @stylistic/string-quotes
- @stylistic/unit-case
- @stylistic/value-list-comma-newline-after
- @stylistic/value-list-comma-space-after
- @stylistic/value-list-comma-space-before
- @stylistic/value-list-max-empty-lines
