-
Notifications
You must be signed in to change notification settings - Fork 103
[DRAFT] Adding husky for yarn lint-fix #880
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
base: develop
Are you sure you want to change the base?
[DRAFT] Adding husky for yarn lint-fix #880
Conversation
Hi! I just wanted to drop a small recommendation as I was passing by: As someone who has previously worked with (The reason for that is often when I'm working on large changes, I like to make tiny commits of my progress, if in case I ever want to revert to them. Since these commits are very minor and not the final products, I often don't want to spend time waiting for the CI/CD to pass, especially checks like linting and formatting. So being made aware of it when I install the project, and a small how to on how to skip them goes a long way IMO!). |
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 definitely like the idea overall (and across products) of having a tool for solely running linting on staged files.
However, I'm not sure about adding a .husky/pre-commit
config file. As @EshaanAgg mentioned, it's something that would best be documented and we'd want to be sure there is an easy way to skip the hooks as needed.
We don't have pre-commit
in Kolibri Design System, though, which is how we've typically handled such hooks.
This all said, looking now at Husky for the first time, it does seems reasonably promising. Interested in thoughts from @AlexVelezLl @MisRob @rtibbles
@EshaanAgg 's note about how Husky handles skipping hooks w/ an env var gets me wondering if they'll also be skipped during pre-commit when using the |
A warm hello to everyone!!! I had a couple of thoughts , could not type them down on time , apologies!!! The purpose I opened this PR was to overcome linting issues and enhance efficiency and code quality. My research about husky says , it helps in automation code linting before commits and thus does not let bad code enter the repository. What @EshaanAgg said is to update the documentation to:
2)List the specific scripts that Husky runs (example: yarn lint-fix) |
@nucleogenesis Actually there are certain environment variables present like:
2)Husky_skip_hooks=1(Only affects Husky managed hooks{if any}). |
Would you prefer: 1)Enforcing Husky via .husky/pre-commit, but documenting how to skip it? I’m happy to update the PR based on what works best for the team. Let me know your thoughts! |
Thanks for the replies @RONAK-AI647 I'm thinking that using husky here would be a nice improvements. I think that enforcing & documenting how to skip it would be the way to go as it is how our Python pre-commit hooks run in our other projects. I'll await additional discussion from the team before committing to a decision, so I'll mention this PR in Slack. |
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.
@marcellamaki helpfully pointed out that there has already been discussion about husky, so my hesitancy to add it is gone :)
I think that once the conflicts are resolved, this is ready to go
Hi @RONAK-AI647, are you planning to come back to this? The only thing that remains to be resolved are conflicts. |
Yes @MisRob , I need sometime , I faced an accident and my partial body is burnt . So ,Noone is letting me sit with my laptop.... |
Oh I'm so sorry to hear that @RONAK-AI647. Sending wishes for healing. Don't be worry about this at all. |
hi @MisRob ,just wanted to ask if any update in the documentation [part is also needed ???? referring to this conversation |
I don't think it's blocking, but rather optional suggestion @RONAK-AI647, but will let you and @nucleogenesis to coordinate on when to merge this work. |
ok @MisRob |
@RONAK-AI647 I think this is good to go once the merge conflict is resolved |
ok I will check whats wrong and make the change @nucleogenesis |
Hi @RONAK-AI647, I think it'd be good to wrap this work. Re-running |
@MisRob , check this error , files present but never used when i run yarn lint , so do i remove these files manually , I don;t think that will be right . Majorly two folders have this error named , If i put this files in eslintignore , it will pass the yarn lint but certainly the percy checks here will fail . |
@RONAK-AI647 before you re-lint, can you merge the latest |
@MisRob i have already done that , yet the lint is creating this error . I thought may be this branch has overgone through some serious changes which might bring errors . so tried making a new branch , did yarn install , and then yarn lint , then also this lint error occured , with ,my new branch also ... ?? any possible reason of such errors .... |
@RONAK-AI647 thanks for giving it a try. I realize these conflicts are accumulating because we postponed this PR. Let me take it from here - I will push to your branch so please don't do any further changes. Thanks for this work! |
924b519
to
65a57ef
Compare
Can you re-review @nucleogenesis? |
65a57ef
to
bcbed81
Compare
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 made some changes that require lint fixes in a file. When the pre-commit husky script ran the lint-fix
it showed the output you'd expect saying that it fixed the issue, but the fix isn't being applied. When I run yarn lint-fix
manually, the fix occurs as expected.
Also - I had to chmod +x .husky/pre-commit
in order to get it to run. I can push a commit w/ that change - but I'm not sure what is causing the lint fixes not to be applied.
$ /run/media/jacob/LE/krakens/kolibri-design-system/node_modules/.bin/lint-staged
✔ Backed up original state in git stash (21bbdd2ff)
⚠ Running tasks for staged files...
❯ package.json — 1 file
❯ *.{js,vue} — 1 file
✖ yarn lint-fix [FAILED]
↓ Skipped because of errors from tasks.
✔ Reverting to original state because of errors...
✔ Cleaning up temporary files...
✖ yarn lint-fix:
[ERROR: Kolibri Format] Linting errors for /run/media/jacob/LE/krakens/kolibri-design-system/lib/KBreadcrumbs.vue
[WARN: Kolibri Format] /run/media/jacob/LE/krakens/kolibri-design-system/lib/KBreadcrumbs.vue needs to be reformatted.
error Command failed with exit code 1.
error Command failed with exit code 1.
$ yarn lint -w /run/media/jacob/LE/krakens/kolibri-design-system/lib/KBreadcrumbs.vue
$ kolibri-format --pattern '**/*.{js,vue,scss,less,css}' --ignore '**/node_modules/**' '**/.nuxt/**' '**/dist/**' '**/lib/KIcon/precompiled-icons/**' '**/lib/keen/**' '**/docs/environment.js' '**/docs/jsdocs.js' -w /run/media/jacob/LE/krakens/kolibri-design-system/lib/KBreadcrumbs.vue
[INFO: Kolibri Format] Rewriting a reformatted version of /run/media/jacob/LE/krakens/kolibri-design-system/lib/KBreadcrumbs.vue
[INFO: Kolibri Format] Linted 1 file
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
husky - pre-commit hook exited with code 1 (error)
Thank you @nucleogenesis, I wonder if I caused this with my rebase, or if it was the case before. By any chance, do you recall if it worked for you during the previous review? |
Looks we won't merge this any time soon for reasons above - converting to draft in case it's handy at some point |
While working on this PR, I also encountered a problem where the Husky pre-commit hook runs yarn lint-fix, shows the expected output (indicating that it fixed the lint issues), but the fix isn't applied to the commit. Should we turn |
@RONAK-AI647 thanks for looking into it! We're having another discussion in parallel with @rtibbles about perhaps having to eventually use |
@MisRob Thanks for the response. |
Good to hear that @RONAK-AI647! We have new contributing guidelines that contain link to free issues, most of them are from a whole new frontend project that is actually prepared specifically for community contributors. I'm currently the main coordinator and would be happy to see you there! There are currently 3 free issues, and I keep adding new ones. A previous contributor didn't finish learningequality/studio#5082 - that may be a nice start with this project since the linked closed pull request already contains some code that could be re-used, together with my review. |
Description
A PR that runs yarn run lint-fix with appropriate arguments to ensure it lints only staged files.
Issue addressed
Closes #830
Addresses #*PR# 880
Before/after screenshots
Changelog
Steps to test
(optional) Implementation notes
At a high level, how did you implement this?
Does this introduce any tech-debt items?
Testing checklist
Reviewer guidance
Comments