-
Notifications
You must be signed in to change notification settings - Fork 22.5k
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
Lint front-matter using the work in progress fmlinter #26174
Conversation
679cf88
to
724da7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
* Lint front-matter using the work in progress fmlinter * Fix lint errors caused by husky
@@ -1,5 +1,5 @@ | |||
--- | |||
title: 'SyntaxError: invalid regular expression flag "x"' | |||
title: "SyntaxError: invalid regular expression flag \"x\"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @OnkarRuikar I've just noticed that this change is not compatible with Prettier, which optimizes the number of escaped quotes. Just FYI—we will eventually need to accommodate Prettier style.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @OnkarRuikar I've just noticed that this change is not compatible with Prettier, which optimizes the number of escaped quotes. Just FYI—we will eventually need to accommodate Prettier style.
There is no point in using two tools for indenting the front-matter: there will be multiple mismatches like this in future.
Our validator can reorder the attributes, which the Prettier can’t. When our validator dumps(serialises) the corrected output it is going to indent the YAML by js-yaml
’s rules, and they are not as flexible; we’ll have to use Prettier in the tool to reindent the YAML :(
We have 3 options:
a) Disable front-matter linting in Prettier. Can we disable the front-matter part in Prettier using some config option(not magic comments)?
b) Use Prettier in our validator to reindent the front-matter before writing to file.
c) If possible, write a Prettier plugin that will do the validations and formatting of front-matter that we want.
d) do nothing, as husky hook for our validator will auto format files before commit. Prettier will keep nagging though.
Also, in Prettier can we have infinite line length for YAML and 80 for rest of the content? Because there is going to be the same issue as discussed/voted here.
Option b) is dirty but the quickest of all. I am not sure if a) and c) are even possible.
cc/ @teoli2003, @wbamberg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how the validator is implemented, but I'm not suggesting anything to be done with Prettier. If possible, I wish the validator respects Prettier style in terms of quotes, wrapping, and indenting—no point in letting the validator do formatting. (In the same spirit as ESLint should not do formatting.) It should only care about key ordering, invalid values, etc.
These are cherry picked issues. There is more to come.
I've tested the rendered changes yari has no issues with it.