Skip to content

adaptdk/stylelint-block-as-partial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

stylelint-block-as-partial

This plugin forces all styles within a file to be contain in one top-level block. A component named .Component or #Component must be styled in a file called Component.scss or _Component.scss.

This would fail:

/* thing.scss */
.thing {}
.another-thing {}
/* thing.scss */
.another-thing {}
/* thing.scss */
.thing { background: red; }

@media screen {
  .thing { background: blue; }
}

This is correct:

/* thing.scss */
.thing {}
/* another-thing.scss */
.another-thing {}
/* thing.scss */
.thing {
  background: red;

  @media screen {
    background: blue;
  }
}

Installation and usage

npm install --dev stylelint-block-as-partial

Usage example in .stylelintrc:

{
  "plugins": [
    "stylelint-block-as-partial"
  ],
  "rules": {
    "plugin/block-as-partial": ["always", {
      "skip": [
        "./node_modules/normalize.css/normalize.css",
        "src/base/page.css",
        "src/components/table.css"
      ]
    }]
  }
}

About

Stylelint plugin for files to contain only one component as a partial

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published