From 16f1a3aa9bce7c05a615b78ce1c6850d2bead75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20V=C3=A1clavek?= <49518842+david-vaclavek@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:54:45 +0100 Subject: [PATCH 1/2] fix: undefined `context.filename` for inline lint --- src/rules/alias.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/rules/alias.ts b/src/rules/alias.ts index f7b9350..a3710e9 100644 --- a/src/rules/alias.ts +++ b/src/rules/alias.ts @@ -112,7 +112,9 @@ const rule = { ); if (!isPathInImport) return; - const filename = context.filename; + const fullFilePath = context.getFilename(); + const cwd = context.getCwd(); + const filename = path.relative(cwd, fullFilePath); const resolvedIgnoredPaths = ignoredPaths.map((ignoredPath) => path.normalize(path.join(path.dirname(filename), ignoredPath)), From 5e4f362fa81134070904b6be95a18857d02fcbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20V=C3=A1clavek?= <49518842+david-vaclavek@users.noreply.github.com> Date: Fri, 13 Dec 2024 14:11:06 +0100 Subject: [PATCH 2/2] Update alias.ts Fallback to current behavior --- src/rules/alias.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rules/alias.ts b/src/rules/alias.ts index a3710e9..74877be 100644 --- a/src/rules/alias.ts +++ b/src/rules/alias.ts @@ -112,9 +112,12 @@ const rule = { ); if (!isPathInImport) return; - const fullFilePath = context.getFilename(); - const cwd = context.getCwd(); - const filename = path.relative(cwd, fullFilePath); + let filename = context.filename; + if (typeof filename === 'undefined') { + const fullFilePath = context.getFilename(); + const cwd = context.getCwd(); + filename = path.relative(cwd, fullFilePath); + } const resolvedIgnoredPaths = ignoredPaths.map((ignoredPath) => path.normalize(path.join(path.dirname(filename), ignoredPath)),