diff --git a/package.json b/package.json index e50407a841f..20f1d6d717f 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", "fix": "npm run fix:errors", - "precommit": "lerna run --concurrency 1 --stream precommit --since master", + "precommit": "./precommit.sh", "test:ci:local": "npm run test:ci:build:local && npm run test:ci:all", "test:ci:build:local": "./ci.sh build local", "test:ci": "echo 'This command has been removed. Try running `npm run test:ci:local` to run tests locally using the test_runner docker container as before. The CI pipeline logic is now in .circleci/config.yml.'", diff --git a/packages/bitcore-cli/package.json b/packages/bitcore-cli/package.json index 84ce9584263..183b46e8ba9 100644 --- a/packages/bitcore-cli/package.json +++ b/packages/bitcore-cli/package.json @@ -38,8 +38,7 @@ "lint": "eslint .", "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", - "fix": "npm run fix:errors", - "precommit": "npm run lint" + "fix": "npm run fix:errors" }, "dependencies": { "@bitpay-labs/bitcore-mnemonic": "^11.8.1", diff --git a/packages/bitcore-client/package.json b/packages/bitcore-client/package.json index 1a69288a0da..380b2913177 100644 --- a/packages/bitcore-client/package.json +++ b/packages/bitcore-client/package.json @@ -25,7 +25,6 @@ "compile": "npm run clean && npm run build", "test": "npm run compile && mocha -r tsx --exit 'test/**/*.test.ts'", "coverage": "npm run compile && nyc mocha -r tsx --exit 'test/**/*.test.ts'", - "precommit": "npm run lint", "lint": "eslint .", "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", diff --git a/packages/bitcore-logging/package.json b/packages/bitcore-logging/package.json index cf1c1003ff4..0f6333cd818 100644 --- a/packages/bitcore-logging/package.json +++ b/packages/bitcore-logging/package.json @@ -29,8 +29,7 @@ "lint": "eslint .", "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", - "fix": "npm run fix:errors", - "precommit": "npm run lint" + "fix": "npm run fix:errors" }, "dependencies": { "winston": "3.3.3" diff --git a/packages/bitcore-node/package.json b/packages/bitcore-node/package.json index 6ca7860f540..1dd86061706 100644 --- a/packages/bitcore-node/package.json +++ b/packages/bitcore-node/package.json @@ -50,7 +50,6 @@ "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", "fix": "npm run fix:errors", - "precommit": "npm run lint", "test:scripts": "npx mocha scripts/test" }, "nyc": { diff --git a/packages/bitcore-wallet-client/package.json b/packages/bitcore-wallet-client/package.json index 9436996ef00..3a21f1ec98f 100644 --- a/packages/bitcore-wallet-client/package.json +++ b/packages/bitcore-wallet-client/package.json @@ -66,8 +66,7 @@ "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", "fix": "npm run fix:errors", - "pub": "npm run build && npm publish", - "precommit": "npm run lint" + "pub": "npm run build && npm publish" }, "nyc": { "include": [ diff --git a/packages/crypto-rpc/package.json b/packages/crypto-rpc/package.json index 1642be64c36..88f4978822c 100644 --- a/packages/crypto-rpc/package.json +++ b/packages/crypto-rpc/package.json @@ -20,7 +20,6 @@ "hardhat:clean": "rm -rf blockchain/EVM/artifacts blockchain/EVM/cache", "hardhat:test": "npm run hardhat:clean && cd blockchain/EVM/ && npx hardhat test", "lint": "eslint .", - "precommit": "npm run lint", "test": "docker-compose down && docker-compose build && docker-compose run test_runner", "test:local": "npm run docker:test:down && npm run docker:test:build && docker compose run test_runner" }, diff --git a/packages/crypto-wallet-core/package.json b/packages/crypto-wallet-core/package.json index dde96e5b320..76bd8d27e42 100644 --- a/packages/crypto-wallet-core/package.json +++ b/packages/crypto-wallet-core/package.json @@ -12,7 +12,6 @@ "build": "tsc", "clean": "rm -rf ts_build && tsc --version", "compile": "npm run clean && npm run build", - "precommit": "npm run lint", "lint": "eslint .", "fix:errors": "eslint --fix --quiet .", "fix:all": "eslint --fix .", diff --git a/precommit.sh b/precommit.sh new file mode 100755 index 00000000000..c447dd849ed --- /dev/null +++ b/precommit.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +lintPackages="bitcore-cli bitcore-client bitcore-logging bitcore-node bitcore-wallet-client bitcore-wallet-service crypto-rpc crypto-wallet-core" + +lintDirs="" +for package in $lintPackages; do + for dir in src test scripts lib; do + if [ -d "packages/$package/$dir" ]; then + lintDirs+="packages/$package/$dir " + fi + done +done + +# staged JavaScript/TypeScript files that are either modified or new, not deleted files +modifiedFiles=`git diff --name-only --diff-filter=AM --cached $lintDirs | grep -E '\.(js|ts)'` + +if [[ "" != $modifiedFiles ]]; then + npx eslint $modifiedFiles +fi