Skip to content
This repository was archived by the owner on Sep 28, 2020. It is now read-only.

Commit c6b7c12

Browse files
docs: formatting (#297)
1 parent 0821e14 commit c6b7c12

File tree

2 files changed

+126
-43
lines changed

2 files changed

+126
-43
lines changed

README.md

+115-32
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports = {
9494
};
9595
```
9696

97-
### Options
97+
## Options
9898

9999
You can pass [eslint options](http://eslint.org/docs/developer-guide/nodejs-api#cliengine)
100100
using standard webpack [loader options](https://webpack.js.org/configuration/module/#useentry).
@@ -103,14 +103,10 @@ Note that the config option you provide will be passed to the `CLIEngine`.
103103
This is a different set of options than what you'd specify in `package.json` or `.eslintrc`.
104104
See the [eslint docs](http://eslint.org/docs/developer-guide/nodejs-api#cliengine) for more detail.
105105

106-
#### `fix` (default: false)
106+
### `cache`
107107

108-
This option will enable
109-
[ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).
110-
111-
**Be careful: this option will change source files.**
112-
113-
#### `cache` (default: false)
108+
- Type: `Boolean|String`
109+
- Default: `false`
114110

115111
This option will enable caching of the linting results into a file.
116112
This is particularly useful in reducing linting time when doing a full build.
@@ -120,9 +116,57 @@ This can either be a `boolean` value or the cache directory path(ex: `'./.eslint
120116
If `cache: true` is used, the cache file is written to the `./node_modules/.cache` directory.
121117
This is the recommended usage.
122118

123-
#### `formatter` (default: 'stylish')
119+
```js
120+
module.exports = {
121+
entry: '...',
122+
module: {
123+
rules: [
124+
{
125+
test: /\.js$/,
126+
exclude: /node_modules/,
127+
loader: 'eslint-loader',
128+
options: {
129+
cache: true,
130+
},
131+
},
132+
],
133+
},
134+
};
135+
```
136+
137+
### `eslintPath`
138+
139+
- Type: `String`
140+
- Default: `eslint`
141+
142+
Path to `eslint` instance that will be used for linting.
143+
If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option.
144+
now you dont have to install `eslint`.
124145

125-
Loader accepts a function that will have one argument: an array of eslint messages (object).
146+
```js
147+
module.exports = {
148+
entry: '...',
149+
module: {
150+
rules: [
151+
{
152+
test: /\.js$/,
153+
exclude: /node_modules/,
154+
loader: 'eslint-loader',
155+
options: {
156+
eslintPath: path.join(__dirname, 'reusable-eslint'),
157+
},
158+
},
159+
],
160+
},
161+
};
162+
```
163+
164+
### `formatter`
165+
166+
- Type: `String|Function`
167+
- Default: `stylish`
168+
169+
This option accepts a function that will have one argument: an array of eslint messages (object).
126170
The function must return the output as a string.
127171
You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
128172

@@ -160,11 +204,15 @@ module.exports = {
160204
};
161205
```
162206

163-
#### `eslintPath` (default: 'eslint')
207+
### `fix`
164208

165-
Path to `eslint` instance that will be used for linting.
166-
If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option.
167-
now you dont have to install `eslint`.
209+
- Type: `Boolean`
210+
- Default: `false`
211+
212+
This option will enable
213+
[ESLint autofix feature](http://eslint.org/docs/user-guide/command-line-interface#fix).
214+
215+
**Be careful: this option will change source files.**
168216

169217
```js
170218
module.exports = {
@@ -176,23 +224,26 @@ module.exports = {
176224
exclude: /node_modules/,
177225
loader: 'eslint-loader',
178226
options: {
179-
eslintPath: path.join(__dirname, 'reusable-eslint'),
227+
fix: true,
180228
},
181229
},
182230
],
183231
},
184232
};
185233
```
186234

187-
#### Errors and Warning
235+
### Errors and Warning
188236

189237
**By default the loader will auto adjust error reporting depending
190238
on eslint errors/warnings counts.**
191239
You can still force this behavior by using `emitError` **or** `emitWarning` options:
192240

193-
##### `emitError` (default: `false`)
241+
#### `emitError`
194242

195-
Loader will always return errors if this option is set to `true`.
243+
- Type: `Boolean`
244+
- Default: `false`
245+
246+
Will always return errors, if this option is set to `true`.
196247

197248
```js
198249
module.exports = {
@@ -212,14 +263,37 @@ module.exports = {
212263
};
213264
```
214265

215-
##### `emitWarning` (default: `false`)
266+
#### `emitWarning`
216267

217-
Loader will always return warnings if option is set to `true`. If you're using hot module replacement,
218-
you may wish to enable this in development, or else updates will be skipped when there's an eslint error.
268+
- Type: `Boolean`
269+
- Default: `false`
219270

220-
##### `quiet` (default: `false`)
271+
Will always return warnings, if option is set to `true`. **If you're using hot module replacement, you may wish to enable this in development, or else updates will be skipped when there's an eslint error.**
221272

222-
Loader will process and report errors only and ignore warnings if this option is set to true
273+
```js
274+
module.exports = {
275+
entry: '...',
276+
module: {
277+
rules: [
278+
{
279+
test: /\.js$/,
280+
exclude: /node_modules/,
281+
loader: 'eslint-loader',
282+
options: {
283+
emitWarning: true,
284+
},
285+
},
286+
],
287+
},
288+
};
289+
```
290+
291+
#### `failOnError`
292+
293+
- Type: `Boolean`
294+
- Default: `false`
295+
296+
Will cause the module build to fail if there are any errors, if option is set to `true`.
223297

224298
```js
225299
module.exports = {
@@ -231,17 +305,20 @@ module.exports = {
231305
exclude: /node_modules/,
232306
loader: 'eslint-loader',
233307
options: {
234-
quiet: true,
308+
failOnError: true,
235309
},
236310
},
237311
],
238312
},
239313
};
240314
```
241315

242-
##### `failOnWarning` (default: `false`)
316+
#### `failOnWarning`
243317

244-
Loader will cause the module build to fail if there are any eslint warnings.
318+
- Type: `Boolean`
319+
- Default: `false`
320+
321+
Will cause the module build to fail if there are any warnings, if option is set to `true`.
245322

246323
```js
247324
module.exports = {
@@ -261,9 +338,12 @@ module.exports = {
261338
};
262339
```
263340

264-
##### `failOnError` (default: `false`)
341+
#### `quiet`
342+
343+
- Type: `Boolean`
344+
- Default: `false`
265345

266-
Loader will cause the module build to fail if there are any eslint errors.
346+
Will process and report errors only and ignore warnings, if this option is set to `true`.
267347

268348
```js
269349
module.exports = {
@@ -275,20 +355,23 @@ module.exports = {
275355
exclude: /node_modules/,
276356
loader: 'eslint-loader',
277357
options: {
278-
failOnError: true,
358+
quiet: true,
279359
},
280360
},
281361
],
282362
},
283363
};
284364
```
285365

286-
##### `outputReport` (default: `null`)
366+
#### `outputReport`
367+
368+
- Type: `Boolean|Object`
369+
- Default: `false`
287370

288371
Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI
289372

290-
The `filePath` is an absolute path or relative to the webpack config: output.path
291-
You can pass in a different formatter for the output file,
373+
The `filePath` is an absolute path or relative to the webpack config: `output.path`
374+
You can pass in a different `formatter` for the output file,
292375
if none is passed in the default/configured formatter will be used
293376

294377
```js

src/options.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
"type": "object",
33
"additionalProperties": true,
44
"properties": {
5-
"fix": {
6-
"description": "This option will enable ESLint autofix feature",
7-
"type": "boolean"
8-
},
95
"cache": {
106
"description": "This option will enable caching of the linting results into a file. This is particularly useful in reducing linting time when doing a full build.",
117
"anyOf": [{ "type": "boolean" }, { "type": "string" }]
128
},
9+
"eslintPath": {
10+
"description": "Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. now you dont have to install `eslint` .",
11+
"type": "string"
12+
},
1313
"formatter": {
1414
"description": "Loader accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string.",
1515
"anyOf": [{ "type": "string" }, { "instanceof": "Function" }]
1616
},
17-
"eslintPath": {
18-
"description": "Path to `eslint` instance that will be used for linting. If the `eslintPath` is a folder like a official eslint, or specify a `formatter` option. now you dont have to install `eslint` .",
19-
"type": "string"
17+
"fix": {
18+
"description": "This option will enable ESLint autofix feature",
19+
"type": "boolean"
2020
},
2121
"emitError": {
2222
"description": "Loader will always return errors if this option is set to `true`.",
@@ -26,16 +26,16 @@
2626
"description": "Loader will always return warnings if option is set to `true`. If you're using hot module replacement, you may wish to enable this in development, or else updates will be skipped when there's an eslint error.",
2727
"type": "boolean"
2828
},
29-
"quiet": {
30-
"description": "Loader will process and report errors only and ignore warnings if this option is set to true",
29+
"failOnError": {
30+
"description": "Loader will cause the module build to fail if there are any eslint errors.",
3131
"type": "boolean"
3232
},
3333
"failOnWarning": {
3434
"description": "Loader will cause the module build to fail if there are any eslint warnings.",
3535
"type": "boolean"
3636
},
37-
"failOnError": {
38-
"description": "Loader will cause the module build to fail if there are any eslint errors.",
37+
"quiet": {
38+
"description": "Loader will process and report errors only and ignore warnings if this option is set to true",
3939
"type": "boolean"
4040
},
4141
"outputReport": {

0 commit comments

Comments
 (0)