UNPKG

1.85 kBMarkdownView Raw
1# stylelint-config-shopify
2[![Circle CI](https://circleci.com/gh/Shopify/stylelint-config-shopify.svg?style=shield)](https://circleci.com/gh/Shopify/stylelint-config-shopify)
3[![David-DM](https://david-dm.org/shopify/stylelint-config-shopify.svg)](https://david-dm.org/Shopify/stylelint-config-shopify)
4
5Shopify's stylelint rules and config
6
7## Installation
8
9Install [stylelint](https://stylelint.io/) and `stylelint-config-shopify`:
10
11**With Yarn**
12```
13yarn add --dev stylelint stylelint-config-shopify
14```
15
16**With npm**
17```
18npm install stylelint stylelint-config-shopify --save-dev
19```
20
21
22## Usage
23Shopify’s stylelint rules come bundled in `stylelint-config-shopify`. To enable these rules, add a `stylelint` property in your `package.json`. See the [stylelint configuration docs](https://stylelint.io/user-guide/configuration/) for more details.
24```
25"stylelint": {
26 "extends": ["stylelint-config-shopify"]
27}
28```
29
30Now you can run stylelint by adding the following linting script to your `package.json`. See the [stylelint CLI docs](https://stylelint.io/user-guide/cli/) for more details.
31```
32"scripts": {
33 "stylelint": "stylelint 'src/**/*.scss'"
34}
35```
36Run it:
37
38**With Yarn**
39```
40yarn run stylelint
41```
42
43**With npm**
44```
45npm run stylelint
46```
47
48## Prettier
49
50This config also includes a prettier config which can be extended to format `.scss`.
51
52Install [`prettier-stylelint-formatter`](https://github.com/ismail-syed/prettier-stylelint-formatter):
53
54```
55$ yarn add --dev prettier-stylelint-formatter
56```
57
58Extend the config in your `package.json`:
59
60```json
61"stylelint": {
62 "extends": [
63 "stylelint-config-shopify/prettier"
64 ]
65}
66```
67
68Add a prettier config in `package.json`:
69
70```json
71"prettier": {
72 "singleQuote": true,
73 "trailingComma": "es5",
74 "bracketSpacing": false
75}
76```
77
78Run `prettier-stylelint`:
79
80```
81prettier-stylelint **/*.scss
82```