1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | Object.defineProperty(exports, "__esModule", { value: true });
|
16 | const model_1 = require("../model/model");
|
17 | const minimatch = require("minimatch");
|
18 | class WarningFilter {
|
19 | constructor(options) {
|
20 | this.warningCodesToIgnore = new Set();
|
21 | this.minimumSeverity = model_1.Severity.INFO;
|
22 | this.fileGlobsToFilterOut = [];
|
23 | if (options.warningCodesToIgnore) {
|
24 | this.warningCodesToIgnore = options.warningCodesToIgnore;
|
25 | }
|
26 | if (options.minimumSeverity != null) {
|
27 | this.minimumSeverity = options.minimumSeverity;
|
28 | }
|
29 | if (options.filesToIgnore) {
|
30 | this.fileGlobsToFilterOut =
|
31 | (options.filesToIgnore ||
|
32 | []).map((glob) => new minimatch.Minimatch(glob, {}));
|
33 | }
|
34 | }
|
35 | shouldIgnore(warning) {
|
36 | if (this.warningCodesToIgnore.has(warning.code)) {
|
37 | return true;
|
38 | }
|
39 | if (warning.severity > this.minimumSeverity) {
|
40 | return true;
|
41 | }
|
42 | for (const glob of this.fileGlobsToFilterOut) {
|
43 | if (glob.match(warning.sourceRange.file)) {
|
44 | return true;
|
45 | }
|
46 | }
|
47 | return false;
|
48 | }
|
49 | }
|
50 | exports.WarningFilter = WarningFilter;
|
51 |
|
\ | No newline at end of file |