npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@detra-lab/stylelint-config

v1.1.0

Published

Modular and opinionated Stylelint configuration with support for CSS, PostCSS, SASS language, and CSS in JS solutions.

Downloads

610

Readme

Stylelint Config

NPM Version NPM Downloads CI Status

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.

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

Available configurations

  1. Install the config:

    pnpm add -D @detra-lab/stylelint-config stylelint
  2. Create a .stylelintrc.json file in the root of your project, and extend the following configuration from it:

    {
      "extends": "@detra-lab/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:

    pnpm run check:css
  1. Install the config:

    pnpm add -D @detra-lab/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": [
        "@detra-lab/stylelint-config",
        "@detra-lab/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:

    pnpm run check:css
  1. Install the config:

    pnpm add -D @detra-lab/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": [
        "@detra-lab/stylelint-config",
        "@detra-lab/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:

    pnpm 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": "@detra-lab/stylelint-config",
  "rules": [
    // Customize your rules
    "selector-id-pattern": null,
    "selector-class-pattern": null
  ]
}

Integration with 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": "explicit"
    },
    "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

Code of Conduct

Help us keep the project open and inclusive. Please read and follow our Code of Conduct.

Contributing

Read our contributing guide to learn about our development process, how to propose bug fixes and improvements, and how to build and test your changes.

Acknowledgments

Thanks to the following projects for their contributions:

License

Apache License 2.0