Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
stylelint-config-standard
Advanced tools
The stylelint-config-standard package is an extensible shared configuration for Stylelint, which is a mighty, modern linter that helps you avoid errors and enforce conventions in your styles. It is considered the standard configuration for Stylelint, providing a sensible default configuration that enforces common stylistic conventions for CSS.
Extensible Configuration
This package provides a base set of rules for Stylelint, which can be extended in a project's .stylelintrc configuration file. By extending stylelint-config-standard, you inherit a standard set of rules that can be customized further.
{
"extends": "stylelint-config-standard"
}
Enforce Stylistic Conventions
The package enforces stylistic conventions such as lowercase hex colors, indentation levels, and leading zeros in numbers. These rules help maintain consistency across your project's stylesheets.
{
"rules": {
"color-hex-case": "lower",
"indentation": 2,
"number-leading-zero": "always"
}
}
Customizable Rules
While it provides a standard set of rules, it also allows for customization. Developers can override or extend the rules to fit their project's specific needs, such as allowing certain at-rules that are not part of CSS specifications but are used by preprocessors.
{
"extends": "stylelint-config-standard",
"rules": {
"at-rule-no-unknown": [ true, {
"ignoreAtRules": ["extends", "ignores"]
}]
}
}
This package is a lighter version of the standard configuration, focusing on possible error rules rather than stylistic rules. It's a good starting point for projects that want to enforce error checking without imposing stylistic choices.
This package extends stylelint-config-standard and adds rules specific to Sass, such as those for nesting depth, name formats, and other conventions. It's tailored for projects that use Sass and want to adhere to common guidelines.
This package integrates Stylelint with Prettier, an opinionated code formatter. It disables all rules that might conflict with Prettier, allowing developers to use Stylelint for linting and Prettier for formatting.
The standard shareable config for Stylelint.
Extends stylelint-config-recommended
.
Turns on additional rules to enforce common conventions found in the specifications and in a handful of CSS styleguides, including: The Idiomatic CSS Principles, Google's CSS Style Guide, Airbnb's Styleguide, and @mdo's Code Guide.
It favours flexibility over strictness for things like multi-line lists and single-line rulesets.
To see the rules that this config uses, please read the config itself.
@import url("x.css");
@import url("y.css");
/**
* Multi-line comment
*/
:root {
--brand-red: hsl(5deg 10% 40%);
}
.selector-1,
.selector-2,
.selector-3[type="text"] {
background: linear-gradient(#fff, rgb(0 0 0 / 80%));
box-sizing: border-box;
display: block;
color: var(--brand-red);
}
.selector-a,
.selector-b:not(:first-child) {
padding: 10px !important;
top: calc(100% - 2rem);
}
.selector-x { width: 10%; }
.selector-y { width: 20%; }
.selector-z { width: 30%; }
/* Single-line comment */
@media (width >= 60em) {
.selector {
/* Flush to parent comment */
transform: translate(1, 1) scale(3);
}
}
@media (orientation: portrait), projection and (color) {
.selector-i + .selector-ii {
background: hsl(20deg 25% 33%);
font-family: Helvetica, "Arial Black", sans-serif;
}
}
/* Flush single line comment */
@media
screen and (min-resolution: 192dpi),
screen and (min-resolution: 2dppx) {
.selector {
animation: 3s none fade-in;
background-image:
repeating-linear-gradient(
-45deg,
transparent,
#fff 25px,
rgb(255 255 255 / 100%) 50px
);
margin: 10px;
margin-bottom: 5px;
box-shadow:
0 1px 1px #000,
0 1px 0 #fff,
2px 2px 1px 1px #ccc inset;
height: 10rem;
}
/* Flush nested single line comment */
.selector::after {
content: "→";
background-image: url("x.svg");
}
}
@keyframes fade-in {
from { opacity: 0%; }
to { opacity: 100%; }
}
Note: the config is tested against this example, as such the example contains plenty of CSS syntax, formatting and features.
npm install stylelint-config-standard --save-dev
Set your stylelint config to:
{
"extends": "stylelint-config-standard"
}
Add a "rules"
key to your config, then add your overrides and additions there.
You can turn off rules by setting its value to null
. For example:
{
"extends": "stylelint-config-standard",
"rules": {
"selector-class-pattern": null
}
}
Or lower the severity of a rule to a warning using the severity
secondary option. For example:
{
"extends": "stylelint-config-standard",
"rules": {
"property-no-vendor-prefix": [
true,
{
"severity": "warning"
}
]
}
}
A more complete example, to change the at-rule-no-unknown
rule to use its ignoreAtRules
option, change the indentation
to tabs, turn off the number-leading-zero
rule, set the severity of the number-max-precision
rule to warning
, and add the unit-allowed-list
rule:
{
"extends": "stylelint-config-standard",
"rules": {
"at-rule-no-unknown": [
true,
{
"ignoreAtRules": ["--my-at-rule"]
}
],
"indentation": "tab",
"number-leading-zero": null,
"number-max-precision": [
4,
{
"severity": "warning"
}
],
"unit-allowed-list": ["em", "rem", "s"]
}
}
stylelint-config-standard
is a great foundation for your own config. You can extend it to create a tailored and much stricter config:
at-rule-disallowed-list
at-rule-allowed-list
at-rule-property-required-list
color-named
color-no-hex
comment-word-disallowed-list
declaration-no-important
declaration-property-unit-disallowed-list
declaration-property-unit-allowed-list
declaration-property-value-disallowed-list
declaration-property-value-allowed-list
function-disallowed-list
function-url-scheme-disallowed-list
function-url-scheme-allowed-list
function-allowed-list
media-feature-name-disallowed-list
media-feature-name-allowed-list
property-disallowed-list
property-allowed-list
selector-attribute-operator-disallowed-list
selector-attribute-operator-allowed-list
selector-combinator-disallowed-list
selector-combinator-allowed-list
selector-pseudo-class-disallowed-list
selector-pseudo-class-allowed-list
selector-pseudo-element-disallowed-list
selector-pseudo-element-allowed-list
unit-disallowed-list
unit-allowed-list
23.0.0
This release adds over a dozen new rules.
If needed, you can extend the config to turn off or lower the severity of any of the new rules.
We recommend using Autoprefixer to automatically prefix your at-rules, properties, selectors and values.
stylelint
less than 14.0.0
from peer dependencies.stylelint-config-recommended@6.0.0
.alpha-value-notation
rule.at-rule-no-vendor-prefix
rule.color-function-notation
rule.custom-media-pattern
rule.custom-property-pattern
rule.declaration-block-no-redundant-longhand-properties
rule.font-family-name-quotes
rule.function-url-quotes
rule.hue-degree-notation
rule.keyframes-name-pattern
rule.max-line-length
rule.media-feature-name-no-vendor-prefix
rule.no-empty-first-line
rule.no-irregular-whitespace
rule.number-max-precision
rule.property-no-vendor-prefix
rule.selector-attribute-quotes
rule.selector-class-pattern
rule.selector-id-pattern
rule.selector-no-vendor-prefix
rule.shorthand-property-no-redundant-values
rule.string-quotes
rule.value-no-vendor-prefix
rule.FAQs
Standard shareable config for Stylelint
The npm package stylelint-config-standard receives a total of 2,416,269 weekly downloads. As such, stylelint-config-standard popularity was classified as popular.
We found that stylelint-config-standard demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.