-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected Behavior in Prettier 3.0.3: Attempts to Format Files Outside of Project Directory #15431
Comments
Possible cased by #15001, but seems the new behavior is expected? The original pattern is like |
Possibly, I'd call it a breaking change then. But I don't think traversing the entirety of my file system should ever really be the expected behavior. That said, I'm not sure how I'd effectively limit the scope, but I just think it's dangerous that prettier could technically change files some place completely different (even if prettier attempts to not make destructive changes). I might not even have the option to roll back the changes if it happens outside my git repository. |
Your concern make sense. Maybe we can throw errors when CLI try to format files above |
Yeah. I don't really see when you'd expect prettier to run outside your So I think your suggestion sounds reasonable enough. |
It makes sense when Prettier is installed globally or ran via |
Prettier 3.0.3
# Options: --single-quote --trailing-comma es5 --semi --end-of-line lf --tab-width 2
Note: The bug was confirmed to occur even with no Prettier options specified.
Input:
prettier --write '{,src}/**/*.{ts,tsx,js,json}'
Output:
Expected behavior:
When using a glob pattern that specifies both the root directory (using an empty string) and a subdirectory (e.g.
src
), Prettier should only attempt to format files within the specified project or directory. It should not attempt to access or format files outside the project's directory, especially system directories like/lost+found
.Additional Information:
src/**/*.{ts,tsx,js,json}
fixed the problem on my end.The text was updated successfully, but these errors were encountered: