Align front-matter linter with prettier #27828
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
The front-matter linter and Prettier are correcting each other and are causing some friction.
Problem
Formatters available in YAML space output exactly what is told, so the output remains same no matter the input. But Prettier is an intelligent formatter: it's output changes based on certain conditions.
In following examples YAML parser and Prettier have been told to prefer double quotes to enclose values.
Solution
It's easy to simply run YAML formatter's output through Prettier before writing to file, than making the YAML formatter behave like Prettier:
Note: apart from above change following changes have been made:
updated and added unit tests
yarn test:front-matter-linter
ran
fix:js
on all the.js
files in the repo to confrom to the new Prettier v3.0.0The
*.md
files need to be committed before this PR are in Prettier style front-matter #27830Testing
/files/en-us/web/javascript/**/*.md
line in.prettierignore
filefix:fm
then committed the changesPrettier didn't contradict front-matter linter.