Skip to content

Commit 0a91dd6

Browse files
committed
Add make targets: fmt/shfmt and lint/shellcheck
1 parent 76760a6 commit 0a91dd6

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

Makefile

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ fmt/terraform: $(wildcard *.tf)
4141
terraform fmt -recursive
4242
.PHONY: fmt/terraform
4343

44-
fmt: fmt/prettier fmt/terraform
44+
fmt/shfmt: $(shell shfmt -f .)
45+
@echo "--- shfmt"
46+
# Only do diff check in CI, errors on diff.
47+
ifdef CI
48+
shfmt -d $(shell shfmt -f .)
49+
else
50+
shfmt -w $(shell shfmt -f .)
51+
endif
52+
53+
fmt: fmt/prettier fmt/terraform fmt/shfmt
4554
.PHONY: fmt
4655

4756
gen: coderd/database/querier.go peerbroker/proto/peerbroker.pb.go provisionersdk/proto/provisioner.pb.go provisionerd/proto/provisionerd.pb.go site/src/api/typesGenerated.ts
@@ -53,9 +62,16 @@ install: build
5362
@echo "-- CLI available at $(shell ls $(INSTALL_DIR)/coder*)"
5463
.PHONY: install
5564

56-
lint:
65+
lint: lint/shellcheck lint/go
66+
67+
lint/go:
5768
golangci-lint run
58-
.PHONY: lint
69+
.PHONY: lint/go
70+
71+
# Use shfmt to determine the shell files, takes editorconfig into consideration.
72+
lint/shellcheck: $(shell shfmt -f .)
73+
@echo "--- shellcheck"
74+
shellcheck $(shell shfmt -f .)
5975

6076
peerbroker/proto/peerbroker.pb.go: peerbroker/proto/peerbroker.proto
6177
protoc \

site/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ indent_size = 2
55
[*.go]
66
indent_style = tab
77
indent_size = unset
8+
9+
[node_modules/**]
10+
ignore = true

0 commit comments

Comments
 (0)