From d8e0dc96ac7e8e69497447eea7e5d3543f5927d7 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Fri, 16 Sep 2022 22:25:45 -0700 Subject: [PATCH] refactor: add eslint job and yarn script --- .github/workflows/build.yaml | 47 ++++++++++++++++++++++++++++++++++++ ci/dev/lint.sh | 1 - package.json | 1 + 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 8669ce9f6..08b36b247 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -108,6 +108,53 @@ jobs: if: failure() uses: andymckay/cancel-action@0.2 + lint-ts: + name: Lint TypeScript files + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Get changed files + id: changed-files + uses: tj-actions/changed-files@v23.2 + with: + files: | + **.ts + **.tsx + **.js + files_ignore: | + lib/vscode + + - name: Install Node.js v16 + if: steps.changed-files.outputs.any_changed == 'true' + uses: actions/setup-node@v3 + with: + node-version: "16" + + - name: Fetch dependencies from cache + if: steps.changed-files.outputs.any_changed == 'true' + id: cache-yarn + uses: actions/cache@v3 + with: + path: "node_modules" + key: yarn-build-${{ hashFiles('yarn.lock') }} + restore-keys: | + yarn-build- + + - name: Install dependencies + if: steps.changed-files.outputs.any_changed == 'true' && steps.cache-yarn.outputs.cache-hit != 'true' + run: SKIP_SUBMODULE_DEPS=1 yarn --frozen-lockfile + + - name: Lint TypeScript files + if: steps.changed-files.outputs.any_changed == 'true' + run: yarn lint:ts + + - name: Fail workflow + if: failure() + uses: andymckay/cancel-action@0.2 + lint-helm: name: Lint Helm chart runs-on: ubuntu-latest diff --git a/ci/dev/lint.sh b/ci/dev/lint.sh index f0d7ae586..1542dc224 100755 --- a/ci/dev/lint.sh +++ b/ci/dev/lint.sh @@ -4,7 +4,6 @@ set -euo pipefail main() { cd "$(dirname "$0")/../.." - eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js" | grep -v "lib/vscode") tsc --noEmit --skipLibCheck cd "$OLDPWD" diff --git a/package.json b/package.json index 72659fffc..dd0cef023 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "lint": "./ci/dev/lint.sh", "lint:helm": "./ci/dedv/helm.sh", "lint:sh": "shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files '*.sh' | grep -v 'lib/vscode')", + "lint:ts": "eslint --max-warnings=0 --fix $(git ls-files '*.ts' '*.tsx' '*.js' | grep -v 'lib/vscode')", "test": "echo 'Run yarn test:unit or yarn test:e2e' && exit 1", "ci": "./ci/dev/ci.sh", "watch": "VSCODE_DEV=1 VSCODE_IPC_HOOK_CLI= NODE_OPTIONS='--max_old_space_size=32384 --trace-warnings' ts-node ./ci/dev/watch.ts",