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

#671: configured prettier for new developers #683

Merged
merged 13 commits into from
May 28, 2024

Conversation

River-unknown
Copy link

@River-unknown River-unknown commented May 5, 2024

Short Description

Worked on the issue for ensuring prettier gets configured.\

  1. Changes done to the Readme file
  2. Changes done to the package.json ensuring pre-commit hooks

Issues

Closes #671

@River-unknown River-unknown marked this pull request as draft May 5, 2024 10:02
@River-unknown River-unknown marked this pull request as ready for review May 5, 2024 10:04
Copy link
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @River-unknown! Thank you so much for this contribution.

I am not a fan of the pre-commit hook approach. Few things in this world scare me as much as the idea of my code changing invisibly right before I commit it.

I would prefer to rely on editor integrations alongside something like a test:lint or test:format script in package.json which can be run locally or in CI.

I'd also like the readme to be minimally affected by this stuff. We don't need lots of instructions - just a mention of the plugin should be fine.

Copy link
Collaborator

@josephjclark josephjclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @River-unknown - thanks again for the changes. I've taken another look and I've got a couple more comments for you.

README.md Outdated
You can also manually format files using Prettier by running the following command:

```bash
npm run format
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this repo we usually use pnpm, so this needs to be pnpm run format

package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated
@@ -28,7 +32,9 @@
"@types/gunzip-maybe": "^1.4.0",
"@types/rimraf": "^3.0.2",
"@types/tar-stream": "^2.2.2",
"eslint": "^8.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove eslint and the lint commands - between TypeScript's compiler and prettier's formatter, we should be well covered. Thanks!

README.md Show resolved Hide resolved
@josephjclark
Copy link
Collaborator

Hi @River-unknown - I'd love to get this work finished off! Can you spare a bit more time to make the final changes?

@River-unknown
Copy link
Author

Sure sir... I will complete it in 2-3 days..

@josephjclark
Copy link
Collaborator

Hi @River-unknown, if you're not able to complete this work soon I will need to close this PR and open the issue to other new contributors.

I don't think there's a lot of work outstanding.

If you are having difficulties with any particular point please let me know and we can discuss

@River-unknown
Copy link
Author

River-unknown commented May 28, 2024

Ya working on it. I will be by tomorrow push certain changes about the issue.

@River-unknown
Copy link
Author

having issue with resolving confliicts in the pnpm-lock.yaml and am not sure how to resolve that.

@josephjclark
Copy link
Collaborator

HI @River-unknown you need to merge the main branch into yours and run pnpm install . That will sort out the lock file. You can then commit the changes and push them

@@ -28,7 +30,7 @@
"@types/gunzip-maybe": "^1.4.0",
"@types/rimraf": "^3.0.2",
"@types/tar-stream": "^2.2.2",
"gunzip-maybe": "^1.4.2",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what happened here but we still need this dependency!

@josephjclark
Copy link
Collaborator

josephjclark commented May 28, 2024

If I run:

pnpm test:format

From root, I get this error:

[error] No files matching the pattern were found: "src/**/*.{ts,tsx,js,jsx}".

I also have diffs in my pnpm-lock.yaml file after I run pnpm install , which is a bit strange 🤔

EDIT: to be clear it's correct to check the src dir, but I think you want this pattern:

"packages/*/src/**/*.{ts,tsx}"

package.json Outdated
@@ -28,7 +31,7 @@
"@types/gunzip-maybe": "^1.4.0",
"@types/rimraf": "^3.0.2",
"@types/tar-stream": "^2.2.2",
"gunzip-maybe": "^1.4.2",
"prettier": "^3.2.5",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we lock the prettier version to 2.8.8?

It's a bit silly but that's what the repo currently uses. If we use 3.0 a lot of defaults change and we suddenly start seeing an awful lot of changes

I don't want to go through and check all those reformatting diffs. But if we lock it to 2.8.8 we should get a much smaller number of changes, and I can open a new issue to update to pretter 3.x

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just run prettier 2.8.8 against main and merged the diffs.

So on your branch right now, pnpm test:format should FAIL because it's detecting formatting changes.

After you merge main again, it should pass, and pnpm prettier should generate no diffs

@River-unknown
Copy link
Author

I just merged main branch into my branch as you said and it happened to be like this. And am not quite sure of that pnpm-lock.ya file matter and for that test i think by mistake i had deleted something i am not sure. I will check back on and will update soon

@josephjclark
Copy link
Collaborator

Ah @River-unknown I see the problem - you're on a more advanced pnpm version that we are.

I guess we ought to update that soon for now, but for now could you please set your pnpm to version 8.x and re-install from there?

The problem is that your pnpm has updated the lockfile version and changed everything.

@River-unknown
Copy link
Author

Ahh ok @josephjclark will update to those versions.

@River-unknown
Copy link
Author

@josephjclark can you please review . I had locked the prettier version to 2.8.8 and also reinstalled pnpm and its dependency with its version 8.

@josephjclark
Copy link
Collaborator

Great @River-unknown - thank you for all your hard work 🙏

I'll merge this into our repo now, run some final tests, and merge to main in the morning

@josephjclark josephjclark changed the base branch from main to prettier-tooling May 28, 2024 17:54
@josephjclark josephjclark merged commit eb5a39e into OpenFn:prettier-tooling May 28, 2024
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

Successfully merging this pull request may close these issues.

Ensure prettier is automatically set up for new developers
2 participants