UNPKG

4.65 kBMarkdownView Raw
1# @nuxtjs/stylelint-module
2
3[![npm version][npm-version-src]][npm-version-href]
4[![npm downloads][npm-downloads-src]][npm-downloads-href]
5[![Circle CI][circle-ci-src]][circle-ci-href]
6[![Codecov][codecov-src]][codecov-href]
7[![License][license-src]][license-href]
8
9> Stylelint module for Nuxt.js
10
11[📖 **Release Notes**](./CHANGELOG.md)
12
13## Requirements
14
15You need to ensure that you have `stylelint` installed:
16
17```bash
18yarn add --dev stylelint # or npm install --save-dev stylelint
19```
20
21## Setup
22
231. Add `@nuxtjs/stylelint-module` dependency to your project
24
25```bash
26yarn add --dev @nuxtjs/stylelint-module # or npm install --save-dev @nuxtjs/stylelint-module
27```
28
292. Add `@nuxtjs/stylelint-module` to the `buildModules` section of `nuxt.config.js`
30
31```js
32export default {
33 buildModules: [
34 // Simple usage
35 '@nuxtjs/stylelint-module',
36
37 // With options
38 ['@nuxtjs/stylelint-module', { /* module options */ }]
39 ]
40}
41```
42
43:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`.
44
45### Using top level options
46
47```js
48export default {
49 buildModules: [
50 '@nuxtjs/stylelint-module'
51 ],
52 stylelint: {
53 /* module options */
54 }
55}
56```
57
58## Options
59
60See [stylelint's options](http://stylelint.io/user-guide/node-api/#options) for the complete list of options available. These options are passed through to the `stylelint` directly.
61
62### `configFile`
63
64- Type: `String`
65- Default: `undefined`
66
67Specify the config file location to be used by `stylelint`.
68
69**Note:** By default this is [handled by `stylelint`](http://stylelint.io/user-guide/configuration/).
70
71### `context`
72
73- Type: `String`
74- Default: `srcDir`
75
76A string indicating the root of your files.
77
78### `files`
79
80- Type: `String|Array[String]`
81- Default: `['assets/**/*.{s?(a|c)ss,less,stylus}', '{components,layouts,pages}/**/*.vue']`
82
83Specify the glob pattern for finding files. Must be relative to `options.context`.
84
85### `fix`
86
87- Type: `Boolean`
88- Default: `false`
89
90If `true`, `stylelint` will fix as many errors as possible. The fixes are made to the actual source files. All unfixed errors will be reported. See [Autofixing errors](https://stylelint.io/user-guide/cli#autofixing-errors) docs.
91
92### `formatter`
93
94- Type: `Function`
95- Default: `require('stylelint').formatters.string`
96
97Specify the formatter that you would like to use to format your results.
98
99### `lintDirtyModulesOnly`
100
101- Type: `Boolean`
102- Default: `false`
103
104Lint only changed files, skip lint on start.
105
106### `stylelintPath`
107
108- Type: `String`
109- Default: `stylelint`
110
111Path to `stylelint` instance that will be used for linting.
112
113### Errors and Warning
114
115**By default the plugin will auto adjust error reporting depending on stylelint errors/warnings counts.**
116You can still force this behavior by using `emitError` **or** `emitWarning` options:
117
118#### `emitError`
119
120- Type: `Boolean`
121- Default: `false`
122
123Will always return errors, if set to `true`.
124
125#### `emitWarning`
126
127- Type: `Boolean`
128- Default: `false`
129
130Will always return warnings, if set to `true`.
131
132#### `failOnError`
133
134- Type: `Boolean`
135- Default: `false`
136
137Will cause the module build to fail if there are any errors, if set to `true`.
138
139#### `failOnWarning`
140
141- Type: `Boolean`
142- Default: `false`
143
144Will cause the module build to fail if there are any warnings, if set to `true`.
145
146#### `quiet`
147
148- Type: `Boolean`
149- Default: `false`
150
151Will process and report errors only and ignore warnings, if set to `true`.
152
153## Development
154
1551. Clone this repository
1562. Install dependencies using `yarn install` or `npm install`
1573. Start development server using `npm run dev`
158
159## License
160
161[MIT License](./LICENSE)
162
163Copyright (c) Nuxt Community
164
165<!-- Badges -->
166[npm-version-src]: https://img.shields.io/npm/v/@nuxtjs/stylelint-module/latest.svg?style=flat-square
167[npm-version-href]: https://npmjs.com/package/@nuxtjs/stylelint-module
168
169[npm-downloads-src]: https://img.shields.io/npm/dt/@nuxtjs/stylelint-module.svg?style=flat-square
170[npm-downloads-href]: https://npmjs.com/package/@nuxtjs/stylelint-module
171
172[circle-ci-src]: https://img.shields.io/circleci/project/github/nuxt-community/stylelint-module.svg?style=flat-square
173[circle-ci-href]: https://circleci.com/gh/nuxt-community/stylelint-module
174
175[codecov-src]: https://img.shields.io/codecov/c/github/nuxt-community/stylelint-module.svg?style=flat-square
176[codecov-href]: https://codecov.io/gh/nuxt-community/stylelint-module
177
178[license-src]: https://img.shields.io/npm/l/@nuxtjs/stylelint-module.svg?style=flat-square
179[license-href]: https://npmjs.com/package/@nuxtjs/stylelint-module