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

@visionappscz/stylelint-config

v4.0.0

Published

VisionApps' shareable config for stylelint

Downloads

714

Readme

@visionappscz/stylelint-config

npm version Node version Stylelint version Build status Downloads per month

VisionApps' collection of shareable configs for Stylelint:

  • extends stylelint-config-standard with rules to encourage low specificity and avoid nesting,
  • includes additional configs for checking order, SCSS and CSS Modules.

Installation

Install Stylelint and this config:

$ npm install --save-dev stylelint @visionappscz/stylelint-config

Basic Usage

Apply the config in your Stylelint config:

{
  "extends": "@visionappscz/stylelint-config"
}

👉 To see the rules that this config uses, please read the main config itself.

Optional: Checking Properties Order

To further extend control over coding style of your stylesheets, you can also check for properties order:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@visionappscz/stylelint-config/order"
  ]
}

The order config enforces a consistent order of content in your declaration blocks:

  1. Sass variables,
  2. CSS custom properties,
  3. Sass @extend,
  4. single-line Sass @include,
  5. declarations,
  6. nested rules.

For better flexibility, block at-rules (like @media, @supports, and also Sass @if, @each, etc.) can be placed anywhere in the declaration block.

Furthermore, properties in the declarations must be ordered by following categories:

  1. all properties,
  2. content,
  3. position,
  4. appearance,
  5. box model,
  6. typography,
  7. decorations,
  8. effects and transforms,
  9. interactions,
  10. transitions and animations.

👉 To see the order of individual properties this config prescribes, please read the order config itself.

👉 order config is entirely independent on the main config and thus can be listed anywhere in the extends section of your config. However, that's not the case with our other extending configs.

Usage with SCSS

To lint SCSS files (i.e. *.scss, not *.sass), add the scss config that extends stylelint-config-standard-scss, fixes its incompatibilities with our main config, and overrides some rules to better work with complex stylesheets:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@visionappscz/stylelint-config/scss"
  ]
}

⚠️ Please mind the order of extended configurations, scss config must come after the main config.

👉 To see the rules that this config uses, please read the scss config itself.

Usage with CSS Modules

To lint CSS files in project that leverages CSS Modules, drop in the cssModules config that fixes key incompatibilities of CSS Modules syntax with the main config:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@visionappscz/stylelint-config/cssModules"
  ]
}

Or along with SCSS:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@visionappscz/stylelint-config/scss",
    "@visionappscz/stylelint-config/cssModules"
  ]
}

⚠️ Please mind the order of extended configurations, cssModules must come after the main config, or after the scss config, if present.

⚠️ Only essential features of CSS Modules are recognized by this config. Namely, just camelCase notation for class names and :global pseudo selectors are covered. All other features of CSS Modules (like composes, :local, @value, etc.) are considered non-essential as they can be implemented with Sass (which we encourage) and thus are not recognized by this config.

👉 To see the rules that this config uses, please read the cssModules config itself.

ℹ️ There is a popular stylelint-config-css-modules config that recognizes all features of CSS Modules.

Stylistic Rules

Stylistic rules (like indentation etc.) were dropped in Stylelint v16. If you need to enforce them, you can use @stylistic/stylelint-config:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@stylistic/stylelint-config"
  ]
}

Or, if you feel brave enough and don't need granular configuration of the stylistic rules, you can use Prettier.

Full Example

Example of all configs combined:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@visionappscz/stylelint-config/order",
    "@visionappscz/stylelint-config/scss",
    "@visionappscz/stylelint-config/cssModules",
    "@stylistic/stylelint-config"
  ]
}

FAQ

With Stylistic

If using the @stylistic plugin, just override the @stylistic/indentation rule in your Stylelint config:

{
  "extends": [
    "@visionappscz/stylelint-config",
    "@stylistic/stylelint-config"
  ],
  "rules": {
    "@stylistic/indentation": 2
  }
}

👉 See the @stylistic/stylelint-config documentation for more options.

With Prettier

If using Prettier, you can configure the indentation in your Prettier config:

{
  "tabWidth": 2
}

Or in your .editorconfig:

[*]
indent_size = 2

👉 See Prettier documentation for more options.