From 4b5357da7e2ece404001e8422ed3168c54ad86c4 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Tue, 28 Mar 2023 02:16:43 -0700 Subject: [PATCH] Allow relative import from package root inside of top-level fb folder Reviewed By: LukeDefeo Differential Revision: D44415645 fbshipit-source-id: d19c5144f9ee374cde0727f93f583552664bc806 --- .../src/rules/noRelativeImportsAcrossPackages.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/desktop/eslint-plugin-flipper/src/rules/noRelativeImportsAcrossPackages.tsx b/desktop/eslint-plugin-flipper/src/rules/noRelativeImportsAcrossPackages.tsx index 81355a10b..e13a4c054 100644 --- a/desktop/eslint-plugin-flipper/src/rules/noRelativeImportsAcrossPackages.tsx +++ b/desktop/eslint-plugin-flipper/src/rules/noRelativeImportsAcrossPackages.tsx @@ -18,7 +18,15 @@ function findRootDir(path: string): string { if (cachedRoot) { return cachedRoot; } - if (fs.pathExistsSync(join(path, 'package.json'))) { + // Our public packages have the following structure: + // - package + // - fb + // - package.json + // - pacakage.json + // package.json insode of fb folder is not a real root. It is merely an add-on for the root package.json for internal builds. + // We should ignore package.json inside of "fb" folder and allow relative imports from the root inside of the fb folder. + const fbFolder = path.endsWith('fb') || path.endsWith('fb/'); + if (!fbFolder && fs.pathExistsSync(join(path, 'package.json'))) { rootDirs.set(path, path); return path; }