chore: use prettier to format code
Description
Add prettier to automatically format the code when saving it so that it follows a consistent style. Currently works with eslint
Type of Change
Please delete options that are not relevant.
- [x] Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
How Has This Been Tested?
Feel free to modify the code and save it. But please make sure that format on save of vs code is turned on.
"editor.formatOnSave": true,
Suggested Checklist:
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] My changes generate no new warnings
- [x] I ran
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods
I'm very sorry, I just saw that the project uses antfu's eslint configuration, and antfu does not use prettier. Maybe my PR should be closed.
But there are some issues that I think still need to be discussed
- The configuration of
@antfu/eslint-configalready supports eslint v9. The version in the project is still 8.x. Do we need to upgrade simultaneously? - There are React related rules in
@antfu/eslint-config, but our project is Next.js and there are still some differences. It may be necessary to rewrite some rules after upgrading to cover them. - There are no tailwindcss related rules in
@antfu/eslint-config. We need to introduce rules to restrict tailwindcss, such as repeated class use, class order, etc. Now there are situations where the same class is used
My suggestion is to use eslint + prettier. Using the configuration of shadcn-ui can meet our basic needs. https://github.com/shadcn-ui/ui/blob/main/.eslintrc.json
Prettier's opinionated nature often leads to undesirable results and cannot be optimized through configuration. Therefore, we prefer to use eslint for code formatting.
Thank you for your suggestions on upgrading @antfu/eslint-config. Our team will choose an appropriate time to upgrade the plugin and relevant infrastructures, as upgrading lint rules may cause unwanted code conflicts.
Given that we will not adopt prettier, close this for now.