stylelint-config-twbs-bootstrap

repository·main·Indexed 41 days ago

https://github.com/twbs/stylelint-config-twbs-bootstrap

An opinionated Stylelint configuration version 16.1.0 used by Bootstrap projects to maintain consistent CSS and SCSS code quality. It provides a unified configuration that includes property ordering via stylelint-config-recess-order and stylistic rules via @stylistic/stylelint-config, with specific overrides for .scss files extending stylelint-config-standard-scss.

Tokens
733
Snippets
3
Records
5
Agent score
50%

What's inside stylelint-config-twbs-bootstrap

  1. Use stylelint-config-twbs-bootstrap in your project

    main

    To use this configuration, extend it in your Stylelint configuration file (e.g., .stylelintrc.json). The config provides a single unified configuration that covers both CSS and SCSS; it automatically applies SCSS-specific rules to files with the .scss extension.

    {
      "extends": "stylelint-config-twbs-bootstrap"
    }
  2. Extend stylelint-config-twbs-bootstrap in your configuration

    main

    To use the Bootstrap-specific Stylelint rules, add stylelint-config-twbs-bootstrap to the extends array in your .stylelintrc (or equivalent) configuration file. This configuration provides a base set of rules optimized for Bootstrap development, including standard linting, property ordering via stylelint-config-recess-order, and stylistic rules via @stylistic/stylelint-config.

    {
      "extends": ["stylelint-config-twbs-bootstrap"]
    }
  3. Reference the SCSS overrides in stylelint-config-twbs-bootstrap

    main

    When linting .scss files, the configuration automatically applies an override that extends stylelint-config-standard-scss and stylelint-config-recess-order.

    Specific SCSS rules include:

    • scss/at-mixin-argumentless-call-parentheses: Set to always.
    • scss/dimension-no-non-numeric-values: Set to true.
    • scss/dollar-variable-colon-space-after: Set to at-least-one-space.
    • scss/selector-no-redundant-nesting-selector: Set to true.
    • scss/at-function-named-arguments: Set to never.

    Note: scss/no-global-function-names is disabled (null) to maintain compatibility with node-sass which does not support the @use syntax.

  4. Reference the core rules in stylelint-config-twbs-bootstrap

    main

    The core configuration applies several specific constraints to CSS. Key rules include:

    • declaration-no-important: Set to true (disallows the use of !important).
    • selector-max-id: Set to 0 (disallows ID selectors).
    • selector-no-qualifying-type: Set to true (disallows qualifying selectors with a type).
    • font-weight-notation: Enforces numeric notation while ignoring relative values.
    • color-named: Set to never (disallows named colors).
    • selector-max-class: Limits classes to a maximum of 4.
    • selector-max-combinators: Limits combinators to a maximum of 4.
    • selector-max-compound-selectors: Limits compound selectors to a maximum of 4.
    • selector-max-type: Limits type selectors to a maximum of 2.
    • selector-max-attribute: Limits attribute selectors to a maximum of 2.
    • selector-max-universal: Limits universal selectors to a maximum of 1.

    It also includes various @stylistic/ rules for whitespace, indentation, and formatting (e.g., @stylistic/max-empty-lines: 2).