From e93bc4fc130c4634a09e2d30652d8ddaad59700f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 26 Jan 2024 10:12:50 +0100 Subject: [PATCH] eslint-plugin: fix tests not restoring cwd Signed-off-by: Patrik Oldsberg --- .../eslint-plugin/src/no-forbidden-package-imports.test.ts | 5 +++++ .../eslint-plugin/src/no-relative-monorepo-imports.test.ts | 5 +++++ packages/eslint-plugin/src/no-undeclared-imports.test.ts | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/packages/eslint-plugin/src/no-forbidden-package-imports.test.ts b/packages/eslint-plugin/src/no-forbidden-package-imports.test.ts index 349b71319f..c46f82f4fc 100644 --- a/packages/eslint-plugin/src/no-forbidden-package-imports.test.ts +++ b/packages/eslint-plugin/src/no-forbidden-package-imports.test.ts @@ -25,6 +25,11 @@ const ERR = (name: string, path: string) => ({ message: `${name} does not export ${path}`, }); +// cwd must be restored +const origDir = process.cwd(); +afterAll(() => { + process.chdir(origDir); +}); process.chdir(FIXTURE); const ruleTester = new RuleTester({ diff --git a/packages/eslint-plugin/src/no-relative-monorepo-imports.test.ts b/packages/eslint-plugin/src/no-relative-monorepo-imports.test.ts index 6888d258cc..31e1674b76 100644 --- a/packages/eslint-plugin/src/no-relative-monorepo-imports.test.ts +++ b/packages/eslint-plugin/src/no-relative-monorepo-imports.test.ts @@ -28,6 +28,11 @@ const ERR_FORBIDDEN = (newImp: string) => ({ message: `Relative imports of monorepo packages are forbidden, use '${newImp}' instead`, }); +// cwd must be restored +const origDir = process.cwd(); +afterAll(() => { + process.chdir(origDir); +}); process.chdir(FIXTURE); const ruleTester = new RuleTester({ diff --git a/packages/eslint-plugin/src/no-undeclared-imports.test.ts b/packages/eslint-plugin/src/no-undeclared-imports.test.ts index e92d422057..29e2c3a87c 100644 --- a/packages/eslint-plugin/src/no-undeclared-imports.test.ts +++ b/packages/eslint-plugin/src/no-undeclared-imports.test.ts @@ -53,6 +53,11 @@ const ERR_SWITCH_BACK = () => ({ message: 'Switch back to import declaration', }); +// cwd must be restored +const origDir = process.cwd(); +afterAll(() => { + process.chdir(origDir); +}); process.chdir(FIXTURE); const ruleTester = new RuleTester({