UNPKG

9.5 kBMarkdownView Raw
1# stylelint-config-standard
2
3[![NPM version](http://img.shields.io/npm/v/stylelint-config-standard.svg)](https://www.npmjs.org/package/stylelint-config-standard) [![Build Status](https://travis-ci.org/stylelint/stylelint-config-standard.svg?branch=master)](https://travis-ci.org/stylelint/stylelint-config-standard) [![Build status](https://ci.appveyor.com/api/projects/status/o8rfhyax6n7bjnlt/branch/master?svg=true)](https://ci.appveyor.com/project/stylelint/stylelint-config-standard/branch/master)
4
5> The standard shareable config for stylelint.
6
7Use it as is or as a foundation for your own config.
8
9It is derived from the common rules found within a handful of CSS styleguides, including: [The Idiomatic CSS Principles](https://github.com/necolas/idiomatic-css),
10[Github's PrimerCSS Guidelines](http://primercss.io/guidelines/#scss),
11[Google's CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.xml#CSS_Formatting_Rules), [Airbnb's Styleguide](https://github.com/airbnb/css#css), and [@mdo's Code Guide](http://codeguide.co/#css).
12
13It favours flexibility over strictness for things like multi-line lists and single-line rulesets, and tries to avoid potentially divisive rules.
14
15## Example
16
17```css
18/**
19 * Multi-line comment
20 */
21
22.selector-1,
23.selector-2,
24.selector-3[type="text"] {
25 background: linear-gradient(#fff, rgba(0, 0, 0, 0.8));
26 box-sizing: border-box;
27 display: block;
28 color: #333;
29}
30
31.selector-a,
32.selector-b {
33 padding: 10px !important;
34 top: calc(calc(1em * 2) / 3);
35}
36
37.selector-x { width: 10%; }
38.selector-y { width: 20%; }
39.selector-z { width: 30%; }
40
41/* Single-line comment */
42
43@media (min-width >= 60em) {
44 .selector {
45 /* Flush to parent comment */
46 transform: translate(1, 1) scale(3);
47 }
48}
49
50@media (min-orientation: portrait), projection and (color) {
51 .selector-i + .selector-ii {
52 background: color(rgb(0, 0, 0) lightness(50%));
53 font-family: helvetica, arial, sans-serif;
54 }
55}
56
57/* Flush single line comment */
58@media screen and (min-resolution: 192dpi),
59 screen and (min-resolution: 2dppx) {
60
61 .selector {
62 background-image:
63 repeating-linear-gradient(
64 -45deg,
65 transparent,
66 #fff 25px,
67 rgba(255, 255, 255, 1) 50px
68 );
69 margin: 10px;
70 margin-bottom: 5px;
71 box-shadow:
72 0 1px 1px #000,
73 0 1px 0 #fff,
74 2px 2px 1px 1px #ccc inset;
75 height: 10rem;
76 }
77
78 /* Flush nested single line comment */
79 .selector::after {
80 content: '→';
81 background-image: url(x.svg);
82 }
83}
84
85```
86
87*Note: the config is tested against this example, as such the example contains plenty of CSS syntax, formatting and features.*
88
89## Installation
90
91```console
92$ npm install stylelint-config-standard
93```
94
95## Usage
96
97If you've installed `stylelint-config-standard` locally within your project, just set your `stylelint` config to:
98
99```json
100{
101 "extends": "stylelint-config-standard"
102}
103```
104
105If you've globally installed `stylelint-config-standard` using the `-g` flag, then you'll need to use the absolute path to `stylelint-config-standard` in your config e.g.
106
107```json
108{
109 "extends": "/absolute/path/to/stylelint-config-standard"
110}
111```
112
113### Extending the config
114
115Simply add a `"rules"` key to your config, then add your overrides and additions there.
116
117For example, to whitelist specific units, change the `indentation` to tabs and turn off the `number-leading-zero` rule:
118
119```json
120{
121 "extends": "stylelint-config-standard",
122 "rules": {
123 "indentation": "tab",
124 "number-leading-zero": null,
125 "unit-whitelist": ["em", "rem", "s"]
126 }
127}
128```
129
130#### Suggested additions
131
132`stylelint-config-standard` is a great foundation for your own config. You can extend it create a tailored and much stricter config:
133
134- Specify what quotes must be used using:
135 - [`font-family-name-quotes`](https://github.com/stylelint/stylelint/blob/master/src/rules/font-family-name-quotes/README.md)
136 - [`function-url-quotes`](https://github.com/stylelint/stylelint/blob/master/src/rules/function-url-quotes/README.md)
137 - [`string-quotes`](https://github.com/stylelint/stylelint/blob/master/src/rules/string-quotes/README.md)
138- Specify the order of properties using:
139 - [`declaration-block-properties-order`](https://github.com/stylelint/stylelint/blob/master/src/rules/declaration-block-properties-order/README.md)
140- If you use [`autoprefixer`](https://github.com/postcss/autoprefixer) you'll want to disallow vendor prefixes using:
141 - [`at-rule-no-vendor-prefix`](https://github.com/stylelint/stylelint/blob/master/src/rules/at-rule-no-vendor-prefix/README.md)
142 - [`media-feature-name-no-vendor-prefix`](https://github.com/stylelint/stylelint/blob/master/src/rules/media-feature-name-no-vendor-prefix/README.md)
143 - [`property-no-vendor-prefix`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-no-vendor-prefix/README.md)
144 - [`selector-no-vendor-prefix`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-no-vendor-prefix/README.md)
145 - [`value-no-vendor-prefix`](https://github.com/stylelint/stylelint/blob/master/src/rules/value-no-vendor-prefix/README.md)
146- Control specificity using:
147 - [`max-nesting-depth`](https://github.com/stylelint/stylelint/blob/master/src/rules/max-nesting-depth/README.md)
148 - [`selector-max-specificity`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-max-specificity/README.md)
149- Specify acceptable selector types, units, properties and functions using:
150 - [`color-named`](https://github.com/stylelint/stylelint/blob/master/src/rules/color-named/README.md)
151 - [`color-no-hex`](https://github.com/stylelint/stylelint/blob/master/src/rules/color-no-hex/README.md)
152 - [`declaration-no-important`](https://github.com/stylelint/stylelint/blob/master/src/rules/declaration-no-important/README.md)
153 - [`function-whitelist`](https://github.com/stylelint/stylelint/blob/master/src/rules/function-whitelist/README.md)
154 - [`property-blacklist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-blacklist/README.md)
155 - [`property-unit-blacklist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-unit-blacklist/README.md)
156 - [`property-unit-whitelist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-unit-whitelist/README.md)
157 - [`property-value-blacklist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-value-blacklist/README.md)
158 - [`property-value-whitelist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-value-whitelist/README.md)
159 - [`selector-no-attribute`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-no-attribute/README.md)
160 - [`selector-no-combinator`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-no-combinator/README.md)
161 - [`selector-no-id`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-no-id/README.md)
162 - [`selector-no-type`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-no-type/README.md)
163 - [`selector-no-universal`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-no-universal/README.md)
164 - [`unit-blacklist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-blacklist/README.md)
165 - [`unit-whitelist`](https://github.com/stylelint/stylelint/blob/master/src/rules/property-blacklist/README.md)
166- Specify acceptable naming patterns using:
167 - [`custom-media-pattern`](https://github.com/stylelint/stylelint/blob/master/src/rules/custom-media-pattern/README.md)
168 - [`custom-property-pattern`](https://github.com/stylelint/stylelint/blob/master/src/rules/custom-property-pattern/README.md)
169 - [`selector-class-pattern`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-class-pattern/README.md)
170 - [`selector-id-pattern`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-id-pattern/README.md)
171- Specify a notation when there are one or more valid representations using:
172 - [`font-weight-notation`](https://github.com/stylelint/stylelint/blob/master/src/rules/font-weight-notation/README.md)
173- Specify the acceptable use of custom properties using:
174 - [`custom-property-no-outside-root`](https://github.com/stylelint/stylelint/blob/master/src/rules/custom-property-no-outside-root/README.md)
175 - [`selector-root-no-composition`](https://github.com/stylelint/stylelint/blob/master/src/rules/selector-root-no-composition/README.md)
176- Specify if Data URIs must or must not be used using:
177 - [`function-url-data-uris`](https://github.com/stylelint/stylelint/blob/master/src/rules/function-url-data-uris/README.md)
178- Specify a maximum line length using:
179 - [`max-line-length`](https://github.com/stylelint/stylelint/blob/master/src/rules/max-line-length/README.md)
180- Catch possible mistakes related to your targeted browsers using:
181 - [`no-browser-hacks`](https://github.com/stylelint/stylelint/blob/master/src/rules/no-browser-hacks/README.md)
182 - [`no-unsupported-browser-features`](https://github.com/stylelint/stylelint/blob/master/src/rules/no-unsupported-browser-features/README.md)
183
184### Using the config with SugarSS syntax
185
186The config is broadly compatible with [SugarSS](https://github.com/postcss/sugarss) syntax. You *will* need to turn off the `declaration-block-trailing-semicolon` rule, as so:
187
188```json
189{
190 "extends": "stylelint-config-standard",
191 "rules": {
192 "declaration-block-trailing-semicolon": null
193 }
194}
195```
196
197## [Changelog](CHANGELOG.md)
198
199## [License](LICENSE)