diff --git a/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts b/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts index b87b43626144a..846aa4d4cebab 100644 --- a/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts +++ b/packages/eslint-plugin/src/rules/enforce-module-boundaries.ts @@ -13,7 +13,7 @@ import { } from '@typescript-eslint/utils'; import { isBuiltinModuleImport } from '@nx/js/src/internal'; import { isRelativePath } from 'nx/src/utils/fileutils'; -import { basename, dirname, relative } from 'path'; +import { basename, dirname, join, relative } from 'path'; import { getBarrelEntryPointByImportScope, getBarrelEntryPointProjectNode, @@ -318,7 +318,7 @@ export default ESLintUtils.RuleCreator( for (const importMember of imports) { const importPath = getRelativeImportPath( importMember, - joinPathFragments(workspaceRoot, entryPointPath.path), + join(workspaceRoot, entryPointPath.path), sourceProject.data.sourceRoot ); // we cannot remap, so leave it as is @@ -419,7 +419,7 @@ export default ESLintUtils.RuleCreator( for (const importMember of imports) { const importPath = getRelativeImportPath( importMember, - joinPathFragments(workspaceRoot, entryPointPath), + join(workspaceRoot, entryPointPath), sourceProject.data.sourceRoot ); if (importPath) { diff --git a/packages/eslint-plugin/src/utils/ast-utils.ts b/packages/eslint-plugin/src/utils/ast-utils.ts index f212efcc26365..23ca93dea7ec3 100644 --- a/packages/eslint-plugin/src/utils/ast-utils.ts +++ b/packages/eslint-plugin/src/utils/ast-utils.ts @@ -1,5 +1,4 @@ import { - joinPathFragments, logger, ProjectGraphProjectNode, readJsonFile, @@ -8,12 +7,12 @@ import { import { findNodes } from '@nx/js'; import { getModifiers } from '@typescript-eslint/type-utils'; import { existsSync, lstatSync, readdirSync, readFileSync } from 'fs'; -import { dirname } from 'path'; +import { dirname, join } from 'path'; import ts = require('typescript'); function tryReadBaseJson() { try { - return readJsonFile(joinPathFragments(workspaceRoot, 'tsconfig.base.json')); + return readJsonFile(join(workspaceRoot, 'tsconfig.base.json')); } catch (e) { logger.warn(`Error reading "tsconfig.base.json": \n${JSON.stringify(e)}`); return null; @@ -126,7 +125,7 @@ export function getRelativeImportPath(exportedMember, filePath, basePath) { /^index\.[jt]sx?$/.exec(file) ); if (file) { - filePath = joinPathFragments(filePath, file); + filePath = join(filePath, file); } else { return; } @@ -252,35 +251,23 @@ export function getRelativeImportPath(exportedMember, filePath, basePath) { let moduleFilePath; if (modulePath.endsWith('.js') || modulePath.endsWith('.jsx')) { - moduleFilePath = joinPathFragments(dirname(filePath), modulePath); + moduleFilePath = join(dirname(filePath), modulePath); if (!existsSync(moduleFilePath)) { const tsifiedModulePath = modulePath.replace(/\.js(x?)$/, '.ts$1'); - moduleFilePath = joinPathFragments( - dirname(filePath), - `${tsifiedModulePath}` - ); + moduleFilePath = join(dirname(filePath), `${tsifiedModulePath}`); } } else if (modulePath.endsWith('.ts') || modulePath.endsWith('.tsx')) { - moduleFilePath = joinPathFragments(dirname(filePath), modulePath); + moduleFilePath = join(dirname(filePath), modulePath); } else { - moduleFilePath = joinPathFragments( - dirname(filePath), - `${modulePath}.ts` - ); + moduleFilePath = join(dirname(filePath), `${modulePath}.ts`); if (!existsSync(moduleFilePath)) { // might be a tsx file - moduleFilePath = joinPathFragments( - dirname(filePath), - `${modulePath}.tsx` - ); + moduleFilePath = join(dirname(filePath), `${modulePath}.tsx`); } } if (!existsSync(moduleFilePath)) { // might be an index.ts - moduleFilePath = joinPathFragments( - dirname(filePath), - `${modulePath}/index.ts` - ); + moduleFilePath = join(dirname(filePath), `${modulePath}/index.ts`); } if (hasMemberExport(exportedMember, moduleFilePath)) { diff --git a/packages/eslint-plugin/src/utils/runtime-lint-utils.ts b/packages/eslint-plugin/src/utils/runtime-lint-utils.ts index da080fc95b218..96f5355a39c0e 100644 --- a/packages/eslint-plugin/src/utils/runtime-lint-utils.ts +++ b/packages/eslint-plugin/src/utils/runtime-lint-utils.ts @@ -521,7 +521,7 @@ function getAngularEntryPoint(file: string, projectRoot: string): string { // we need to find closest existing ng-package.json // in order to determine if the file matches the secondary entry point const ngPackageContent = readFileIfExisting( - joinPathFragments(workspaceRoot, parent, 'ng-package.json') + path.join(workspaceRoot, parent, 'ng-package.json') ); if (ngPackageContent) { // https://github.com/ng-packagr/ng-packagr/blob/23c718d04eea85e015b4c261310b7bd0c39e5311/src/ng-package.schema.json#L54 @@ -539,18 +539,10 @@ function getAngularEntryPoint(file: string, projectRoot: string): string { export function appIsMFERemote(project: ProjectGraphProjectNode): boolean { const mfeConfig = readFileIfExisting( - joinPathFragments( - workspaceRoot, - project.data.root, - 'module-federation.config.js' - ) + path.join(workspaceRoot, project.data.root, 'module-federation.config.js') ) || readFileIfExisting( - joinPathFragments( - workspaceRoot, - project.data.root, - 'module-federation.config.ts' - ) + path.join(workspaceRoot, project.data.root, 'module-federation.config.ts') ); if (mfeConfig) {