-
Notifications
You must be signed in to change notification settings - Fork 141
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
Integrate prettier to make the format consistent #5
Conversation
"scripts": { | ||
"prettier": "prettier '{,!(node_modules)/**/}*.md' --check", | ||
"prettier:fix": "npm run prettier -- --write", | ||
"sort": "npx sort-package-json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this sort script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a trick I recently have. In the future, we may install dependencies by editing package.json
directly (e.g: integrate lint-stage
), or update some fields in that file. To make package.json
organized, just need to run npm run sort
, it will sort all fields recursively.
Let's think of it as prettier
, but for package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moreover, it use npx
, so it does not cost any disk storage to the users (except some bytes for the script 😂😂)
I think the PR is pretty good so far. There is one thing I want to bring up for discussion. Should we enforce the formatting somehow? So that every PR created will be in formatted state. I'm thinking of two approaches:
What do you think? @nvh95 @tamhoang1412 |
I think it's a great idea. However, please remember that users clone repository locally have an option to push the changes without installing prettier 😂. So this initiative mitigates the problem, not solves it completely.
The current github action does not make any commits. It just check the format (Notice the flag |
@huytd
|
What do you think @tamhoang1412? I think the discussion is longer than the code itself. 😅 |
😂 Yeah I think just run the check and let the contributor handle the code format from now on is good enough. Let's merge this. Btw, we can config the Github Action to commit on behalf of the repository owner, but maybe it's a bit over-engineering 😂 |
@huytd Yeah. Let's run it for a couple of new PRs to see how it goes and we can decide the next steps. |
@all-contributors please add @nvh95 for code |
I've put up a pull request to add @nvh95! 🎉 |
Motivation
How
backend-swe-interview-questions
- a de facto tool for formating code.Pending Items