Skip to content

Commit 8f49d3e

Browse files
authored
docs: improve documentation of issue option (#551)
Closes: #548
1 parent 2a1348d commit 8f49d3e

File tree

1 file changed

+44
-6
lines changed

1 file changed

+44
-6
lines changed

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,51 @@ Options for the ESLint linter (`eslint` option object).
187187

188188
### Issues options
189189

190-
Options for the issues filtering (`issues` option object).
190+
Options for the issues filtering (`issue` option object).
191+
I could write some plain text explanation of these options but I think code will explain it better:
191192

192-
| Name | Type | Default value | Description |
193-
| --------- | --------------------------------- | ------------- | ----------- |
194-
| `include` | `object` or `function` or `array` | `undefined` | If `object`, defines issue properties that should be [matched](./src/issue/IssueMatch.ts). If `function`, acts as a predicate where `issue` is an argument. |
195-
| `exclude` | `object` or `function` or `array` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
196-
| `scope` | `'all'` or `'webpack'` | `'webpack'` | Defines issues scope to be reported. If `'webpack'`, reports errors only related to the webpack compilation. Reports all errors otherwise (like `tsc` and `eslint` command). |
193+
```typescript
194+
interface Issue {
195+
origin: 'typescript' | 'eslint';
196+
severity: 'error' | 'warning';
197+
code: string;
198+
file?: string;
199+
}
200+
201+
type IssueMatch = Partial<Issue>; // file field supports glob matching
202+
type IssuePredicate = (issue: Issue) => boolean;
203+
type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[];
204+
```
205+
206+
| Name | Type | Default value | Description |
207+
| --------- | ------------- | ------------- | ----------- |
208+
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](./src/issue/IssueMatch.ts). If `function`, acts as a predicate where `issue` is an argument. |
209+
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
210+
211+
<details>
212+
<summary>Expand example</summary>
213+
214+
Include issues from the `src` directory, exclude eslint issues from `.spec.ts` files:
215+
216+
```js
217+
module.exports = {
218+
// ...the webpack configuration
219+
plugins: [
220+
new ForkTsCheckerWebpackPlugin({
221+
issue: {
222+
include: [
223+
{ file: '**/src/**/*' }
224+
],
225+
exclude: [
226+
{ origin: 'eslint', file: '**/*.spec.ts' }
227+
]
228+
}
229+
})
230+
]
231+
};
232+
```
233+
234+
</details>
197235

198236
## Vue.js
199237

0 commit comments

Comments
 (0)