From bdaadbccca0d152f36a6767b39099a4ac9458b06 Mon Sep 17 00:00:00 2001 From: Milan Pavlik Date: Tue, 8 Mar 2022 10:21:40 +0000 Subject: [PATCH] Add prettier to pre-commit & sane default config --- .gitpod.yml | 7 +-- .pre-commit-config.yaml | 66 +++++++++++++++------------ .prettierrc.json | 6 +++ .werft/jobs/build/validate-changes.ts | 2 +- 4 files changed, 47 insertions(+), 34 deletions(-) create mode 100644 .prettierrc.json diff --git a/.gitpod.yml b/.gitpod.yml index b647f30fbe3ab9..307695d657c99d 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -14,15 +14,15 @@ ports: onOpen: ignore - port: 9229 onOpen: ignore -# Go proxy + # Go proxy - port: 9999 onOpen: ignore - port: 13001 onOpen: ignore -# Werft + # Werft - port: 7777 onOpen: ignore -# Dev Theia + # Dev Theia - port: 13444 tasks: - name: Add Harvester kubeconfig @@ -38,6 +38,7 @@ tasks: before: scripts/branch-namespace.sh init: yarn --network-timeout 100000 && yarn build - name: Go + before: pre-commit install init: leeway exec --filter-type go -v -- go mod verify openMode: split-right vscode: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6c9b4d502d75e9..bd25f176e1058c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,34 +1,40 @@ repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 - hooks: - #- id: check-yaml - # args: [--allow-multiple-documents] - # - id: end-of-file-fixer - - id: trailing-whitespace - exclude: .*/src/main/java/io/gitpod/supervisor/api/.* + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.1.0 + hooks: + #- id: check-yaml + # args: [--allow-multiple-documents] + # - id: end-of-file-fixer + - id: trailing-whitespace + exclude: .*/src/main/java/io/gitpod/supervisor/api/.* - - id: check-symlinks - - id: mixed-line-ending - - id: check-case-conflict - - id: check-executables-have-shebangs - - id: check-shebang-scripts-are-executable - - id: check-merge-conflict + - id: check-symlinks + - id: mixed-line-ending + - id: check-case-conflict + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: check-merge-conflict + # keep fork in sync! + - repo: https://github.com/gitpod-io/pre-commit-hooks + rev: "2.1.5" + hooks: + - id: forbid-binary + exclude: | + (?x)^( + .*example-layer.tar.gz| + .*\.(png|svg|ico|gpg)| + dev/version-manifest/version-manifest| + .*gradle-wrapper\.jar + )$ + - id: script-must-have-extension + - id: shellcheck + args: [-e, "SC1090,SC1091"] + exclude: .*/gradlew$ -# keep fork in sync! -- repo: https://github.com/gitpod-io/pre-commit-hooks - rev: "2.1.5" - hooks: - - id: forbid-binary - exclude: | - (?x)^( - .*example-layer.tar.gz| - .*\.(png|svg|ico|gpg)| - dev/version-manifest/version-manifest| - .*gradle-wrapper\.jar - )$ - - id: script-must-have-extension - - id: shellcheck - args: [-e, "SC1090,SC1091"] - exclude: .*/gradlew$ + - repo: https://github.com/pre-commit/mirrors-prettier + rev: "v2.5.1" + hooks: + - id: prettier + # Only enabled for WebApp components initially, to build consensus and incrementally onboard others + files: ^components\/(server|gitpod-protocol|gitpod-db|dashboard)\/.*\.ts(x?)$ diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 00000000000000..277fe37db9982f --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,6 @@ +{ + "printWidth": 120, + "tabWidth": 4, + "endOfLine": "auto", + "trailingComma": "all" +} diff --git a/.werft/jobs/build/validate-changes.ts b/.werft/jobs/build/validate-changes.ts index 11b402a44669a4..76445468e124b6 100644 --- a/.werft/jobs/build/validate-changes.ts +++ b/.werft/jobs/build/validate-changes.ts @@ -29,7 +29,7 @@ async function branchNameCheck(werft: Werft, config: JobConfig) { async function preCommitCheck(werft: Werft) { werft.log("pre-commit checks", "Running pre-commit hooks.") - const preCommitCmd = exec(`pre-commit run --all-files --show-diff-on-failure`, { slice: "pre-commit checks" }); + const preCommitCmd = exec(`pre-commit run --show-diff-on-failure`, { slice: "pre-commit checks" }); if (preCommitCmd.code != 0) { throw new Error(preCommitCmd.stderr.toString().trim())