Skip to content

Commit

Permalink
fix(utils): RuleTester: Only call afterAll if defined (#4656)
Browse files Browse the repository at this point in the history
* fix(utils): RuleTester: Only call afterAll if defined

* Prettier
  • Loading branch information
ArnaudBarre committed Mar 18, 2022
1 parent dd49280 commit 0fe0683
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/utils/src/eslint-utils/RuleTester.ts
Expand Up @@ -28,16 +28,18 @@ class RuleTester extends TSESLint.RuleTester {

// make sure that the parser doesn't hold onto file handles between tests
// on linux (i.e. our CI env), there can be very a limited number of watch handles available
afterAll(() => {
try {
// instead of creating a hard dependency, just use a soft require
// a bit weird, but if they're using this tooling, it'll be installed
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
require(parser).clearCaches();
} catch {
// ignored
}
});
if (typeof afterAll !== 'undefined') {
afterAll(() => {
try {
// instead of creating a hard dependency, just use a soft require
// a bit weird, but if they're using this tooling, it'll be installed
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
require(parser).clearCaches();
} catch {
// ignored
}
});
}
}
private getFilename(options?: TSESLint.ParserOptions): string {
if (options) {
Expand Down

0 comments on commit 0fe0683

Please sign in to comment.