Skip to content

Commit

Permalink
Fix duplicate suppressions and add documentation for extendVerifyFunc…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
iclanton committed Mar 20, 2024
1 parent d8dff54 commit c199086
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
Expand Down Expand Up @@ -50,11 +45,6 @@
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
Expand All @@ -70,11 +60,6 @@
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
Expand All @@ -85,11 +70,6 @@
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
Expand Down Expand Up @@ -120,11 +100,6 @@
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
Expand Down Expand Up @@ -50,11 +45,6 @@
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
Expand All @@ -70,11 +60,6 @@
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
Expand All @@ -85,11 +70,6 @@
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
Expand Down Expand Up @@ -120,11 +100,6 @@
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".",
"rule": "prefer-const"
},
{
"file": "src/index.ts",
"scopeId": ".ExampleClass",
Expand Down Expand Up @@ -50,11 +45,6 @@
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
"rule": "@typescript-eslint/typedef"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass",
Expand All @@ -70,11 +60,6 @@
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
Expand All @@ -85,11 +70,6 @@
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleAnonymousClass.exampleSetGet",
"rule": "@typescript-eslint/explicit-member-accessibility"
},
{
"file": "src/index.ts",
"scopeId": ".exampleArrowFunction",
Expand Down Expand Up @@ -120,11 +100,6 @@
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
"rule": "@typescript-eslint/ban-types"
},
{
"file": "src/index.ts",
"scopeId": ".exampleFunction",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ export function patchClass<T, U extends T>(originalClass: new () => T, patchedCl
}
}

/**
* This returns a wrapped version of the "verify" function from ESLint's Linter class
* that postprocesses rule violations that weren't suppressed by comments. This postprocessing
* records suppressions that weren't otherwise suppressed by comments to be used
* by the "suppress" and "prune" commands.
*/
export function extendVerifyFunction(
originalFn: (this: unknown, ...args: unknown[]) => IProblem[] | undefined
): (this: unknown, ...args: unknown[]) => IProblem[] | undefined {
Expand All @@ -341,9 +347,11 @@ export function extendVerifyFunction(
newJsonObject: { suppressions: newSuppressions }
}
} = problem[SUPPRESSION_SYMBOL];
newSerializedSuppressions.add(serializedSuppression);
suppressions.push(suppression);
newSuppressions.push(suppression);
if (!newSerializedSuppressions.has(serializedSuppression)) {
newSerializedSuppressions.add(serializedSuppression);
newSuppressions.push(suppression);
suppressions.push(suppression);
}
}
}
}
Expand Down

0 comments on commit c199086

Please sign in to comment.