Socket
Socket
Sign inDemoInstall

stylelint-config-standard

Package Overview
Dependencies
112
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    stylelint-config-standard

Standard shareable config for Stylelint


Version published
Weekly downloads
2.7M
increased by2.47%
Maintainers
5
Install size
14.1 kB
Created
Weekly downloads
 

Package description

What is stylelint-config-standard?

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.

What are stylelint-config-standard's main functionalities?

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"]
    }]
  }
}

Other packages similar to stylelint-config-standard

Changelog

Source

36.0.0

  • Removed: stylelint less than 16.1.0 from peer dependencies.
  • Added: lightness-notation: "percentage" rule.

Readme

Source

stylelint-config-standard

NPM version Build Status

The standard shareable config for Stylelint.

It extends stylelint-config-recommended and turns on additional rules to enforce modern conventions found in the CSS specifications.

To see the rules that this config uses, please read the config itself.

Example

@import url("foo.css");
@import url("bar.css");

@custom-media --foo (min-width: 30em);

/**
 * Multi-line comment
 */

:root {
  --brand-red: hsl(5deg 10% 40%);
}

/* Single-line comment */

.class-foo:not(a, div) {
  margin: 0;
  top: calc(100% - 2rem);
}

/* Flush single line comment */
@media (width >= 60em) {
  #id-bar {
    /* Flush to parent comment */
    --offset: 0px;

    color: #fff;
    font-family: Helvetica, "Arial Black", sans-serif;
    left: calc(var(--offset) + 50%);
  }

  /* Flush nested single line comment */
  a::after {
    display: block;
    content: "→";
    background-image: url("x.svg");
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

Note: the config is tested against this example, as such the example contains plenty of CSS syntax and features.

Installation

npm install stylelint-config-standard --save-dev

Usage

Set your Stylelint config to:

{
  "extends": "stylelint-config-standard"
}

Extending the config

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"
      }
    ]
  }
}

Or to add a rule, For example, the unit-allowed-list one:

{
  "extends": "stylelint-config-standard",
  "rules": {
    "unit-allowed-list": ["em", "rem", "s"]
  }
}

We recommend adding more of Stylelint's rules to your config as these rules need to be configured to suit your specific needs.

Changelog

License

Keywords

FAQs

Last updated on 25 Dec 2023

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