Skip to content

Commit f4a09da

Browse files
author
Strek
authored
docs(readme): added types in readme (#141)
1 parent cb435b5 commit f4a09da

1 file changed

Lines changed: 132 additions & 17 deletions

File tree

README.md

Lines changed: 132 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,40 @@ This plugin uses [`eslint`](https://eslint.org/) to find and fix problems in you
2121

2222
To begin, you'll need to install `eslint-webpack-plugin`:
2323

24-
```bash
24+
```console
2525
npm install eslint-webpack-plugin --save-dev
2626
```
2727

28+
or
29+
30+
```console
31+
yarn add -D install eslint-webpack-plugin
32+
```
33+
34+
or
35+
36+
```console
37+
pnpm add -D eslint-webpack-plugin
38+
```
39+
2840
**Note**: You also need to install `eslint >= 7` from npm, if you haven't already:
2941

30-
```bash
42+
```console
3143
npm install eslint --save-dev
3244
```
3345

46+
or
47+
48+
```console
49+
yarn add -D eslint
50+
```
51+
52+
or
53+
54+
```console
55+
pnpm add -D eslint
56+
```
57+
3458
Then add the plugin to your webpack config. For example:
3559

3660
```js
@@ -55,35 +79,60 @@ See the [eslint docs](https://eslint.org/docs/developer-guide/nodejs-api#-new-es
5579

5680
### `context`
5781

58-
- Type: `String`
82+
- Type:
83+
84+
```ts
85+
type context = string;
86+
```
87+
5988
- Default: `compiler.context`
6089

6190
A string indicating the root of your files.
6291

6392
### `eslintPath`
6493

65-
- Type: `String`
94+
- Type:
95+
96+
```ts
97+
type eslintPath = string;
98+
```
99+
66100
- Default: `eslint`
67101

68102
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 don't have to install `eslint`.
69103

70104
### `extensions`
71105

72-
- Type: `String|Array[String]`
106+
- Type:
107+
108+
```ts
109+
type extensions = string | Array<string>;
110+
```
111+
73112
- Default: `'js'`
74113

75114
Specify extensions that should be checked.
76115

77116
### `exclude`
78117

79-
- Type: `String|Array[String]`
118+
- Type:
119+
120+
```ts
121+
type exclude = string | Array<string>;
122+
```
123+
80124
- Default: `'node_modules'`
81125

82126
Specify the files and/or directories to exclude. Must be relative to `options.context`.
83127

84128
### `files`
85129

86-
- Type: `String|Array[String]`
130+
- Type:
131+
132+
```ts
133+
type files = string | Array<string>;
134+
```
135+
87136
- Default: `null`
88137

89138
Specify directories, files, or globs. Must be relative to `options.context`.
@@ -92,7 +141,12 @@ File and glob patterns ignore `options.extensions`.
92141

93142
### `fix`
94143

95-
- Type: `Boolean`
144+
- Type:
145+
146+
```ts
147+
type fix = boolean;
148+
```
149+
96150
- Default: `false`
97151

98152
Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nodejs-api#-eslintoutputfixesresults).
@@ -101,21 +155,39 @@ Will enable [ESLint autofix feature](https://eslint.org/docs/developer-guide/nod
101155

102156
### `formatter`
103157

104-
- Type: `String|Function`
158+
- Type:
159+
160+
```ts
161+
type formatter = string| (
162+
results: Array<import('eslint').ESLint.LintResult>,
163+
data?: import('eslint').ESLint.LintResultData | undefined
164+
) => string
165+
```
166+
105167
- Default: `'stylish'`
106168
107169
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/).
108170
109171
### `lintDirtyModulesOnly`
110172
111-
- Type: `Boolean`
173+
- Type:
174+
175+
```ts
176+
type lintDirtyModulesOnly = boolean;
177+
```
178+
112179
- Default: `false`
113180

114181
Lint only changed files, skip lint on start.
115182

116183
### `threads`
117184

118-
- Type: `Boolean | Number`
185+
- Type:
186+
187+
```ts
188+
type threads = boolean | number;
189+
```
190+
119191
- Default: `false`
120192

121193
Will run lint tasks across a thread pool. The pool size is automatic unless you specify a number.
@@ -127,42 +199,85 @@ You can still force this behavior by using `emitError` **or** `emitWarning` opti
127199

128200
#### `emitError`
129201

130-
- Type: `Boolean`
202+
- Type:
203+
204+
```ts
205+
type emitError = boolean;
206+
```
207+
131208
- Default: `true`
132209

133210
The errors found will always be emitted, to disable set to `false`.
134211

135212
#### `emitWarning`
136213

137-
- Type: `Boolean`
214+
- Type:
215+
216+
```ts
217+
type emitWarning = boolean;
218+
```
219+
138220
- Default: `true`
139221

140222
The warnings found will always be emitted, to disable set to `false`.
141223

142224
#### `failOnError`
143225

144-
- Type: `Boolean`
226+
- Type:
227+
228+
```ts
229+
type failOnError = boolean;
230+
```
231+
145232
- Default: `true`
146233

147234
Will cause the module build to fail if there are any errors, to disable set to `false`.
148235

149236
#### `failOnWarning`
150237

151-
- Type: `Boolean`
238+
- Type:
239+
240+
```ts
241+
type failOnWarning = boolean;
242+
```
243+
152244
- Default: `false`
153245

154246
Will cause the module build to fail if there are any warnings, if set to `true`.
155247

156248
#### `quiet`
157249

158-
- Type: `Boolean`
250+
- Type:
251+
252+
```ts
253+
type quiet = boolean;
254+
```
255+
159256
- Default: `false`
160257

161258
Will process and report errors only and ignore warnings, if set to `true`.
162259

163260
#### `outputReport`
164261

165-
- Type: `Boolean|Object`
262+
- Type:
263+
264+
```ts
265+
type outputReport =
266+
| boolean
267+
| {
268+
filePath?: string | undefined;
269+
formatter?:
270+
| (
271+
| string
272+
| ((
273+
results: Array<import('eslint').ESLint.LintResult>,
274+
data?: import('eslint').ESLint.LintResultData | undefined
275+
) => string)
276+
)
277+
| undefined;
278+
};
279+
```
280+
166281
- Default: `false`
167282

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

0 commit comments

Comments
 (0)