oxlint-harness 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,7 @@ import { SuppressionFile, ProcessedDiagnostic, ExcessError } from "./types.js";
|
|
|
2
2
|
export declare class SuppressionManager {
|
|
3
3
|
private suppressionFile;
|
|
4
4
|
constructor(suppressionFile?: string);
|
|
5
|
+
private sortSuppressions;
|
|
5
6
|
loadSuppressions(): SuppressionFile;
|
|
6
7
|
saveSuppressions(suppressions: SuppressionFile): void;
|
|
7
8
|
generateSuppressions(diagnostics: ProcessedDiagnostic[]): SuppressionFile;
|
|
@@ -4,6 +4,20 @@ export class SuppressionManager {
|
|
|
4
4
|
constructor(suppressionFile = ".oxlint-suppressions.json") {
|
|
5
5
|
this.suppressionFile = suppressionFile;
|
|
6
6
|
}
|
|
7
|
+
sortSuppressions(suppressions) {
|
|
8
|
+
const sorted = {};
|
|
9
|
+
const sortedFilenames = Object.keys(suppressions).sort();
|
|
10
|
+
for (const filename of sortedFilenames) {
|
|
11
|
+
const rules = suppressions[filename];
|
|
12
|
+
const sortedRules = {};
|
|
13
|
+
const sortedRuleNames = Object.keys(rules).sort();
|
|
14
|
+
for (const ruleName of sortedRuleNames) {
|
|
15
|
+
sortedRules[ruleName] = rules[ruleName];
|
|
16
|
+
}
|
|
17
|
+
sorted[filename] = sortedRules;
|
|
18
|
+
}
|
|
19
|
+
return sorted;
|
|
20
|
+
}
|
|
7
21
|
loadSuppressions() {
|
|
8
22
|
if (!existsSync(this.suppressionFile)) {
|
|
9
23
|
return {};
|
|
@@ -18,7 +32,8 @@ export class SuppressionManager {
|
|
|
18
32
|
}
|
|
19
33
|
saveSuppressions(suppressions) {
|
|
20
34
|
try {
|
|
21
|
-
const
|
|
35
|
+
const sorted = this.sortSuppressions(suppressions);
|
|
36
|
+
const content = JSON.stringify(sorted, null, 2);
|
|
22
37
|
writeFileSync(this.suppressionFile, content, "utf8");
|
|
23
38
|
}
|
|
24
39
|
catch (error) {
|
|
@@ -44,7 +59,7 @@ export class SuppressionManager {
|
|
|
44
59
|
suppressions[filename][rule] = { count };
|
|
45
60
|
}
|
|
46
61
|
}
|
|
47
|
-
return suppressions;
|
|
62
|
+
return this.sortSuppressions(suppressions);
|
|
48
63
|
}
|
|
49
64
|
findExcessErrors(diagnostics, suppressions) {
|
|
50
65
|
const excessErrors = [];
|
|
@@ -91,7 +106,7 @@ export class SuppressionManager {
|
|
|
91
106
|
delete updated[filename];
|
|
92
107
|
}
|
|
93
108
|
}
|
|
94
|
-
return updated;
|
|
109
|
+
return this.sortSuppressions(updated);
|
|
95
110
|
}
|
|
96
111
|
tightenSuppressions(currentSuppressions, diagnostics) {
|
|
97
112
|
// Group diagnostics by file and rule to get actual counts
|
|
@@ -132,6 +147,6 @@ export class SuppressionManager {
|
|
|
132
147
|
tightened[filename] = fileRules;
|
|
133
148
|
}
|
|
134
149
|
}
|
|
135
|
-
return tightened;
|
|
150
|
+
return this.sortSuppressions(tightened);
|
|
136
151
|
}
|
|
137
152
|
}
|