UNPKG

4.46 kBMarkdownView Raw
1<div align="center">
2 <a href="https://github.com/stylelint/stylelint"><img width="200" height="200" src="https://cdn.worldvectorlogo.com/logos/stylelint.svg"></a>
3 <a href="https://github.com/webpack/webpack"><img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg"></a>
4</div>
5
6[![npm][npm]][npm-url]
7[![node][node]][node-url]
8[![deps][deps]][deps-url]
9[![tests][tests]][tests-url]
10[![coverage][cover]][cover-url]
11[![chat][chat]][chat-url]
12[![size][size]][size-url]
13
14# stylelint-webpack-plugin
15
16> A Stylelint plugin for webpack
17
18## Install
19
20```bash
21npm install stylelint-webpack-plugin --save-dev
22```
23
24**Note**: You also need to install `stylelint` from npm, if you haven't already:
25
26```bash
27npm install stylelint --save-dev
28```
29
30## Usage
31
32In your webpack configuration:
33
34```js
35const StylelintPlugin = require('stylelint-webpack-plugin');
36
37module.exports = {
38 // ...
39 plugins: [new StylelintPlugin(options)],
40 // ...
41};
42```
43
44## Options
45
46See stylelint's [options](http://stylelint.io/user-guide/node-api/#options) for
47the complete list of options available. These options are passed through to the
48`stylelint` directly.
49
50### `configFile`
51
52- Type: `String`
53- Default: `undefined`
54
55Specify the config file location to be used by `stylelint`.
56
57_Note: By default this is [handled by `stylelint`](http://stylelint.io/user-guide/configuration/)._
58
59### `context`
60
61- Type: `String`
62- Default: `compiler.context`
63
64A string indicating the root of your style files.
65
66### `files`
67
68- Type: `String|Array[String]`
69- Default: `'**/*.s?(a|c)ss'`
70
71Specify the glob pattern for finding files. Must be relative to `options.context`.
72
73### `formatter`
74
75- Type: `Function`
76- Default: `require('stylelint').formatters.string`
77
78Specify a custom formatter to format errors printed to the console.
79
80### `lintDirtyModulesOnly`
81
82- Type: `Boolean`
83- Default: `false`
84
85Lint only changed files, skip lint on start.
86
87### `stylelintPath`
88
89- Type: `String`
90- Default: `stylelint`
91
92Path to `stylelint` instance that will be used for linting.
93
94### `syntax`
95
96- Type: `String`
97- Default: `undefined`
98
99See the `styelint` [user guide](https://stylelint.io/user-guide/node-api/#syntax) for more info.
100e.g. use `'scss'` to lint .scss files.
101
102### Errors and Warning
103
104**By default the plugin will auto adjust error reporting depending on stylelint errors/warnings counts.**
105You can still force this behavior by using `emitError` **or** `emitWarning` options:
106
107#### `emitError`
108
109- Type: `Boolean`
110- Default: `false`
111
112Will always return errors, if this option is set to `true`.
113
114#### `emitWarning`
115
116- Type: `Boolean`
117- Default: `false`
118
119Will always return warnings, if option is set to `true`.
120
121#### `failOnError`
122
123- Type: `Boolean`
124- Default: `false`
125
126Will cause the module build to fail if there are any errors, if option is set to `true`.
127
128#### `failOnWarning`
129
130- Type: `Boolean`
131- Default: `false`
132
133Will cause the module build to fail if there are any warnings, if option is set to `true`.
134
135#### `quiet`
136
137- Type: `Boolean`
138- Default: `false`
139
140Will process and report errors only and ignore warnings, if this option is set to `true`.
141
142## Acknowledgement
143
144This project was inspired by, and is a heavily modified version of
145`sasslint-webpack-plugin`.
146
147Thanks to Javier ([@vieron](https://github.com/vieron)) for authoring this
148plugin.
149
150## Changelog
151
152[Changelog](CHANGELOG.md)
153
154## License
155
156[MIT](./LICENSE)
157
158[npm]: https://img.shields.io/npm/v/stylelint-webpack-plugin.svg
159[npm-url]: https://npmjs.com/package/stylelint-webpack-plugin
160[node]: https://img.shields.io/node/v/stylelint-webpack-plugin.svg
161[node-url]: https://nodejs.org
162[deps]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin.svg
163[deps-url]: https://david-dm.org/webpack-contrib/stylelint-webpack-plugin
164[tests]: https://dev.azure.com/webpack-contrib/stylelint-webpack-plugin/_apis/build/status/webpack-contrib.stylelint-webpack-plugin?branchName=master
165[tests-url]: https://dev.azure.com/webpack-contrib/stylelint-webpack-plugin/_build/latest?definitionId=4&branchName=master
166[cover]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin/branch/master/graph/badge.svg
167[cover-url]: https://codecov.io/gh/webpack-contrib/stylelint-webpack-plugin
168[chat]: https://badges.gitter.im/webpack/webpack.svg
169[chat-url]: https://gitter.im/webpack/webpack
170[size]: https://packagephobia.now.sh/badge?p=stylelint-webpack-plugin
171[size-url]: https://packagephobia.now.sh/result?p=stylelint-webpack-plugin