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

Code base seems to be non-formatted with Prettier #262

Closed
kettanaito opened this issue Aug 27, 2021 · 8 comments
Closed

Code base seems to be non-formatted with Prettier #262

kettanaito opened this issue Aug 27, 2021 · 8 comments

Comments

@kettanaito
Copy link
Contributor

kettanaito commented Aug 27, 2021

The library is using Prettier to format the changes via lint-staged and npm run prettier command. When doing so, however, it formats the entire file, distorting the commit's diff. This makes contributing to the project extremely tedious.

I believe the reason for that is the lack of the explicit Prettier configuration that'd tell Prettier how to format the code. It must be detecting some of my other Prettier configurations and formatting the code base accordingly.

Solution

Let's add an explicit .prettierrc configuration so that the formatting on the commit hook would produce a consistent result.

@kettanaito
Copy link
Contributor Author

Once the configuration is added, I highly recommend formatting the entire code base to prevent any unexpected format-related diffs in the future.

@blakeembrey
Copy link
Member

I’d rather not add a special config to avoid this, the point of prettier personally was to avoid configuration. That said, I’ll take a look and maybe migrate to https://github.com/borderless/ts-scripts anyway since I’ve standardized this setup for all other repos.

@kettanaito
Copy link
Contributor Author

I completely agree, yet I'm experiencing an issue when a clean fork without any additional VS Code settings mal-formats the code base of this project. I suspect some implicit Prettier config resolution at the place, but cannot point a finder on it just yet.

An even bigger beauty of prettier is just being opinionated. I always add explicit configs even if they describe prettier's default. The latter can always change, as happened with prettier for javascript, if my memory serves right. In the end, it's about consistent code formatting and contributing experience.

@blakeembrey
Copy link
Member

I'll take a look. I think that's actually my fault for merging a prettier update with applying the version I updated to at the same time.

@kettanaito
Copy link
Contributor Author

Thank you, @blakeembrey. Let me know if you need any help. I can set up a pre-commit hook that'd format any changes, ensuring no unformatted code gets committed. That, and a fixed Prettier configuration will be enough for a great experience.

@frank-dspeed

This comment was marked as off-topic.

@blakeembrey
Copy link
Member

Reformatted in the mega commit b45871b. I'm taking a look at your PR finally and will rebase if I can 😄

@kettanaito
Copy link
Contributor Author

Thank you, @blakeembrey!

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

No branches or pull requests

4 participants