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

@elecdeer/stylelint-rscss

v1.0.4

Published

Validate CSS (and SCSS, Less, SugarSS) to RSCSS conventions

Downloads

192

Readme

stylelint-rscss

Validate CSS (and SCSS, Less, SugarSS) to RSCSS conventions

This repository is a maintenance fork of rstacruz/stylelint-rscss. It has been rewritten in TypeScript and is compatible with stylelint v16.

stylelint-rscss is a plugin for stylelint to validate your code against RSCSS conventions. It supports SCSS (Sass), SugarSS and Less, as supported by stylelint.

As a stylelint plugin, it can be used with stylelint's hundreds of rules or other stylelint configs to validate other good CSS practices as well.

Status

Quickstart guide

Install: Install stylelint and stylelint-rscss to your project.

npm install --save-dev stylelint @elecdeer/stylelint-rscss

Configure: Create a .stylelintrc in your project. Use the stylelint-rscss/config configuration, which has defaults for strict RSCSS conventions.

// .stylelintrc
{
  "extends": [
    "@elecdeer/stylelint-rscss/config"
  ]
}

Add a script: Add an npm script to your package.json.

// package.json
{
  "scripts": {
    "lint:css": "stylelint path/to/css/**/*"
  }
}

Run it!

npm run lint:css

Recommendations

These steps are not required, but are highly recommended:

Text editor support

You need to install stylelint globally (npm install -g stylelint) for text editor support.

npm install -g stylelint

After that, here are the plugins I'd recommend:

Also see stylelint's complimentary tools documentation.

Examples

Here are some valid examples according to RSCSS rules.

.component-name { }
  // ✓ Components should be two or more words, separated by dashes.
.component-name > .element { }
  // ✓ Elements should be one word. Use `>` to denote markup structure.
.component-name > .element.-foo { }
  // ✓ Variant classes begin with a dash (`-`).
.component-name.-variant { }
  // ✓ Components can have variants.
._helper { }
  // ✓ Helpers start with an underscore (`_`).

Some cases not allowed:

.component-name .element { }
  // ✗ Use `>` to denote markup structure.
.component-name.variant { }
  // ✗ Variants must begin with a dash.
.componentname { }
  // ✗ Components should be two or more words.
.component-name.other-component { }
  // ✗ Only one component name is allowed.
.component-name > .-foo { }
.-foo { }
  // ✗ Variants should be attached to components or elements.

Also OK:

h2 { }
  // ✓ Bare elements can be styled.
.component-name > h2 { }
  // ✓ Bare elements can be styled as elements.
.component-name > a:hover[aria-hidden="false"] { }
  // ✓ Pseudo-classes and attributes are OK.
.component-name:hover > .element { }
  // ✓ They're ok for components too.

See Rules for more examples.

Rules and customization

See Rules for a detailed lint of rules and examples of how to customize stylelint-rscss.

Thanks

stylelint-rscss © 2016+, Rico Sta. Cruz. Released under the MIT License. Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz