From e5682eec38a0785b962975a91b9f6fbf315e2c31 Mon Sep 17 00:00:00 2001 From: ricky Date: Wed, 11 Dec 2019 15:52:08 -0500 Subject: [PATCH] Add lint:shellcheck:package (#7568) * Add lint:shellcheck:package * Add double quote as per jq suggestion * Use single quotes * Ignore SC2016 * Use shellcheck script * Set some flags * Put shellcheck --version on new line * Disable SC2016 (singe quotes is actually what we want here) --- development/shellcheck.sh | 14 ++++++++++++++ package.json | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 development/shellcheck.sh diff --git a/development/shellcheck.sh b/development/shellcheck.sh new file mode 100755 index 000000000..ec326908d --- /dev/null +++ b/development/shellcheck.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -e +set -u +set -x +set -o pipefail + +shellcheck --version +# lint all *.sh files +find . -type f -name '*.sh' ! -path './node_modules/*' -print0 | xargs -0 shellcheck +# lint all .scripts in package.json +# shellcheck disable=SC2016 +list=$(jq -r '.scripts | keys[] as $key | .[$key]' < package.json) +printf "#!/bin/bash\n%s\n" "$list" | shellcheck - diff --git a/package.json b/package.json index 48bbf8590..985b08f3c 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test:web3:firefox": "SELENIUM_BROWSER=firefox test/e2e/run-web3.sh", "test:e2e:firefox": "SELENIUM_BROWSER=firefox test/e2e/run-all.sh", "test:coverage": "nyc --reporter=text --reporter=html npm run test:unit", - "test:coveralls-upload": "if [ $COVERALLS_REPO_TOKEN ]; then nyc report --reporter=text-lcov | coveralls; fi", + "test:coveralls-upload": "if [ \"$COVERALLS_REPO_TOKEN\" ]; then nyc report --reporter=text-lcov | coveralls; fi", "test:flat": "yarn test:flat:build && karma start test/flat.conf.js", "test:flat:build": "yarn test:flat:build:ui && yarn test:flat:build:tests && yarn test:flat:build:locales", "test:flat:build:tests": "node test/integration/index.js", @@ -39,7 +39,7 @@ "lint:fix": "eslint . --ext js,json --fix", "lint:changed": "{ git ls-files --others --exclude-standard ; git diff-index --name-only --diff-filter=d HEAD ; } | grep --regexp='[.]js$' --regexp='[.]json$' | tr '\\n' '\\0' | xargs -0 eslint", "lint:changed:fix": "{ git ls-files --others --exclude-standard ; git diff-index --name-only --diff-filter=d HEAD ; } | grep --regexp='[.]js$' --regexp='[.]json$' | tr '\\n' '\\0' | xargs -0 eslint --fix", - "lint:shellcheck": "shellcheck --version && find . -type f -name '*.sh' ! -path './node_modules/*' -print0 | xargs -0 shellcheck", + "lint:shellcheck": "./development/shellcheck.sh", "verify-locales": "node ./development/verify-locale-strings.js", "verify-locales:fix": "node ./development/verify-locale-strings.js --fix", "mozilla-lint": "addons-linter dist/firefox",