Skip to content
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

Generated prettier-ignore comments do nothing #2673

Closed
ethanwu10 opened this issue Oct 30, 2024 · 5 comments · Fixed by #2679
Closed

Generated prettier-ignore comments do nothing #2673

ethanwu10 opened this issue Oct 30, 2024 · 5 comments · Fixed by #2679

Comments

@ethanwu10
Copy link

ethanwu10 commented Oct 30, 2024

Which project does this relate to?

Router

Describe the bug

By default, the router generator will add prettier-ignore-start and prettier-ignore-end comments to the generated file (functionality added in #1157):

'/* prettier-ignore-start */',

.default(['/* prettier-ignore-end */']),

However, these comments are not actually supported by prettier - the start/end range comments are only supported in Markdown right now - prettier/prettier#5287

Your Example Website or App

https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBbAhjATgSwB4AUAOlAASkCMANKQAw30nn2UNVN1uUkCUJJAegBUpAA5Y4MGDjhYAtDgDmUCBLkBnGOiwxSQgSQzZ8xMq06cOLapbMtrvQSPGTpshctVw5CACZ6BECoQCFFpaHVkUG0sCAB3AAVtBEiUdAAbOPQAT0jggCMsdDAAa0kAZXRUOAAZHCg4ZAAzDPU4AqLSitFi+sVkbABXdpA21BwBrGHguDxRWRxq2AyAFVkobRlUlvS24PU+9LgARUGIeGbWkYArdTxyw5Ozi6QdvZAAR2e4BNjRVJA6HUcgacF8YKCIGw6Bw6T6AGEIKgMMhAel0pCDlBFEcAIJSXD5QbwBKyOoNS67EYACxgqHSAHVqTh4OoemA4OUUiycAA3FnZVFgdR5EC84YASSg4Ng5TAuDCuOl5Rg2SOlPe4ggbQZRVEqJcbSwvMawXqRpgv3QihRryuwR6WCNqNV83U8pwYUh4nqMAZOF8MGpyAAHPQQBIvjgJFabegNSMtPl-YHg0gAEzBQZtFbofLbe0gOCofJg8G+GrobGDa1wABiqiM0mxqPQxIgIAAvp2gA

Steps to Reproduce the Bug or Issue

  1. Take any generated TSR route tree file and run it through prettier
  2. Notice prettier still formats the entire file

Expected behavior

The presence of the non-functional prettier-ignore comments is confusing. They should just be removed from the default configuration since there is no way to get prettier to ignore a whole file through comment directives (prettier/prettier#3634).

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Browser: N/A

Additional context

No response

@SeanCassiere
Copy link
Member

For the time being, on some versions of prettier, this seems to be working. In general, you should ignore the generated file from your formatted and linter.

Prettier: https://prettier.io/docs/en/ignore.html#ignoring-files
Eslint: https://eslint.org/docs/latest/use/configure/ignore

We should call this out in the docs.

@SeanCassiere SeanCassiere added the documentation Everything documentation related label Oct 30, 2024
@ethanwu10
Copy link
Author

As far as I'm aware the prettier-ignore-start/end comments were never supported for any language except markdown (prettier/prettier#5287). Is there any actual evidence of it working? From what I can tell, router-generator's output conforms perfectly to the prettier default style when quotes and semis are configured the same, so that might be leading to the impression that it works?

@SeanCassiere
Copy link
Member

I must be mistaken then 🤔.


What would you suggest as the best option here outside of updating the documentation?

I'm thinking of possibly updating the head comment of the generated output file, telling the user to ignore the generated file from their linter and/or formatted.

Whatever path forward, we'd definitely want to avoid having to update the user's prettierignore file as it relies upon us knowing the location of root dir (which can be different based on people's setups). Plus, this kind of change would lead to people wanting the same changes to accommodate others like eslint, biome, and others.

@SeanCassiere SeanCassiere added enhancement New feature or request and removed documentation Everything documentation related enhancement New feature or request labels Oct 30, 2024
@ethanwu10
Copy link
Author

Yeah, I agree that calling this out in the docs and updating the head comment is probably the best way forward - I don't think there's much automation that can/should be done (at least, until prettier gets around adding a @noformat directive or something).
But whatever happens, I think the currently inserted comments should be removed, since it misleads people (such as me) into thinking they're supposed to do something.

@SeanCassiere
Copy link
Member

FYI @thomasballinger thought you'd be interested in knowing about this find.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants