UNPKG

2.7 kBMarkdownView Raw
1# stylelint-config-standard
2
3[![NPM version](https://img.shields.io/npm/v/stylelint-config-standard.svg)](https://www.npmjs.org/package/stylelint-config-standard) [![Build Status](https://github.com/stylelint/stylelint-config-standard/workflows/CI/badge.svg)](https://github.com/stylelint/stylelint-config-standard/actions)
4
5> The standard shareable config for Stylelint.
6
7It extends [`stylelint-config-recommended`](https://github.com/stylelint/stylelint-config-recommended) and turns on additional rules to enforce modern conventions found in the [CSS specifications](https://www.w3.org/Style/CSS/current-work).
8
9To see the rules that this config uses, please read the [config itself](./index.js).
10
11## Example
12
13```css
14@import url("foo.css");
15@import url("bar.css");
16
17@custom-media --foo (min-width: 30em);
18
19/**
20 * Multi-line comment
21 */
22
23:root {
24 --brand-red: hsl(5deg 10% 40%);
25}
26
27/* Single-line comment */
28
29.class-foo:not(a, div) {
30 margin: 0;
31 top: calc(100% - 2rem);
32}
33
34/* Flush single line comment */
35@media (width >= 60em) {
36 #id-bar {
37 /* Flush to parent comment */
38 --offset: 0px;
39
40 color: #fff;
41 font-family: Helvetica, "Arial Black", sans-serif;
42 left: calc(var(--offset) + 50%);
43 }
44
45 /* Flush nested single line comment */
46 a::after {
47 display: block;
48 content: "→";
49 background-image: url("x.svg");
50 }
51}
52
53@keyframes fade-in {
54 from {
55 opacity: 0;
56 }
57
58 to {
59 opacity: 1;
60 }
61}
62```
63
64_Note: the config is tested against this example, as such the example contains plenty of CSS syntax and features._
65
66## Installation
67
68```bash
69npm install stylelint-config-standard --save-dev
70```
71
72## Usage
73
74Set your Stylelint config to:
75
76```json
77{
78 "extends": "stylelint-config-standard"
79}
80```
81
82### Extending the config
83
84Add a `"rules"` key to your config, then add your overrides and additions there.
85
86You can turn off rules by setting its value to `null`. For example:
87
88```json
89{
90 "extends": "stylelint-config-standard",
91 "rules": {
92 "selector-class-pattern": null
93 }
94}
95```
96
97Or lower the severity of a rule to a warning using the `severity` secondary option. For example:
98
99```json
100{
101 "extends": "stylelint-config-standard",
102 "rules": {
103 "property-no-vendor-prefix": [
104 true,
105 {
106 "severity": "warning"
107 }
108 ]
109 }
110}
111```
112
113Or to add a rule, For example, the `unit-allowed-list` one:
114
115```json
116{
117 "extends": "stylelint-config-standard",
118 "rules": {
119 "unit-allowed-list": ["em", "rem", "s"]
120 }
121}
122```
123
124We recommend adding more of [Stylelint's rules](https://stylelint.io/user-guide/rules/) to your config as these rules need to be configured to suit your specific needs.
125
126## [Changelog](CHANGELOG.md)
127
128## [License](LICENSE)