fix(linter): ensure fs operations run on full path (#12953)
This commit is contained in:
parent
4ca743ea54
commit
c3db8e6070
@ -248,7 +248,7 @@ export default createESLintRule<Options, MessageIds>({
|
||||
for (const importMember of imports) {
|
||||
const importPath = getRelativeImportPath(
|
||||
importMember,
|
||||
entryPointPath.path,
|
||||
joinPathFragments(workspaceRoot, entryPointPath.path),
|
||||
sourceProject.data.sourceRoot
|
||||
);
|
||||
// we cannot remap, so leave it as is
|
||||
@ -322,7 +322,7 @@ export default createESLintRule<Options, MessageIds>({
|
||||
for (const importMember of imports) {
|
||||
const importPath = getRelativeImportPath(
|
||||
importMember,
|
||||
entryPointPath,
|
||||
joinPathFragments(workspaceRoot, entryPointPath),
|
||||
sourceProject.data.sourceRoot
|
||||
);
|
||||
if (importPath) {
|
||||
|
||||
@ -7,8 +7,7 @@ import { findNodes } from '@nrwl/workspace/src/utilities/typescript';
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { dirname } from 'path';
|
||||
import ts = require('typescript');
|
||||
import { logger } from '@nrwl/devkit';
|
||||
import { workspaceRoot } from '@nrwl/devkit';
|
||||
import { logger, workspaceRoot } from '@nrwl/devkit';
|
||||
|
||||
function tryReadBaseJson() {
|
||||
try {
|
||||
@ -200,14 +199,12 @@ export function getRelativeImportPath(exportedMember, filePath, basePath) {
|
||||
const modulePath = (exportDeclaration as any).moduleSpecifier.text;
|
||||
|
||||
let moduleFilePath = joinPathFragments(
|
||||
'./',
|
||||
dirname(filePath),
|
||||
`${modulePath}.ts`
|
||||
);
|
||||
if (!existsSync(moduleFilePath)) {
|
||||
// might be a index.ts
|
||||
moduleFilePath = joinPathFragments(
|
||||
'./',
|
||||
dirname(filePath),
|
||||
`${modulePath}/index.ts`
|
||||
);
|
||||
|
||||
@ -437,7 +437,9 @@ export function isAngularSecondaryEntrypoint(
|
||||
// The `ng-packagr` defaults to the `src/public_api.ts` entry file to
|
||||
// the public API if the `lib.entryFile` is not specified explicitly.
|
||||
(file.endsWith('src/public_api.ts') || file.endsWith('src/index.ts')) &&
|
||||
existsSync(joinPathFragments(file, '../../', 'ng-package.json'))
|
||||
existsSync(
|
||||
joinPathFragments(workspaceRoot, file, '../../', 'ng-package.json')
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user