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

Decouple prettier from eslint #363

Open
1 task done
nicholasio opened this issue Jan 15, 2024 · 3 comments
Open
1 task done

Decouple prettier from eslint #363

nicholasio opened this issue Jan 15, 2024 · 3 comments

Comments

@nicholasio
Copy link
Member

Is your enhancement related to a problem? Please describe.

from @tobeycodes (10up/wp-scaffold#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

  1. Add a prettier config to the root of wp-scaffold. The current config baked into the eslint-config can be used
  2. Add a npm command format to format the code
  3. Add format to run with husky/lint-staged on commit
  4. (future: add generic job configs for gitlab ci/github actions/circleci) that'll run this as a job with --check
  5. 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

  • I agree to follow this project's Code of Conduct
@nicholasio
Copy link
Member Author

@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.

@tobeycodes
Copy link

@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.

@nicholasio
Copy link
Member Author

nicholasio commented Feb 5, 2024

relevant to this discussion https://www.joshuakgoldberg.com/blog/you-probably-dont-need-eslint-config-prettier-or-eslint-plugin-prettier

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

No branches or pull requests

2 participants