Closed alex12306 closed 10 months ago
Run & review this pull request in StackBlitz Codeflow.
I am impressed that Prettier does not allow ignoring the entire file via comments https://prettier.io/docs/en/ignore.html / https://github.com/prettier/prettier/issues/3634
In this case, I feel the fix is not solid enough, as we can't really prevent another statement in the middle. I'd suggest you add the file to .prettierignore
as a workaround.
I am impressed that Prettier does not allow ignoring the entire file via comments https://prettier.io/docs/en/ignore.html / prettier/prettier#3634
In this case, I feel the fix is not solid enough, as we can't really prevent another statement in the middle. I'd suggest you add the file to
.prettierignore
as a workaround.
Yes it does not allow you to ignore an entire file through comments. I just look at the source code and see the generated code along with the comments and git history, and think maybe something is missing, so I'll just use.prettierignore
(^ ^)
While I do agree that the .prettierignore
is the best solution, unfortunately it doesn't work in my situation.
We sometimes have conflicts in this file, and saving it in VSCode triggers the auto formatting, even though it is in our .eslintignore AND .prettierignore definitions.
Having this rule everywhere would help us a lot - though this is only a supposition. Maybe there is a better way to do this that we haven't found. I'd like to know your opinion about this.
Description
When I used prettier to format the code, I found that the
components.d.ts
file automatically generated byunplugin-vue-components
was formatted, but the top of the file was written to prohibit eslint and prettier . After testing, I found that/* eslint-disable */
is effective, but/* prettier-ignore */
does not.BUG reproduction: Before prettier formatting:
After prettier formatting:
You can see that single quotes have changed to double quotes, proving that
/* prettier-ignore */
has no effectThen I checked the git history and found the changes proposed by this PR: https://github.com/unplugin/unplugin-vue-components/pull/597 The original intention of this change is to prevent
eslint
andprettier
from formatting the entire file, not just theexport {}
line. So I added the last line/* prettier-ignore */
in the relevant code, this will ensure that the whole file will not be formatted and will not affect the functionality of other commentsLinked Issues
Additional context