Skip to content

Commit

Permalink
Add prettier to pre-commit & sane default config
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ committed Mar 10, 2022
1 parent 0f44fe9 commit bdaadbc
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 34 deletions.
7 changes: 4 additions & 3 deletions .gitpod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
66 changes: 36 additions & 30 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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?)$
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"tabWidth": 4,
"endOfLine": "auto",
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion .werft/jobs/build/validate-changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit bdaadbc

Please sign in to comment.