Skip to content

Fast Precommit#4171

Merged
kajoseph merged 3 commits into
bitpay:masterfrom
MicahMaphet:fast-precommit
Jun 30, 2026
Merged

Fast Precommit#4171
kajoseph merged 3 commits into
bitpay:masterfrom
MicahMaphet:fast-precommit

Conversation

@MicahMaphet

Copy link
Copy Markdown
Contributor

Description

Only run eslint on staged files

Changelog

  • precommit.sh shell script to filter files based on
  1. Modified or new staged files (not deleted files as those can show up in diffs)
  2. Either JavaScript or TypeScript files
  3. Files in bitcore-cli, bitcore-client, bitcore-logging, bitcore-node, bitcore-wallet-client, bitcore-wallet-service, crypto-rpc, or crypto-wallet-core
  4. Files in a src, test, lib, or scripts folder
  • Swapped lerna script with ./precommit.sh in packages.json precommit script
  • Removed precommit from all packages

Testing Notes

Test Basic Functionality

  1. Add random characters to a file in a package that is checked (like bitcore-node)
  2. Add the file in git (perhaps run git add .)
  3. Run git commit, the precommit script should fail stopping the commit from being created

Edge Cases

The commit should work according to the first bullet point in the Cangelog above


Checklist

  • I have read CONTRIBUTING.md and verified that this PR follows the guidelines and requirements outlined in it.

@MicahMaphet MicahMaphet marked this pull request as ready for review June 30, 2026 15:10

@kajoseph kajoseph left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this PR can actually be condensed down to a single line change.

package.json:

  "precommit": "npx eslint $(git diff --cached --name-only)",

@MicahMaphet

Copy link
Copy Markdown
Contributor Author

I think this PR can actually be condensed down to a single line change.

package.json:

  "precommit": "npx eslint $(git diff --cached --name-only)",

Made some changes:

 "precommit": "eslint --pass-on-no-patterns --no-warn-ignored $(git diff --name-only --cached --diff-filter=AM)",

--pass-on-no-pattern otherwise it checks everything if no files were changes
--no-warn-ignored otherwise warns if something like a config file is changes
--diff-filter=AM prevents linting of removed files which causes errors
removed npx because it is not needed

@kajoseph kajoseph left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

tACK

@kajoseph kajoseph merged commit 04b8d34 into bitpay:master Jun 30, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants