-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 git hooks and simplify scripts #8427
Conversation
www/src/data/StarterShowcase/generatedGithubData/gatsby-advanced-blog.json
Outdated
Show resolved
Hide resolved
I think we would need to consolidate husky things - we do have it setup for |
@pieh I like the idea of using something like Husky and I completely agree that it should be at the root of the repo. It seems like a bug or something that the one at www/ level is applying to all files. I'd rather be explicit and define exactly what files we auto format. |
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.
@lipis I think we're very much in favor of the intent of this PR.
Would you be able to separate the functionality from the formatting? It's kinda challenging to review a PR with 1000 files changed 👀, so it'd be great to take a look at just the functionality, then introduce the formatting in a subsequent PR.
It'd also be nice if the build scripts in package.json were tweaked minimally, but I would need to take another look at exactly what's changed and why it was changed (e.g. prettier-eslint -> eslint)
Sound like a plan?
package.json
Outdated
"format-yaml": "prettier --write \"**/*.y?(a)ml\"", | ||
"format": "npm-run-all -p format-packages format:js format:other", | ||
"format:other": "yarn prettier --write", | ||
"format:js": "eslint --ignore-path .gitignore \"**/*.{js,jsx}\" --fix", |
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.
why specify the the ignore path here?
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.
Because otherwise it will try to parse more files as far as I know if it's not included..
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.
also let's put more ignored directories (in another file) instead of specifying which ones to format... there is no need to have 10 different format rules, as it's the same project.
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.
I'm open for better names here
@lipis also you can ignore the commit hooks with |
I'll do that.. |
I updated the PR with only the changes and simplified package.json. As a first step we can run the |
package.json
Outdated
"format-integration": "prettier-eslint --write \"integration-tests/**/src/**/*.js\" \"integration-tests/**/cypress/**/*.js\"", | ||
"format-yaml": "prettier --write \"**/*.y?(a)ml\"", | ||
"format": "npm-run-all -p format-packages format:js format:other", | ||
"format:other": "yarn prettier --write", |
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.
Can we do npm run prettier --write
here? I'd like to minimize the amount of places we require yarn explicitly!
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.
I would say we could get rid of npm-run-all and use yarn everywhere since we have yarn.lock
and no package-lock.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.
I disagree a lot with that! We want to keep barrier to entry low, so a change like that just makes that barrier higher and harder to get to for new contributors.
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.
That's invisible to the users and we already using yarn in the 'prebootstrap' and defined as engine..
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.
I don't think the engine is prohibiting anyone from contributing who uses npm
. I agree that it's an "invisible" change (i.e. not defined as a commit hook or anything, yet), but I don't see the benefit of changing that out here?
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.
I can imagine a user running npm run format:other
or npm run format
and being confused that fails. In that scenario, we made it harder for that user to contribute, and I'm not sure if it was for a real benefit.
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.
Updated it
Here is the PR for formatting all files except JS (just as an example) |
I updated the scripts.. in the next PRs we can format and fix the linting errors. |
* 'master' of github.com:gatsbyjs/gatsby: Category typos fixes and consolidation (gatsbyjs#8520) debugging build: error due to import/require mix (gatsbyjs#8493) updating name Adding pagination docs: add pagination doc (gatsbyjs#8476)
It looks like you plan to use This is great! 👍 |
…ate if we want error
even if `public` dirs are in .prettierignore, prettier will construct settings for each .json file before discarding them if they are in .prettierignore. This caused pretty bad prettier performance as it was doing that for every query result file (especially bad if you tried running benchmark pages with 50000 pages as prettier would evaluate 50000 json files
If you want disable this hook for all future commits: | ||
npm run hooks:uninstall | ||
` | ||
) |
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.
Awesome!
@pieh Why not prettify the JSON files as well.. and add to the ignore list if they are generated automatically? |
I missed weekend deadline as I needed to consult with some people working on So few things I just pushed here:
|
See 031ec68 for explanation - yes they won't be linted/formatted, but prettier will prepare configuration for every .json (in this instance) file and it was slowing linting/formatting (i was stuck on I didn't want to spend/waste more time on trying to figure it out - would prefer to merge this and if possible to fix that problem in follow up PR |
Makes sense.. we can do it in the follow up! |
Did you run "just" |
* 'master' of github.com:gatsbyjs/gatsby: (63 commits) Update how-to-contribute.md to mention the style guide when writing blogs/tutorials (gatsbyjs#9742) Added Tylermcginnis website (gatsbyjs#9619) Fix grammar and punctuation (gatsbyjs#9498) Fix typo of plugin authoring (gatsbyjs#9737) Authentication tutorial - small fixes (gatsbyjs#9738) chore: move run-sift (gatsbyjs#9549) docs: fix minor typo (gatsbyjs#9730) chore(release): Publish fix(gatsby-plugin-page-creator): ensure that __tests__ directory is actually ignored (gatsbyjs#9720) fix: revert admin redirect (gatsbyjs#9728) fix: adjust page order to make nested matchPaths work (gatsbyjs#9719) feat(gatsby-plugin-sharp): cache base64 if possible (gatsbyjs#9059) chore(release): Publish fix(gatsby-plugin-offline): Serve the offline shell for short URLs + use no-cors for external resources (gatsbyjs#9679) chore(release): Publish fix: ensure babel-preset-gatsby can be used with unit tests (gatsbyjs#9629) feat(www): Filter posts by date (gatsbyjs#9400) fix(blog): azure blog post url date (gatsbyjs#9718) feat(blog): Add post on publishing to Azure (gatsbyjs#8868) Emphasize importance of promise return on source-plugin docs (gatsbyjs#9650) ...
I just run the code without any manual work.. it's just to see what is being affected and what is needed to be fixed. I'll fix the errors and do manual updates when we merge the hooks. |
Let's merge this PR, then 2 of your (if they will apply cleanly) and then we can merge remaining of manual fixes that I already did from my branch (no sense to add more work for You if it's already done) |
Let's press the buttons! After merging this.. I will update my other PRs and force push the changes.. and then you can apply your changes..!! Looking forward to pass all the tests! |
eta ~15 minutes for merge - just gave final "warning" for rest of team to get any changes that are complete merged (to avoid unneeded conflict resolutions for PRs that were ready but for some reason not merged). |
@lipis merged, can you update other PRs so they don't include same changes as this one (git is weird sometimes) |
Yep! Just did.. :) |
- [x] Add git hooks to make sure the files are formatted before commiting - [x] Simplify `format*` scripts - [x] Drop prettier-eslint (is just a wrapper for ESLint and Prettier that we are using already) ---- ### The actual formats will happen in follow up PRs - [Format preview for `format:code`](https://github.com/gatsbyjs/gatsby/pull/8623/files) - [Format preview for `format:other`](https://github.com/gatsbyjs/gatsby/pull/8622/files)
After we merge gatsbyjs#8427
After we merge gatsbyjs#8427
format*
scriptsThe actual formats will happen in follow up PRs
format:code
format:other