You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72-84Lines changed: 72 additions & 84 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,31 +6,59 @@
6
6
[![Codecov][codecov-src]][codecov-href]
7
7
[![License][license-src]][license-href]
8
8
9
-
> ESLint module for Nuxt.js
9
+
> ESLint module for Nuxt
10
10
11
11
[📖 **Release Notes**](./CHANGELOG.md)
12
12
13
13
## Requirements
14
14
15
15
You need to ensure that you have `eslint >= 7` installed:
16
16
17
+
With `pnpm`
18
+
19
+
```bash
20
+
pnpm add -D eslint
21
+
```
22
+
23
+
Or, with `yarn`
24
+
17
25
```bash
18
-
yarn add --dev eslint # or npm install --save-dev eslint
26
+
yarn add -D eslint
27
+
```
28
+
29
+
Or, with `npm`
30
+
31
+
```bash
32
+
npm install -D eslint
19
33
```
20
34
21
35
## Setup
22
36
23
37
1. Add `@nuxtjs/eslint-module` dependency to your project
24
38
39
+
With `pnpm`
40
+
25
41
```bash
26
-
yarn add --dev @nuxtjs/eslint-module # or npm install --save-dev @nuxtjs/eslint-module
42
+
pnpm add @nuxtjs/eslint-module
27
43
```
28
44
29
-
2. Add `@nuxtjs/eslint-module` to the `buildModules` section of `nuxt.config.js`
45
+
Or, with `yarn`
46
+
47
+
```bash
48
+
yarn add @nuxtjs/eslint-module
49
+
```
50
+
51
+
Or, with `npm`
52
+
53
+
```bash
54
+
npm install @nuxtjs/eslint-module
55
+
```
56
+
57
+
2. Add `@nuxtjs/eslint-module` to the `modules` section of `nuxt.config.js`
30
58
31
59
```js
32
60
exportdefault {
33
-
buildModules: [
61
+
modules: [
34
62
// Simple usage
35
63
'@nuxtjs/eslint-module',
36
64
@@ -40,13 +68,11 @@ export default {
40
68
}
41
69
```
42
70
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
71
### Using top level options
46
72
47
73
```js
48
74
exportdefault {
49
-
buildModules: [
75
+
modules: [
50
76
'@nuxtjs/eslint-module'
51
77
],
52
78
eslint: {
@@ -57,11 +83,11 @@ export default {
57
83
58
84
## Options
59
85
60
-
You can pass [eslint options](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions).
86
+
You can pass [eslint options](https://eslint.org/docs/latest/integrate/nodejs-api#-new-eslintoptions).
61
87
62
88
Note that the config option you provide will be passed to the `ESLint` class.
63
89
This is a different set of options than what you'd specify in `package.json` or `.eslintrc`.
64
-
See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-eslintoptions) for more details.
90
+
See the [eslint docs](https://eslint.org/docs/latest/integrate/nodejs-api#-new-eslintoptions) for more details.
65
91
66
92
### `cache`
67
93
@@ -70,129 +96,91 @@ See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-es
70
96
71
97
**Note**: The cache is enabled by default to decrease execution time.
72
98
73
-
### `context`
74
-
75
-
- Type: `String`
76
-
- Default: `srcDir`
77
-
78
-
A string indicating the root of your files.
79
-
80
-
### `eslintPath`
81
-
82
-
- Type: `String`
83
-
- Default: `eslint`
84
-
85
-
Path to `eslint` instance that will be used for linting.
86
-
87
99
### `exclude`
88
100
89
-
- Type: `String|Array[String]`
90
-
- Default: `'node_modules'`
101
+
- Type: `Array[String]`
102
+
- Default: `['**/node_modules/**']]`
91
103
92
-
Specify the files and/or directories to exclude. Must be relative to `options.context`.
104
+
Specify the files and/or directories to exclude.
93
105
94
106
### `extensions`
95
107
96
108
- Type: `String|Array[String]`
97
-
- Default: `['js', 'ts', 'vue']`
109
+
- Default: `['js', 'jsx', 'ts', 'tsx', 'vue']`
98
110
99
111
Specify extensions that should be checked.
100
112
101
-
### `files`
113
+
### `eslintPath`
102
114
103
-
- Type: `String|Array[String]`
104
-
- Default: `null`
115
+
- Type: `String`
116
+
- Default: `eslint`
105
117
106
-
Specify directories, files, or globs. Must be relative to `options.context`.
107
-
Directories are traversed recursively looking for files matching `options.extensions`.
108
-
File and glob patterns ignore `options.extensions`.
118
+
Path to `eslint` instance that will be used for linting.
109
119
110
-
###`fix`
120
+
#### `emitError`
111
121
112
122
- Type: `Boolean`
113
-
- Default: `false`
114
-
115
-
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#cliengineoutputfixes).
116
-
117
-
**Be careful: this option will change source files.**
118
-
119
-
### `formatter`
123
+
- Default: `true`
120
124
121
-
- Type: `String|Function`
122
-
- Default: `'stylish'`
125
+
The errors found will be printed.
123
126
124
-
Accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
125
-
126
-
### `lintDirtyModulesOnly`
127
+
#### `emitWarning`
127
128
128
129
- Type: `Boolean`
129
130
- Default: `true`
130
131
131
-
Lint only changed files, skip lint on start.
132
-
133
-
### `threads`
134
-
135
-
- Type: `Boolean | Number`
136
-
- Default: `false`
132
+
The warnings found will be printed.
137
133
138
-
Will run lint tasks across a thread pool. The pool size is automatic unless you specify a number.
139
-
140
-
### Errors and Warning
141
-
142
-
**By default the plugin will auto adjust error reporting depending on eslint errors/warnings counts.**
143
-
You can still force this behavior by using `emitError`**or**`emitWarning` options:
144
-
145
-
#### `emitError`
134
+
#### `failOnWarning`
146
135
147
136
- Type: `Boolean`
148
137
- Default: `false`
149
138
150
-
Will always return errors, if set to `true`.
139
+
Will cause the module build to fail if there are any warnings, based on `emitWarning`.
151
140
152
-
#### `emitWarning`
141
+
#### `failOnError`
153
142
154
143
- Type: `Boolean`
155
144
- Default: `false`
156
145
157
-
Will always return warnings, if set to `true`.
146
+
Will cause the module build to fail if there are any errors, based on `emitError`.
158
147
159
-
#### `failOnError`
148
+
###`fix`
160
149
161
150
- Type: `Boolean`
162
151
- Default: `false`
163
152
164
-
Will cause the module build to fail if there are any errors, if set to `true`.
153
+
Auto fix source code.
165
154
166
-
#### `failOnWarning`
155
+
**Be careful: this option will change source files.**
167
156
168
-
- Type: `Boolean`
169
-
- Default: `false`
157
+
### `formatter`
170
158
171
-
Will cause the module build to fail if there are any warnings, if set to `true`.
159
+
- Type: `String|Function`
160
+
- Default: `'stylish'`
172
161
173
-
#### `quiet`
162
+
Accepts a function that will have one argument: an array of eslint messages (object). The function must return the output as a string. You can use official [eslint formatters](https://eslint.org/docs/user-guide/formatters/).
174
163
175
-
- Type: `Boolean`
176
-
- Default: `false`
164
+
### `lintOnStart`
177
165
178
-
Will process and report errors only and ignore warnings, if set to `true`.
166
+
- Type: `Boolean`
167
+
- Default: `true`
179
168
180
-
#### `outputReport`
169
+
Check all matching files on project startup, too slow, turn on discreetly.
181
170
182
-
- Type: `Boolean|Object`
183
-
- Default: `false`
171
+
## Contributing
184
172
185
-
Write the output of the errors to a file, for example a checkstyle xml file for use for reporting on Jenkins CI.
173
+
You can contribute to this module online with CodeSandBox:
186
174
187
-
The `filePath` is an absolute path or relative to the webpack config: `output.path`.
188
-
You can pass in a different `formatter` for the output file,
189
-
if none is passed in the default/configured formatter will be used.
0 commit comments