Skip to content

Commit 1b7ab85

Browse files
authored
docs: improve issue options documentation in README (#52)
1 parent 4d47a5b commit 1b7ab85

1 file changed

Lines changed: 26 additions & 17 deletions

File tree

README.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,45 +119,54 @@ Options for the TypeScript checker (`typescript` option object).
119119
### Issues options
120120

121121
Options for the issues filtering (`issue` option object).
122-
I could write some plain text explanation of these options but I think code will explain it better:
122+
123+
- **Type**:
123124

124125
```typescript
126+
interface IssueOptions {
127+
include?: IssuePredicateOption;
128+
exclude?: IssuePredicateOption;
129+
}
130+
125131
interface Issue {
126132
severity: 'error' | 'warning';
127133
code: string;
134+
// file field supports glob matching
128135
file?: string;
129136
}
130137

131-
type IssueMatch = Partial<Issue>; // file field supports glob matching
138+
type IssueMatch = Partial<Issue>;
132139
type IssuePredicate = (issue: Issue) => boolean;
133-
type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[];
140+
type IssuePredicateOption = IssuePredicate | IssueMatch | (IssuePredicate | IssueMatch)[];
134141
```
135142

136143
| Name | Type | Default value | Description |
137144
| --------- | ------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
138145
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](src/issue/issue-match.ts). If `function`, acts as a predicate where `issue` is an argument. |
139146
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
140147

141-
<details>
142-
<summary>Expand example</summary>
148+
- **Example**:
143149

144150
Include issues from the `src` directory, exclude issues from `.spec.ts` files:
145151

146152
```js
147-
module.exports = {
148-
// ...the Rspack configuration
149-
plugins: [
150-
new TsCheckerRspackPlugin({
151-
issue: {
152-
include: [{ file: '**/src/**/*' }],
153-
exclude: [{ file: '**/*.spec.ts' }],
154-
},
155-
}),
156-
],
157-
};
153+
new TsCheckerRspackPlugin({
154+
issue: {
155+
include: [{ file: '**/src/**/*' }],
156+
exclude: [{ file: '**/*.spec.ts' }],
157+
},
158+
});
158159
```
159160

160-
</details>
161+
Exclude files under `/node_modules/` using `file:`:
162+
163+
```js
164+
new TsCheckerRspackPlugin({
165+
issue: {
166+
exclude: [({ file = '' }) => /[\\/]some-folder[\\/]/.test(file)],
167+
},
168+
});
169+
```
161170

162171
## Plugin hooks
163172

0 commit comments

Comments
 (0)