Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
stylelint
Advanced tools
Stylelint is a powerful, modern linter that helps you avoid errors and enforce consistent conventions in your stylesheets. It is configurable and supports the latest CSS syntax as well as CSS-like syntaxes, such as SCSS.
Linting CSS files
This command will lint all CSS files in the 'src' directory and its subdirectories. It will check for errors and code quality issues based on the rules defined in the configuration.
"stylelint 'src/**/*.css'"
Fixing CSS files
This command will not only lint the CSS files but also attempt to fix any fixable issues, such as formatting inconsistencies, automatically.
"stylelint 'src/**/*.css' --fix"
Custom configuration
This JSON represents a custom Stylelint configuration object where specific rules are defined, such as disallowing invalid hex colors, setting indentation preferences, and enforcing no leading zero for numbers.
{ "rules": { "color-no-invalid-hex": true, "indentation": [2, { "except": ["block"] }], "number-leading-zero": "never" } }
Extending configurations
This JSON represents a Stylelint configuration that extends a shared configuration, in this case, 'stylelint-config-standard', which is a popular set of rules that enforce common stylistic conventions.
{ "extends": "stylelint-config-standard" }
Using plugins
This JSON represents a Stylelint configuration that includes a plugin, 'stylelint-scss', which adds SCSS-specific linting rules to Stylelint. The configuration then enables a rule from that plugin to disallow unknown at-rules in SCSS.
{ "plugins": ["stylelint-scss"], "rules": { "scss/at-rule-no-unknown": true } }
ESLint is a static code analysis tool for identifying problematic patterns in JavaScript code. It is similar to Stylelint in its extensibility and plugin ecosystem but is focused on JavaScript rather than stylesheets.
Prettier is an opinionated code formatter that supports many languages, including CSS. Unlike Stylelint, which can both lint and fix code, Prettier is solely focused on code formatting and does not provide linting functionalities.
Sass-lint is a node-only Sass linter for both sass and scss syntax. It is similar to Stylelint when working with SCSS files but does not support plain CSS or other CSS-like syntaxes.
CSSLint is a tool that helps to point out problems with your CSS code. It is less configurable than Stylelint and has a smaller set of rules and plugins, but it serves a similar purpose in linting CSS files.
A mighty CSS linter that helps you avoid errors and enforce conventions.
It's mighty as it:
And it can be extended to:
It'll help you avoid errors, for example:
And enforce conventions, for example:
We recommend using a pretty printer like Prettier alongside Stylelint. Linters and pretty printers are complementary tools that work together to help you write consistent and error-free code.
Stylelint is maintained by volunteers. Without the code contributions from all these fantastic people, Stylelint would not exist. Become a contributor.
Thank you to all our sponsors! Become a sponsor.
Thank you to all our backers! Become a backer.
16.7.0
tap
formatter to support TAP14 (#7759) (@Mouvedia).url
secondary option (#7743) (@emmacharp).at-rule-no-unknown
false positives for @historical-forms
and @font-palette-values
(#7774) (@Mouvedia).at-rule-no-unknown
false positives for @view-transition
(#7753) (@sebdanielsson).at-rule-no-vendor-prefix
false negatives for @-moz-document
and @-webkit-viewport
(#7772) (@Mouvedia).comment-whitespace-inside
end positions (#7744) (@Mouvedia).declaration-block-no-duplicate-properties
reported ranges (#7758) (@Mouvedia).declaration-block-no-redundant-longhand-properties
/declaration-block-no-shorthand-property-overrides
false negatives for font-variant
(#7734) (@Bilie).font-family-name-quotes
false negatives for -moz-*
/-webkit-*
keywords (#7777) (@Mouvedia).font-family-no-missing-generic-family-keyword
false negatives for font families which names match a CSS3 font-variant
keyword (#7823) (@Mouvedia).function-name-case
end positions (#7747) (@Mouvedia).function-no-unknown
performance by reducing file read count (#7801) (@ybiquitous).media-feature-name-no-vendor-prefix
autofix (#7770) (@Mouvedia).no-invalid-double-slash-comments
reported ranges (#7768) (@Mouvedia).property-no-unknown
false positives for navigation
and miscellaneous legacy properties (#7764) (@Mouvedia).quietDeprecationWarnings
to suppress stylelint:003
warning (#7837) (@ybiquitous).selector-no-vendor-prefix
autofix (#7763) (@Mouvedia).selector-not-notation
end positions when new lines are part of the selector (#7755) (@Mouvedia).selector-type-case
end positions (#7752) (@Mouvedia).shorthand-property-no-redundant-values
false negatives for logical properties, overflow
, overscroll-behavior
, scroll-margin
and scroll-padding
(#7808) (@Mouvedia).string-no-newline
false positives for escaped multi-line (#7818) (@romainmenke).value-keyword-case
end positions (#7760) (@Mouvedia).stylelint.utils.checkAgainstRule()
for Promise-based rules (#7821) (@aaronccasanova).stylelint.utils.checkAgainstRule()
to use result.stylelint
if present (#7833) (@ybiquitous).tap
formatter (#7759) (@Mouvedia).FAQs
A mighty CSS linter that helps you avoid errors and enforce conventions.
The npm package stylelint receives a total of 3,785,913 weekly downloads. As such, stylelint popularity was classified as popular.
We found that stylelint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.