Conversation
bc65ee2 to
585edc6
Compare
| "lint:prettier": "prettier --check .", | ||
| "preinstall": "npx only-allow pnpm", | ||
| "prepare": "lerna run build && husky install", | ||
| "prepare": "husky && lerna run build", |
There was a problem hiding this comment.
Run the husky setup code before the build that people ctrl+c
| ], | ||
| "**/*.{js,ts}": [ | ||
| "eslint --fix", | ||
| "prettier --write" |
There was a problem hiding this comment.
This is duplicate work with the * prettier below.
| @@ -1,4 +1 @@ | |||
| #!/usr/bin/env sh | |||
| . "$(dirname -- "$0")/_/husky.sh" | |||
|
|
|||
There was a problem hiding this comment.
^ I believe this block is no longer required in husky 9
| packages/turf-*/test/in/** | ||
| packages/turf-*/test/out/** | ||
| packages/turf-*/test/true/** | ||
| packages/turf-*/test/false/** |
There was a problem hiding this comment.
We were actually intentionally ignoring the json/geojson files in the test directories I believe for whitespace reasons. I changed prettier to target longer lines which is maybe a better compromise with readability and gets us back to being standardized.
.prettierrc.json
Outdated
| @@ -1,3 +1,4 @@ | |||
| { | |||
| "printWidth": 120, | |||
There was a problem hiding this comment.
Open to feedback on this exact number, I essentially randomly chose it. I'm hoping that's a better compromise for test fixture geojson readability, among other things. (I think the default was 80?)
585edc6 to
28a06cd
Compare
|
Okay I didn't notice this change in the previous linked PR. I agree that consistent formatting is more import than readable formatting. In that I just ran into this yesterday 😄 when a test geojson output needed to be regenerated and with all the whitespace differences, I had a hard time seeing the small bit of actual change that I needed to confirm - #2665. Is it possible to enable or enforce a different printWidth for a subset of files? I'm not against the 120, but I do think it reduces readability of the source files. Whether code review in browser, or using multiple columns in editor like I do. @smallsaucepan does setting to 120 support the use case that led to making the change in the first place? I would suspect not, it's seems tailored to custom formatting. |
|
Yeah we can totally have different prettier settings in different files with overrides. If we're all on board with re-adding json formatting to the test fixtures, I'm happy to implement whatever |
|
Oh you can totally see what various prettier settings do by changing the config and just running this: It might be easiest to start from |
|
Personally, I'd just bring back the old default setting of 80 if having a different value doesn't solve a need for the fixtures |
I think there's value in having some JSON format standard even if it isn't perfectly ideal when compared to hand formatting. We can also use |
28a06cd to
e7f1556
Compare
|
@twelch I reset the prettier settings, but added a custom script that formats the json and geojson files. Thoughts? |
| "type": "LineString", | ||
| "coordinates": [ | ||
| [-53.674866943359375, 28.30135788537988], | ||
| [-53.674866943359376, 28.30135788537988], |
There was a problem hiding this comment.
I think the round trip of JSON.parse/stringify is modifying these which is a little scary. I think the tests all still pass though.
There was a problem hiding this comment.
There was a problem hiding this comment.
Everything is going to have tradeoffs. But not automatically formatting these things isn't really an option because we can't review PRs cleanly otherwise. Here's prettier with the default printWidth #2677
Modify lint-staged and prettier configs Add specific json/geojson formatting that isn't prettier
e7f1556 to
7e8d41d
Compare
|
See #2677 |


Since I was already here I started by upgrading
huskyprettierandlint-staged.It turns out that we intentionally dialed down the prettier aggressiveness because the formatting of test fixtures looked pretty ugly with the existing prettier settings. I think that if we increase the target
printWidthfor prettier, we can more confidently re-enable it for all of the test fixtures.I think that even imperfect formatting of the fixtures is better than inconsistent formatting because of disabling it.
Its probably easiest to review this commit by looking at the first one to understand the changes, and the second commit for getting a sense of how the changes impacted the formatting across the codebase.
Thoughts? If people are on board with this, I'd like to merge this after we merge as many of the outstanding PRs as possible to give them fewer merge conflicts where possible.