Skip to content
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

Allow skipping symlink patterns, to avoid raising a fault #15533

5 changes: 5 additions & 0 deletions changelog_unreleased/cli/15533.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#### Process files only supported by plugins (#15533 by @sanmai-NL)

In #14627, Prettier was redesigned to ‘no longer follow symbolic links’. However, the implementation went further and turned into a breaking change. Rather than adhering to the exit status contract of only returning a non-zero exit status when a file is not formatted or when something is wrong with Prettier itself, #14627 made Prettier return a non-zero exit status upon any pattern turning out to be a pointing to symlink.
fisker marked this conversation as resolved.
Show resolved Hide resolved

In case `--no-error-on-unmatched-pattern` is set, Prettier no longer always has a non-zero exit status if patterns match symlinks.
4 changes: 2 additions & 2 deletions src/cli/expand-patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ async function* expandPatternsInternal(context) {

const stat = await lstatSafe(absolutePath);
if (stat) {
if (stat.isSymbolicLink()) {
if (stat.isSymbolicLink() && context.argv.errorOnUnmatchedPattern !== false) {
yield {
error: `Explicitly specified pattern "${pattern}" is a symbolic link.`,
error: `Skipping pattern "${pattern}", as it points to a symbolic link.`,
};
fisker marked this conversation as resolved.
Show resolved Hide resolved
} else if (stat.isFile()) {
entries.push({
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/__tests__/patterns-dirs.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function isSymlinkSupported() {
status: 2,
stdout: "",
stderr:
'[error] Explicitly specified pattern "test-a/symlink-to-directory-a" is a symbolic link.',
'[error] Skipping pattern "test-a/symlink-to-directory-a", as it points to a symbolic link.',
},
base,
);
Expand All @@ -267,7 +267,7 @@ function isSymlinkSupported() {
status: 2,
stdout: "",
stderr:
'[error] Explicitly specified pattern "test-a/symlink-to-directory-b" is a symbolic link.',
'[error] Skipping pattern "test-a/symlink-to-directory-b", as it points to a symbolic link.',
},
base,
);
Expand All @@ -278,7 +278,7 @@ function isSymlinkSupported() {
status: 2,
stdout: "",
stderr:
'[error] Explicitly specified pattern "test-a/symlink-to-file-a" is a symbolic link.',
'[error] Skipping pattern "test-a/symlink-to-file-a", as it points to a symbolic link.',
},
base,
);
Expand All @@ -289,7 +289,7 @@ function isSymlinkSupported() {
status: 2,
stdout: "",
stderr:
'[error] Explicitly specified pattern "test-a/symlink-to-file-b" is a symbolic link.',
'[error] Skipping pattern "test-a/symlink-to-file-b", as it points to a symbolic link.',
},
base,
);
Expand All @@ -311,7 +311,7 @@ function isSymlinkSupported() {
status: 2,
stdout: "test-a/a.js",
stderr:
'[error] Explicitly specified pattern "test-a/symlink-to-file-b" is a symbolic link.',
'[error] Skipping pattern "test-a/symlink-to-file-b", as it points to a symbolic link.',
},
base,
);
Expand Down