10up-toolkit
10up-toolkit copied to clipboard
Decouple prettier from eslint
Is your enhancement related to a problem? Please describe.
from @tobeycodes (https://github.com/10up/wp-scaffold/issues/199)
This might be more appropriate for 10up-toolkit. I believe we should use prettier for formatting and not part of linting. I am proposing the following changes
- Add a prettier config to the root of wp-scaffold. The current config baked into the eslint-config can be used
- Add a npm command
formatto format the code - Add
formatto run with husky/lint-staged on commit - (future: add generic job configs for gitlab ci/github actions/circleci) that'll run this as a job with --check
- remove the duplicate .editorconfig in the theme and the mu-plugin
The reason I am proposing this change is that we can currently only formatting JS files. The formatting should be applied to all files in the repo that match the prettierconfig and the .editorconfig. Currently the repo does not match the editorconfig in a lot of files and that would be resolved by running prettier as it will use the prettier config and the editor config. This will fix the formatting in non JS files such as JSON, MD, etc.
Designs
No response
Describe alternatives you've considered
No response
Code of Conduct
- [X] I agree to follow this project's Code of Conduct
@tobeycodes You could still set up vscode so that it runs for the other supported files correct? We could add the extensions prettier should be used to format here https://github.com/10up/wp-scaffold/pull/206/files#diff-a5de3e5871ffcc383a2294845bd3df25d3eeff6c29ad46e3a396577c413bf357R18 while leaving js/ts files responsibility of eslint.
@nicholasio I guess you could do that but prettier will format all files types because of the editorconfig here. https://github.com/10up/wp-scaffold/blob/trunk/.editorconfig#L3. I think it would be a little weird processing non ts/js files with eslint but I am sure it's possible
My personal opinion is leave formatting to prettier and leave code issues to eslint. I have both prettier and eslint running in vscode without issues. On 10up projects I disable prettier because otherwise so many of my commits are fixing the formatting of the prettierconfig/editorconfig.
relevant to this discussion https://www.joshuakgoldberg.com/blog/you-probably-dont-need-eslint-config-prettier-or-eslint-plugin-prettier