Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to the "prettier-vscode" extension will be documented in thi

<!-- Check [Keep a Changelog](https://keepachangelog.com/) for recommendations on how to structure this file. -->

## [Unreleased]

- Support resolving paths starting with `~` under Unix and Windows

## [11.0.0]

- [BREAKING CHANGE] Prevent `.editorconfig` from satisfying the `requireConfig` setting (#2708) - Thanks to [@redoPop](https://github.com/redoPop)
Expand Down
8 changes: 2 additions & 6 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ export function getWorkspaceRelativePath(
filePath: string,
pathToResolve: string
) {
// In case the user wants to use ~/.prettierrc on Mac
if (
process.platform === "darwin" &&
pathToResolve.indexOf("~") === 0 &&
os.homedir()
) {
// In case the user wants to use path like `~/.prettierrc` on unix or `~\.prettierrc` on windows
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The word 'unix' should be capitalized as 'Unix' to match the capitalization of 'Windows' in the same sentence.

Suggested change
// In case the user wants to use path like `~/.prettierrc` on unix or `~\.prettierrc` on windows
// In case the user wants to use path like `~/.prettierrc` on Unix or `~\.prettierrc` on windows

Copilot uses AI. Check for mistakes.
if (pathToResolve.indexOf("~") === 0 && os.homedir()) {
return pathToResolve.replace(/^~(?=$|\/|\\)/, os.homedir());
Comment on lines +11 to 13
Copy link

Copilot AI Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tilde path resolution logic now supports Windows in addition to Unix systems, but lacks test coverage. Consider adding unit tests to verify: (1) tilde expansion works with Unix-style paths (~/.prettierrc), (2) tilde expansion works with Windows-style paths (~\.prettierrc), (3) tilde is not expanded when it appears mid-path, and (4) behavior when os.homedir() is empty.

Copilot uses AI. Check for mistakes.
}

Expand Down