12.1.0 • Published 1 year ago

@giotramu/stylelint-config v12.1.0

Weekly downloads
52
License
MIT
Repository
github
Last release
1 year ago

Stylelint Config

Modular and opinionated Stylelint configuration with support for CSS or PostCSS syntax, SASS language, and some CSS in JS solutions, like Styled Components or Emotion.js template literals.

NPM Version NPM Downloads Build Status

The following Stylelint configurations do not include code formatting rules, which are therefore delegated to Prettier. Please, use the @giotramu/prettier to handle this type of need.

Available Configurations

  1. Install the config:

    # NPM
    npm add --save-dev @giotramu/stylelint-config stylelint
    
    # PNPM
    pnpm add --save-dev @giotramu/stylelint-config stylelint
    
    # Yarn
    yarn add --dev @giotramu/stylelint-config stylelint
  2. Create a .stylelintrc.json file in the root of your project, and extend the following configuration from it:

    {
      "extends": "@giotramu/stylelint-config"
    }
  3. Use the ESLint CLI to check supported files. Drop this line into your package.json under the scripts property:

    {
      "scripts": [
    +   "check:css": "stylelint ./styles/*.css"
      ]
    }
  4. Lint your code with Stylelint:

    npm run check:css
  1. Install the config:

    # NPM
    npm add --save-dev @giotramu/stylelint-config stylelint stylelint-scss postcss-scss
    
    # PNPM
    pnpm add --save-dev @giotramu/stylelint-config stylelint stylelint-scss postcss-scss
    
    # Yarn
    yarn add --dev @giotramu/stylelint-config stylelint stylelint-scss postcss-scss
  2. Create a .stylelintrc.json file in the root of your project, and extend the following configuration from it:

    {
      "extends": [
        "@giotramu/stylelint-config",
        "@giotramu/stylelint-config/sass"
      ]
    }
  3. Use the ESLint CLI to check supported files. Drop this line into your package.json under the scripts property:

    {
      "scripts": [
    +   "check:css": "stylelint ./styles/*.scss"
      ]
    }
  4. Lint your code with Stylelint:

    npm run check:css
  1. Install the config:

    # NPM
    npm add --save-dev @giotramu/stylelint-config stylelint postcss-styled-syntax
    
    # PNPM
    pnpm add --save-dev @giotramu/stylelint-config stylelint postcss-styled-syntax
    
    # Yarn
    yarn add --dev @giotramu/stylelint-config stylelint postcss-styled-syntax
  2. Create a .stylelintrc.json file in the root of your project, and extend the following configuration from it:

    {
      "extends": [
        "@giotramu/stylelint-config",
        "@giotramu/stylelint-config/styled"
      ]
    }
  3. Use the Stylelint CLI to check supported files. Drop this line into your package.json under the scripts property:

    {
      "scripts": [
    +   "check:css": "stylelint ./styles/*.{js,jsx,ts,tsx}"
      ]
    }
  4. Lint your code with Stylelint:

    npm run check:css

CSS Properties Order

Stylelint Config sorts the CSS property declarations by grouping them in the following order:

  1. Positioning
  2. Box Model
  3. Typography
  4. Visual
  5. Animation
  6. Misc

Extending the Configuration

You can extend the configuration and override some rules. Add the rules property inside the .stylelintrc.json file and then choose what to turn on or off.

{
  "extends": "@giotramu/stylelint-config",
  "rules": [
    // Customize your rules
    "selector-id-pattern": null,
    "selector-class-pattern": null
  ]
}

Integrating Stylelint into the IDEs/Editors

  1. Install the Stylelint Plugin

  2. Add the following code to your .vscode/settings.json:

    "css.validate": false,
    "scss.validate": false,
    "editor.codeActionsOnSave": {
      "source.fixAll.stylelint": true
    },
    "stylelint.validate": ["css"] // Add the type of file you want to validate (e.g. ["css", "scss", "typescript", "typescriptreact"])
  3. (Optional) Highlight the CSS-in-JS syntax with the Styled Components Plugin

Thanks

License

MIT License

12.0.3

1 year ago

12.0.2

1 year ago

12.1.0

1 year ago

12.0.0

1 year ago

12.0.1

1 year ago

11.1.1

2 years ago

11.0.0-rc.0

2 years ago

10.1.0-rc.1

2 years ago

10.1.0-rc.2

2 years ago

10.1.0-rc.3

2 years ago

11.0.0

2 years ago

11.1.0

2 years ago

10.0.0

2 years ago

9.1.0

2 years ago

9.0.0-rc1

2 years ago

9.0.0

2 years ago

8.0.0

3 years ago

7.0.2

3 years ago

7.0.0

3 years ago

7.0.1

3 years ago

6.0.0

3 years ago

5.1.3

3 years ago

5.1.2

3 years ago

5.1.1

3 years ago

5.1.0

4 years ago

5.0.0

4 years ago

4.0.0

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.3.0

4 years ago

2.2.3

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.2.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.0

4 years ago

2.0.0-3

4 years ago

2.0.0-1

4 years ago

2.0.0-0

4 years ago

1.1.0

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago