Latest Socket ResearchMalicious Chrome Extension Performs Hidden Affiliate Hijacking.Details
Socket
Book a DemoInstallSign in
Socket

stylelint-rscss

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylelint-rscss

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

latest
Source
npmnpm
Version
0.4.0
Version published
Weekly downloads
2.8K
-25.35%
Maintainers
1
Weekly downloads
 
Created
Source

stylelint-rscss

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

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 stylelint-rscss

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

// .stylelintrc
{
  "extends": [
    "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

Keywords

css

FAQs

Package last updated on 03 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts