oui
oui copied to clipboard
Change pre-commit hook to only lint
The current pre-commit hook takes a non-insignificant amount of time. It would be nice if our precommit hook mirrored OSD's and only ran the linter (assuming it will run in an insignificant amount of time).
hi @BSFishy ,
Hope you are doing well! I can work on this issue for you. I just wanted to clarify before I get started: you want "test-staged" to only run lint and absolutely nothing else?
Thanks!
I just wanted to clarify before I get started: you want "test-staged" to only run lint and absolutely nothing else?
Here is the outcome I envision: when making a commit, only the linter is run (ideally, it is only run on files which have been added, modified, etc., but for this task, running the linter in its entirety is fine).
I think 2 parts will be involved:
-
Changing the script that is run for precommit (to
lint):https://github.com/opensearch-project/oui/blob/a1b90296c324ac936f2c6594f694324ef299cd44/package.json#L92-L94
-
Changing test staged to run only the
scripts/test-staged.jsscript (without running thelintscript):https://github.com/opensearch-project/oui/blob/a1b90296c324ac936f2c6594f694324ef299cd44/package.json#L32
Hi @BSFishy ,
Thanks for responding to my comment! I will use your comment as a guideline while I work on this issue.
Cheers!
hi @BSFishy ,
Hope you are doing well! I saw your comment in the discussion for lint-staged as a dependency. I agree with the points you made, so I will try and write a script instead of adding a new dependency. Can I submit a new PR with that script once its complete?
Thanks!
Can I submit a new PR with that script once its complete?
Absolutely! Ideally, this is what runs pre-commit instead of linting the entire project. The script should be relatively simple too, some pseudocode:
changes -> files that were added, changed, renamed, etc.
eslint_changes -> changes that have the proper suffix (.js, .ts, .tsx, etc.)
if eslint_changes is not empty then
run eslint on eslint_changes
endif
sass_lint_changes -> changes that have the proper suffix (.scss, etc.)
if sass_lint_changes is not empty then
run sass-lint on sass_lint_changes
endif
That should be good. I don't think we should run Typescript type checking to pre-commit, as you can only check the entire project and it will run in CI anyway.