Socket
Socket
Sign inDemoInstall

stylelint-scss

Package Overview
Dependencies
112
Maintainers
3
Versions
101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stylelint-scss

A collection of SCSS-specific rules for Stylelint


Version published
Weekly downloads
2.1M
decreased by-20.6%
Maintainers
3
Created
Weekly downloads
 

Package description

What is stylelint-scss?

The stylelint-scss npm package is a plugin for stylelint that provides linting rules specific to SCSS syntax. It helps enforce consistent conventions and avoid errors in your SCSS files.

What are stylelint-scss's main functionalities?

Linting SCSS-specific syntax

This feature allows you to lint SCSS-specific syntax such as @rules, $variables, and nesting. The code sample shows how to enable rules in a stylelint configuration file to disallow unknown @rules, enforce a naming pattern for $variables, and prevent redundant nesting selectors.

"rules": {
  "scss/at-rule-no-unknown": true,
  "scss/dollar-variable-pattern": "^foo-",
  "scss/selector-no-redundant-nesting-selector": true
}

Enforcing best practices

This feature helps enforce best practices in SCSS by preventing common mistakes. The code sample demonstrates enabling rules that ensure placeholders are used with @extend, discourage the use of leading underscores in partial names on @import, and prevent duplicate $variable declarations.

"rules": {
  "scss/at-extend-no-missing-placeholder": true,
  "scss/at-import-no-partial-leading-underscore": true,
  "scss/no-duplicate-dollar-variables": true
}

Customizable rules for SCSS

This feature provides customizable rules tailored for SCSS, allowing you to enforce specific stylistic decisions or prevent certain patterns. The code sample shows rules that enforce no spaces around operators, disallow nested properties, and ensure that dimensions only contain numeric values.

"rules": {
  "scss/operator-no-unspaced": true,
  "scss/declaration-nested-properties": "never",
  "scss/dimension-no-non-numeric-values": true
}

Other packages similar to stylelint-scss

Readme

Source

stylelint-scss

npm version Build Status Coverage Status contributions welcome Downloads per month

A collection of SCSS-specific linting rules for Stylelint (in a form of a plugin).

Purpose

Stylelint by itself supports SCSS syntax very well (as well as other preprocessors' syntaxes). Moreover, it introduces some specific rules that can be used to lint SCSS, e.g. to limit nesting, control the way @-rules are written. Yet Stylelint is in general focused on standard CSS.

stylelint-scss introduces rules specific to SCSS syntax. That said, the rules from this plugin can be used with other syntaxes, like Less or some PostCSS syntaxes. That's why the rules' names are not tied to SCSS only (at-function-pattern instead of scss-function-pattern).

The plugin follows Stylelint's guidelines (about rule names, testing and so on).

Installation and usage

This plugin is used in the stylelint-config-standard-scss shared config. We recommend using that shared config, rather than installing this plugin directly.

However, the plugin can still be used in you're crafting a config from the ground up. First, install stylelint-scss (and stylelint, if you haven't done so yet) via npm:

npm install stylelint stylelint-scss

Create the .stylelintrc.json config file (or open the existing one), add stylelint-scss to the plugins array and the rules you need to the rules list. All rules from stylelint-scss need to be namespaced with scss.

{
  "plugins": ["stylelint-scss"],
  "rules": {
    // recommended rules
    "at-rule-no-unknown": null,
    "scss/at-rule-no-unknown": true,
    // ...
    // any other rules you'd want to change e.g.
    "scss/dollar-variable-pattern": "^foo",
    "scss/selector-no-redundant-nesting-selector": true
  }
}

Please refer to Stylelint docs for detailed info on using this linter.

List of rules

Here are stylelint-scss' rules, grouped by the thing they apply to (just like in Stylelint).

Please also see the example configs for special cases.

@-each

  • at-each-key-value-single-line: This is a rule that checks for situations where users have done a loop using map-keys or map.keys and grabbed the value for that key inside of the loop.

@-else

@-extend

@-function

@-if

@-import

@-mixin

@-rule

@-use

$-variable

%-placeholder

//-comment

Block

Comment

Declaration

Dimension

Function

Map

Media feature

Operator

Partial

Property

Selector

Load

General / Sheet

Deprecated

These rules are deprecated — we won't fix bugs nor add options, and we will remove them in the next major release. We recommend you use a pretty printer (like Prettier) alongside Stylelint rather than these rules.

Help out

The work on the plugin's rules is still in progress, so if you feel like it, you're welcome to help out with any of these (the plugin follows Stylelint guidelines so most of this is based on its docs):

  • Create, enhance, and debug rules (see Stylelint's guide to "Working on rules").
  • Improve documentation.
  • Chime in on any open issue or pull request.
  • Open new issues about your ideas on new rules, or for how to improve the existing ones, and pull requests to show us how your idea works.
  • Add new tests to absolutely anything.
  • Work on improving performance of rules.
  • Contribute to Stylelint
  • Spread the word.

We communicate via issues and pull requests.

There is also StackOverflow, which would be the preferred QA forum.

Contributors

Thanks goes to these wonderful people:

kristerkaridryomarambleraptorXhmikosRybiquitousEugeno
kristerkaridryomarambleraptorXhmikosRybiquitousEugeno
pamelalozano16joseph118stofniksykaysonwusrawlins
pamelalozano16joseph118stofniksykaysonwusrawlins
pipopotamasujhae-deOriRntwbricardogobbosouzajeddy3
pipopotamasujhae-deOriRntwbricardogobbosouzajeddy3
evilebottnawikevindewthibaudcolaschimuraivseventerxboy2012
evilebottnawikevindewthibaudcolaschimuraivseventerxboy2012
chalkygames123FloEdelmannbjankordAndyOGoqmhcfreezy-sk
chalkygames123FloEdelmannbjankordAndyOGoqmhcfreezy-sk
YodaDaCodawlewis-formativekershAM-77YozhikMsajadtorkamani
YodaDaCodawlewis-formativekershAM-77YozhikMsajadtorkamani
paulgv01taylopnlydvmanovotnykeegan-lillostormwarning
paulgv01taylopnlydvmanovotnykeegan-lillostormwarning
jantimonguoyunheG-RathEvanHahnlithiumlrondiego-codes
jantimonguoyunheG-RathEvanHahnlithiumlrondiego-codes
DeimosCalme1709SterlingVix
DeimosCalme1709SterlingVix

Important documents

Keywords

FAQs

Last updated on 05 Mar 2024

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc