diff --git a/packages/eslint-plugin-nx/src/utils/ast-utils.ts b/packages/eslint-plugin-nx/src/utils/ast-utils.ts index 9be4ff0ccf83d..996a4962569db 100644 --- a/packages/eslint-plugin-nx/src/utils/ast-utils.ts +++ b/packages/eslint-plugin-nx/src/utils/ast-utils.ts @@ -29,7 +29,7 @@ export function getBarrelEntryPointByImportScope( } export function getBarrelEntryPointProjectNode( - importScope: MappedProjectGraphNode + projectNode: MappedProjectGraphNode ): { path: string; importScope: string }[] | null { const tsConfigBase = tryReadBaseJson(); @@ -38,7 +38,10 @@ export function getBarrelEntryPointProjectNode( .filter((entry) => { const sourceFolderPaths = tsConfigBase.compilerOptions.paths[entry]; return sourceFolderPaths.some((sourceFolderPath) => { - return sourceFolderPath.includes(importScope.data.root); + return ( + sourceFolderPath === projectNode.data.sourceRoot || + sourceFolderPath.indexOf(`${projectNode.data.sourceRoot}/`) === 0 + ); }); }) .map((entry) =>