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) {
|
for (const importMember of imports) {
|
||||||
const importPath = getRelativeImportPath(
|
const importPath = getRelativeImportPath(
|
||||||
importMember,
|
importMember,
|
||||||
entryPointPath.path,
|
joinPathFragments(workspaceRoot, entryPointPath.path),
|
||||||
sourceProject.data.sourceRoot
|
sourceProject.data.sourceRoot
|
||||||
);
|
);
|
||||||
// we cannot remap, so leave it as is
|
// we cannot remap, so leave it as is
|
||||||
@ -322,7 +322,7 @@ export default createESLintRule<Options, MessageIds>({
|
|||||||
for (const importMember of imports) {
|
for (const importMember of imports) {
|
||||||
const importPath = getRelativeImportPath(
|
const importPath = getRelativeImportPath(
|
||||||
importMember,
|
importMember,
|
||||||
entryPointPath,
|
joinPathFragments(workspaceRoot, entryPointPath),
|
||||||
sourceProject.data.sourceRoot
|
sourceProject.data.sourceRoot
|
||||||
);
|
);
|
||||||
if (importPath) {
|
if (importPath) {
|
||||||
|
|||||||
@ -7,8 +7,7 @@ import { findNodes } from '@nrwl/workspace/src/utilities/typescript';
|
|||||||
import { existsSync, readFileSync } from 'fs';
|
import { existsSync, readFileSync } from 'fs';
|
||||||
import { dirname } from 'path';
|
import { dirname } from 'path';
|
||||||
import ts = require('typescript');
|
import ts = require('typescript');
|
||||||
import { logger } from '@nrwl/devkit';
|
import { logger, workspaceRoot } from '@nrwl/devkit';
|
||||||
import { workspaceRoot } from '@nrwl/devkit';
|
|
||||||
|
|
||||||
function tryReadBaseJson() {
|
function tryReadBaseJson() {
|
||||||
try {
|
try {
|
||||||
@ -200,14 +199,12 @@ export function getRelativeImportPath(exportedMember, filePath, basePath) {
|
|||||||
const modulePath = (exportDeclaration as any).moduleSpecifier.text;
|
const modulePath = (exportDeclaration as any).moduleSpecifier.text;
|
||||||
|
|
||||||
let moduleFilePath = joinPathFragments(
|
let moduleFilePath = joinPathFragments(
|
||||||
'./',
|
|
||||||
dirname(filePath),
|
dirname(filePath),
|
||||||
`${modulePath}.ts`
|
`${modulePath}.ts`
|
||||||
);
|
);
|
||||||
if (!existsSync(moduleFilePath)) {
|
if (!existsSync(moduleFilePath)) {
|
||||||
// might be a index.ts
|
// might be a index.ts
|
||||||
moduleFilePath = joinPathFragments(
|
moduleFilePath = joinPathFragments(
|
||||||
'./',
|
|
||||||
dirname(filePath),
|
dirname(filePath),
|
||||||
`${modulePath}/index.ts`
|
`${modulePath}/index.ts`
|
||||||
);
|
);
|
||||||
|
|||||||
@ -437,7 +437,9 @@ export function isAngularSecondaryEntrypoint(
|
|||||||
// The `ng-packagr` defaults to the `src/public_api.ts` entry file to
|
// The `ng-packagr` defaults to the `src/public_api.ts` entry file to
|
||||||
// the public API if the `lib.entryFile` is not specified explicitly.
|
// the public API if the `lib.entryFile` is not specified explicitly.
|
||||||
(file.endsWith('src/public_api.ts') || file.endsWith('src/index.ts')) &&
|
(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