-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add global formatting for the webapp. #130
Conversation
Prettier
).
there's another interesting plugin we could use: https://www.npmjs.com/package/eslint-plugin-simple-import-sort this helps sort imports in different files according to your specs, here's an example one:
|
Yes let's go for 4!
This is always religious, but I do prefer spaces myself. I guess with prettier it matters less, but it ensures proper display on Github for instance. Any counter here? Like would you strongly prefer a 2 or 8 spaces local display? |
.github/workflows/check.yaml
Outdated
- name: Install dependencies for webapp | ||
run: cd packages/webapp && pnpm install | ||
- name: Check formatting with Prettier | ||
run: cd packages/webapp && npx prettier --check "**/*.{js,jsx,ts,tsx,json,css}" |
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.
This should be folded into make check
in the webapp Makefile (which will cause it be checked by the global Makefile make check
and thus covered by the above)
Makefile
Outdated
# Performs code formatting for the webapp files and contracts in their respective directories. | ||
format: | ||
cd packages/webapp && make format | ||
cd packages/contract && make check |
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.
cd packages/contract && make check | |
cd packages/contract && make format |
packages/webapp/Makefile
Outdated
# Runs prettier formatting across webapp files with specified file extensions. | ||
format: | ||
npx prettier --write "**/*.{js,jsx,ts,tsx,json,css}" |
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.
npx prettier --write "**/*.{js,jsx,ts,tsx,json,css}" | |
pnpm prettier --write "**/*.{js,jsx,ts,tsx,json,css}" |
5ebe61d
to
2c3d1dd
Compare
No hard preference here, 4 is good! |
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.
Approving, but address comments!
.github/workflows/check.yaml
Outdated
@@ -20,4 +21,5 @@ jobs: | |||
run: mkdir -p packages/contracts/out && echo "{}" > packages/contracts/out/deployment.json | |||
- run: make setup | |||
- run: make check | |||
|
|||
- name: Check formatting with Prettier | |||
run: cd packages/webapp && make check |
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.
already covered by make check above, this file shouldn't be changed basically
(Sorry, I think I recall I said this needed to be updated, but if make check checks the format, it's not needed!)
packages/webapp/.prettierrc.json
Outdated
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.
isn't 150 too much? I like 100 or 120
check: | ||
pnpm eslint . && pnpm prettier --check "**/*.{js,jsx,ts,tsx,json,css}" | ||
.PHONY: check |
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.
you can put both of these on different lines (no need for &&)
Adds a global format command that runs prettier's
--write
on all specified file types.Uses the following options within the config (
prettierrc.json
):"semi": false
: prevents addition of semicolons on save"trailingComma": "es5"
: https://prettier.io/docs/en/options.html#trailing-commas"singleQuote": false
: uses double quotes for imports/elsewhere."tabWidth": 2
: @norswap did you want this as 4?"useTabs": true
: https://prettier.io/docs/en/options.html#tabs"printWidth": 100
: increase the number of characters that prettier will try to wrap around, prevents the dependency arrays ofuseEffect
anduseCallback
hooks from splitting into a column unless absolutely needed (https://prettier.io/docs/en/options.html#print-width).Also added
eslint-config-prettier
to be used as a plugin as the recommended mediator between linting and formatting.