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

Husky and lint-staged linting automate tools on pre-commit event #114

Open
wants to merge 7 commits into
base: frontend
Choose a base branch
from

Conversation

PixelSculptor
Copy link
Contributor

@PixelSculptor PixelSculptor commented Aug 23, 2023

This PR adds 2 automate tools:

  • Husky - tool to automate some actions on event - here for pre-commit activity
  • lint-staged - tool for invoking all linters (eslint, stylelint, prettier) for files that are staged in repo - NOTE: works asynchronously

When you edit files in ui/src that have .js, .jsx or scss extension and then add to stage, all these files will be checked and linted automatically before commit, if eslint detects something wrong, then throws an error and thanks to this we will not push rubbish code and commits and we will fix all before extending our history of repo.

@PixelSculptor PixelSculptor requested a review from marcol13 August 23, 2023 20:53
@PixelSculptor PixelSculptor changed the title install husky and lint-staged libs Husky and lint-staged linting automate tools on pre-commit event Aug 23, 2023
Copy link
Collaborator

@marcol13 marcol13 left a comment

Choose a reason for hiding this comment

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

Wygląda super, chociaż naszła mnie pewna rozkmina jak sprawdzałem kod 😄 Napisz co o tym myślisz. Jeżeli uważasz, że to podejście jest OK, to jak dla mnie masz zielone światło, żeby mergować 😀

"lint-staged": {
"./src/**/*.{js,jsx}": "eslint --fix",
"./src/**/*.{jsx,js,scss}": "prettier --write",
"./src/**/*.scss": "stylelint --fix"
Copy link
Collaborator

Choose a reason for hiding this comment

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

W sumie tutaj takie pytanie. Czy zawsze dla nas --fix będzie pożądany? Automatyczne fixy mogą powodować trochę bałaganu i przed commitem nie jesteśmy w stanie nad nimi zapanować 😅 To potencjalnie będzie powodowało kolejne problemy. Czy ewentualnie jesteśmy w stanie zmienić te fixy na zwykłe --check? Co o tym myślisz @PixelSculptor ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request frontend Frontend tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Frontend] Dodatkowe sprawdzenie zgodności kodu z linterami z wykorzystaniem biblioteki Husky
2 participants