Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
stylelint-scss
Advanced tools
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.
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
}
sass-lint is a Node-only Sass linter for both sass and scss syntax. It offers similar functionality to stylelint-scss but is not a plugin for stylelint and has its own set of rules and configuration.
postcss-scss is a SCSS parser for PostCSS, which allows you to lint SCSS within PostCSS's ecosystem. It can be used with stylelint but does not provide SCSS-specific linting rules on its own.
scss-lint is a Ruby gem that provides linting for SCSS files. It is similar to stylelint-scss in that it focuses on SCSS syntax but requires Ruby and is not integrated with the stylelint ecosystem.
A collection of SCSS-specific linting rules for Stylelint (in a form of a plugin).
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).
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.
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.
@
-eachat-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.@
-elseat-else-closing-brace-newline-after
: Require or disallow a newline after the closing brace of @else
statements (Autofixable).at-else-closing-brace-space-after
: Require a single space or disallow whitespace after the closing brace of @else
statements (Autofixable).at-else-empty-line-before
: Require an empty line or disallow empty lines before @
-else (Autofixable).at-else-if-parentheses-space-before
: Require or disallow a space before @else if
parentheses (Autofixable).@
-extendat-extend-no-missing-placeholder
: Disallow at-extends (@extend
) with missing placeholders.@
-functionat-function-named-arguments
: Require named parameters in SCSS function call rule.at-function-parentheses-space-before
: Require or disallow a space before @function
parentheses (Autofixable).at-function-pattern
: Specify a pattern for Sass/SCSS-like function names.@
-ifat-if-closing-brace-newline-after
: Require or disallow a newline after the closing brace of @if
statements (Autofixable).at-if-closing-brace-space-after
: Require a single space or disallow whitespace after the closing brace of @if
statements (Autofixable).at-if-no-null
: Disallow null
in @if
statements.@
-importat-import-partial-extension-allowed-list
: Specify a list of allowed file extensions for partial names in @import
commands.at-import-partial-extension-disallowed-list
: Specify a list of disallowed file extensions for partial names in @import
commands.@
-mixinat-mixin-argumentless-call-parentheses
: Require or disallow parentheses in argumentless @mixin
calls (Autofixable).at-mixin-named-arguments
: Require named parameters in at-mixin call rule.at-mixin-no-risky-nesting-selector
: Disallow risky nesting selectors within a mixin.at-mixin-parentheses-space-before
: Require or disallow a space before @mixin
parentheses (Autofixable).at-mixin-pattern
: Specify a pattern for Sass/SCSS-like mixin names.@
-ruleat-rule-conditional-no-parentheses
: Disallow parentheses in conditional @ rules (if, elsif, while) (Autofixable).at-rule-no-unknown
: Disallow unknown at-rules. Should be used instead of Stylelint's at-rule-no-unknown.@
-useat-use-no-unnamespaced
: Disallow @use
without a namespace (i.e. @use "..." as *
).at-use-no-redundant-alias
: Disallow redundant namespace aliases (i.e. @use "foo" as foo
).$
-variabledollar-variable-colon-newline-after
: Require a newline after the colon in $
-variable declarations (Autofixable).dollar-variable-colon-space-after
: Require or disallow whitespace after the colon in $
-variable declarations (Autofixable).dollar-variable-colon-space-before
: Require a single space or disallow whitespace before the colon in $
-variable declarations (Autofixable).dollar-variable-default
: Require !default
flag for $
-variable declarations.dollar-variable-empty-line-after
: Require a single empty line or disallow empty lines after $
-variable declarations (Autofixable).dollar-variable-empty-line-before
: Require a single empty line or disallow empty lines before $
-variable declarations (Autofixable).dollar-variable-first-in-block
: Require for variables to be put first in a block (a rule or in root).dollar-variable-no-missing-interpolation
: Disallow Sass variables that are used without interpolation with CSS features that use custom identifiers.dollar-variable-no-namespaced-assignment
: Disallow assignment to namespaced Sass variables.dollar-variable-pattern
: Specify a pattern for Sass-like variables.%
-placeholderpercent-placeholder-pattern
: Specify a pattern for %
-placeholders.//
-commentdouble-slash-comment-empty-line-before
: Require or disallow an empty line before //
-comments (Autofixable).double-slash-comment-inline
: Require or disallow //
-comments to be inline comments.double-slash-comment-whitespace-inside
: Require or disallow whitespace after the //
in //
-commentsblock-no-redundant-nesting
: Disallow nesting a single block if it could be merged with its parent block.comment-no-empty
: Disallow empty comments.comment-no-loud
: Disallow /*
-comments.declaration-nested-properties
: Require or disallow properties with -
in their names to be in a form of a nested group.declaration-nested-properties-no-divided-groups
: Disallow nested properties of the same "namespace" to be divided into multiple groups.declaration-property-value-no-unknown
: Disallow unknown values for properties within declarations.dimension-no-non-numeric-values
: Disallow non-numeric values when interpolating a value with a unit.function-calculation-no-interpolation
: Disallow interpolation in calc()
, clamp()
, min()
, and max()
functions.function-color-channel
: Encourage the use of the color.channel function over related deprecated color functions.function-color-relative
: Encourage the use of the scale-color function over regular color functions.function-disallowed-list
: Specify a list of disallowed functions. Should be used instead of Stylelint's function-disallowed-list.function-no-unknown
: Disallow unknown functions. Should be used instead of Stylelint's function-no-unknown.function-quote-no-quoted-strings-inside
: Disallow quoted strings inside the quote function (Autofixable).function-unquote-no-unquoted-strings-inside
: Disallow unquoted strings inside the unquote function (Autofixable).map-keys-quotes
: Require quoted keys in Sass maps.media-feature-value-dollar-variable
: Require a media feature value be a $
-variable or disallow $
-variables in media feature values.operator-no-newline-after
: Disallow linebreaks after Sass operators.operator-no-newline-before
: Disallow linebreaks before Sass operators.operator-no-unspaced
: Disallow unspaced operators in Sass operations.partial-no-import
: Disallow non-CSS @import
s in partial files.property-no-unknown
: Disallow unknown properties, including nested properties. Should be used instead of Stylelint's property-no-unknown.selector-nest-combinators
: Require or disallow nesting of combinators in selectors.selector-no-redundant-nesting-selector
: Disallow redundant nesting selectors (&
).selector-no-union-class-name
: Disallow union class names with the parent selector (&
).load-no-partial-leading-underscore
: Disallow leading underscore in partial names in @import
, @use
, @forward
, and meta.load-css
$url
parameter.load-partial-extension
: Require or disallow extension in @import
, @use
, @forward
, and [meta.load-css
] commands (Autofixable).no-dollar-variables
: Disallow dollar variables within a stylesheet.no-duplicate-dollar-variables
: Disallow duplicate dollar variables within a stylesheet.no-duplicate-mixins
: Disallow duplicate mixins within a stylesheet.no-global-function-names
: Disallows the use of global function names, as these global functions are now located inside built-in Sass modules.no-unused-private-members
: Disallow unused private members such as functions, mixins, variables or placeholder selectors.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.
at-import-no-partial-leading-underscore
: Disallow leading underscore in partial names in @import
.at-import-partial-extension
: Require or disallow extension in @import
commands.at-import-partial-extension-blacklist
: Specify a blacklist of disallowed file extensions for partial names in @import
commands.at-import-partial-extension-whitelist
: Specify a whitelist of allowed file extensions for partial names in @import
commands.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):
We communicate via issues and pull requests.
There is also StackOverflow, which would be the preferred QA forum.
Thanks goes to these wonderful people:
kristerkari | dryoma | rambleraptor | XhmikosR | ybiquitous | pamelalozano16 |
Eugeno | joseph118 | stof | niksy | kaysonwu | srawlins |
jhae-de | FloEdelmann | pipopotamasu | OriR | ntwb | ricardogobbosouza |
jeddy3 | evilebottnawi | kevindew | thibaudcolas | chimurai | vseventer |
xboy2012 | chalkygames123 | bjankord | AndyOGo | qmhc | freezy-sk |
YodaDaCoda | wlewis-formative | kersh | AM-77 | YozhikM | sajadtorkamani |
paulgv | 01taylop | nlydv | manovotny | keegan-lillo | stormwarning |
jantimon | guoyunhe | G-Rath | EvanHahn | lithiumlron | diego-codes |
Deimos | Calme1709 | SterlingVix |
FAQs
A collection of SCSS-specific rules for Stylelint
We found that stylelint-scss demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.