Closed Bug 1564824 Opened 3 years ago Closed 3 years ago

Format source fails with Prettier on patches with moved files where the original directory also does not exist

Categories

(Firefox Build System :: Lint and Formatting, task)

task
Not set
normal

Tracking

(firefox70 fixed)

RESOLVED FIXED
mozilla70
Tracking Status
firefox70 --- fixed

People

(Reporter: vporof, Assigned: vporof)

References

Details

Attachments

(1 file)

For example, https://phabricator.services.mozilla.com/D37457

With --stdin-filepath, Prettier still attempts to look for a configuration file in the directory containing the specified "virtual" file path. With file renames or usual file moves, this problem doesn't manifest itself since the parent directory still exists. However, when the whole original directory is moved or doesn't exist anymore, Prettier fails internally. This looks like a bug inside Prettier and confirmed by the returned code 2.

I've attempted to work around this by forcing Prettier to not look for configuration files, with a combination of --config-precedence and --config params, with no success. Prettier seems to either ignore those or simply always check for a configuration file regardless of those params, as long as --stdin-filepath is passed, in the directory "containing" this "virtual" file path.

We can however also work around this by checking if the "virtual" file path for stdin actually exists or not. This seems to fix the problem and Prettier doesn't fail internally anymore with status code 2, and the merge completes successfully.

Assignee: nobody → vporof
Status: NEW → ASSIGNED
Pushed by vporof@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/ec2818ee17f7
Format source fails with Prettier on patches with moved files where the original directory also does not exist, r=andi
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla70
You need to log in before you can comment on or make changes to this bug.