diff --git a/lib/rules/no-manual-cleanup.ts b/lib/rules/no-manual-cleanup.ts index 833fa147..3313c420 100644 --- a/lib/rules/no-manual-cleanup.ts +++ b/lib/rules/no-manual-cleanup.ts @@ -111,15 +111,12 @@ export default createTestingLibraryRule({ return { 'Program:exit'() { const testingLibraryImportName = helpers.getTestingLibraryImportName(); - const testingLibraryImportNode = helpers.getTestingLibraryImportNode(); const customModuleImportNode = helpers.getCustomModuleImportNode(); - if ( - testingLibraryImportName && - testingLibraryImportNode && - testingLibraryImportName.match(CLEANUP_LIBRARY_REGEXP) - ) { - reportCandidateModule(testingLibraryImportNode); + if (testingLibraryImportName?.match(CLEANUP_LIBRARY_REGEXP)) { + for (const importNode of helpers.getAllTestingLibraryImportNodes()) { + reportCandidateModule(importNode); + } } if (customModuleImportNode) { diff --git a/tests/lib/rules/no-manual-cleanup.test.ts b/tests/lib/rules/no-manual-cleanup.test.ts index 0b22ce6a..61208801 100644 --- a/tests/lib/rules/no-manual-cleanup.test.ts +++ b/tests/lib/rules/no-manual-cleanup.test.ts @@ -235,5 +235,22 @@ ruleTester.run(RULE_NAME, rule, { ], } as const) ), + ...ALL_TESTING_LIBRARIES_WITH_CLEANUP.map( + (lib) => + ({ + code: ` + import { render } from "${lib}"; + import { cleanup } from "${lib}"; + afterEach(cleanup); + `, + errors: [ + { + line: 3, + column: 18, + messageId: 'noManualCleanup', + }, + ], + } as const) + ), ], });