Repository navigation
Closed
Labels
lang:yamlIssues affecting YAMLlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.type:questionQuestions and support requests. Please use Stack Overflow for them, not the issue tracker.
Description
Prettier 1.18.2
Playground link
--parser yamlInput:
- hosts: localhost # Hello
Output:
- hosts: localhost # Hello
Expected behavior:
Inline comments should have two spaces after the # to prevent yamllint from producing output like this:
117:33 warning too few spaces before comment (comments)
118:38 warning too few spaces before comment (comments)
119:53 warning too few spaces before comment (comments)
120:35 warning too few spaces before comment (comments)
121:26 warning too few spaces before comment (comments)
123:38 warning too few spaces before comment (comments)
125:35 warning too few spaces before comment (comments)
126:26 warning too few spaces before comment (comments)
127:32 warning too few spaces before comment (comments)
145:33 warning too few spaces before comment (comments)
219:36 warning too few spaces before comment (comments)
220:34 warning too few spaces before comment (comments)
221:39 warning too few spaces before comment (comments)
222:35 warning too few spaces before comment (comments)
223:37 warning too few spaces before comment (comments)
224:33 warning too few spaces before comment (comments)
225:34 warning too few spaces before comment (comments)
226:30 warning too few spaces before comment (comments)
227:39 warning too few spaces before comment (comments)
228:37 warning too few spaces before comment (comments)
232:39 warning too few spaces before comment (comments)
233:44 warning too few spaces before comment (comments)
263:31 warning too few spaces before comment (comments)
268:32 warning too few spaces before comment (comments)
271:32 warning too few spaces before comment (comments)
274:45 warning too few spaces before comment (comments)
277:40 warning too few spaces before comment (comments)
282:41 warning too few spaces before comment (comments)
285:34 warning too few spaces before comment (comments)
288:36 warning too few spaces before comment (comments)
291:34 warning too few spaces before comment (comments)
294:40 warning too few spaces before comment (comments)
Metadata
Metadata
Assignees
Labels
lang:yamlIssues affecting YAMLlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.type:questionQuestions and support requests. Please use Stack Overflow for them, not the issue tracker.
Activity
lydell commentedon Nov 2, 2019
Hi!
We recommend turning off all rules that conflict with linters. See https://prettier.io/docs/en/integrating-with-linters.html
ssokolow commentedon Nov 2, 2019
In that case, please change this to a request to amend https://prettier.io/docs/en/integrating-with-linters.html with instructions for adding the following to either the project linting config or
~/.config/yamllint/config:Also, if it's Prettier policy that linters should leave the formatting up to Prettier, then should I open another issue for how
yamllintwants#Footo become# Foo(ie. comments should start with a space after the#) but Prettier ignores the problem?lydell commentedon Nov 2, 2019
Thanks for the response!
I don’t think we should add an incomplete config in the docs. Not a complete one either – that should be a separate package, just like eslint-config-prettier.
About
#Foovs# Foo– we don’t enforce a space at the start of comments in any language. That’s because it can break tools that use comments in certain ways. So using a linter for that is encouraged if you want to enforce that space! For example, I use thespaced-commentESLint rule to achieve that in JS:https://github.com/lydell/eslint-config-lydell/blob/3682d0e5abb11a36ad0cdecb0fae1ab8bdb16e25/index.js#L150-L159
As you can see, I had to add special config to the rule to still be able to support Flow comments that have to start with
:or::.Hope this answers your questions!
ssokolow commentedon Nov 2, 2019
Fair enough.
It does. That necessity reminds me of an old, unmaintained Python documentation tool named ePyDoc which uses
#{and#}for section markers.That said, as someone who works primarily in Python, where all modern tools are built to play nicely with the
#<space>rule in PEP8, it irks me to see a formatter not having an option I could set on a case-by-case basis. Oh well. C'est la vie.(Maybe I can hack together something in Vimscript as an
ALEFixPosthook to automate adding whitespace on save.)