Skip to content

chore(ci): added lint-staged as pre-commit hook #1360

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

Merged
merged 1 commit into from
Mar 10, 2023

Conversation

dreamorosi
Copy link
Contributor

Description of your changes

As described in the linked issue, the current pre-commit hook was not linting & fixing issues on the staged files but instead was applying the fixes after the commit was made, thus defeating the purpose of the commit hook.

This PR, that fixes #1359, introduces a new developer dependency called lint-staged (7M+ downloads/mo) that helps run linting on staged files specifically. In addition to fixing the issue, this library also helps optimize the process by linting only the files/paths touched in the commit.

How to verify this change

Checkout the repo, run npm run init-environment, then make a change that would result in a fix (i.e. extra spaces or extra ;) and try making a commit.

Related issues, RFCs

Issue number: #1359

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published
  • The PR title follows the conventional commit semantics

Breaking change checklist

Is it a breaking change?: NO

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@dreamorosi dreamorosi self-assigned this Mar 9, 2023
@dreamorosi dreamorosi linked an issue Mar 9, 2023 that may be closed by this pull request
2 tasks
@pull-request-size pull-request-size bot added the size/M PR between 30-99 LOC label Mar 9, 2023
@github-actions github-actions bot added the internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) label Mar 9, 2023
@am29d am29d self-requested a review March 10, 2023 13:20
@am29d
Copy link
Contributor

am29d commented Mar 10, 2023

This is a fantastic addition to lint and fix our commits that improves day to day work in the long run ❤️.

@dreamorosi dreamorosi merged commit ce50659 into main Mar 10, 2023
@dreamorosi dreamorosi deleted the 1359-maintenance-improve-husky-pre-commit-hook branch March 10, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) size/M PR between 30-99 LOC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Maintenance: improve husky pre-commit hook
2 participants