Skip to content

Commit ae38310

Browse files
authored
Linter: Move path to CLI-only bundle (#1352)
This pull request moves the `fileUrl` helpers to a new file `src/cli/file-url.ts` in the linter package, so that the import to `"node:path"` is only within the CLI and not leaking to the web/browser bundle of the linter.
1 parent e960c31 commit ae38310

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { resolve } from "node:path"
2+
3+
export function fileUrl(filePath: string): string {
4+
const absolutePath = resolve(filePath)
5+
return `file://${absolutePath}`
6+
}

javascript/packages/linter/src/cli/formatters/detailed-formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { colorize, Highlighter, type ThemeInput, DEFAULT_THEME } from "@herb-too
22

33
import { BaseFormatter } from "./base-formatter.js"
44
import { LineWrapper } from "@herb-tools/highlighter"
5-
import { ruleDocumentationUrl, fileUrl } from "../../urls.js"
5+
import { ruleDocumentationUrl } from "../../urls.js"
6+
import { fileUrl } from "../file-url.js"
67

78
import type { Diagnostic } from "@herb-tools/core"
89
import type { ProcessedFile } from "../file-processor.js"

javascript/packages/linter/src/cli/formatters/simple-formatter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { colorize, hyperlink, TextFormatter } from "@herb-tools/highlighter"
22

33
import { BaseFormatter } from "./base-formatter.js"
4-
import { ruleDocumentationUrl, fileUrl } from "../../urls.js"
4+
import { ruleDocumentationUrl } from "../../urls.js"
5+
import { fileUrl } from "../file-url.js"
56

67
import type { Diagnostic } from "@herb-tools/core"
78
import type { ProcessedFile } from "../file-processor.js"
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
import { resolve } from "node:path"
2-
31
const DOCS_BASE_URL = "https://herb-tools.dev/linter/rules"
42

53
export function ruleDocumentationUrl(ruleId: string): string {
64
return `${DOCS_BASE_URL}/${ruleId}`
75
}
8-
9-
export function fileUrl(filePath: string): string {
10-
const absolutePath = resolve(filePath)
11-
return `file://${absolutePath}`
12-
}

0 commit comments

Comments
 (0)