Skip to content

Commit

Permalink
Add linting and fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Evertras committed Jan 27, 2024
1 parent a7014a4 commit 9624c5c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .evertras/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ files=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')

[ -z "$files" ] && exit 0

make lint

echo "$files" | xargs npx prettier --ignore-unknown --write
echo "$files" | xargs nixfmt
go fmt ./...
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.51.1
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ coverage.out: $(GO_FILES)

################################################################################
# Lint / Format
.PHONY: lint
lint: git-hooks
golangci-lint run ./...

.PHONY: fmt
fmt: node_modules git-hooks
go fmt ./...
Expand Down
5 changes: 4 additions & 1 deletion cmd/yakdash/cmds/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ func init() {

flags.StringVarP(&cfgFile, "config", "c", "", "The config file to use")

viper.BindPFlags(flags)
err := viper.BindPFlags(flags)
if err != nil {
log.Fatal("Failed to bind flags:", err)
}
}

func initConfig() {
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
go

# For dev tools
golangci-lint
nixfmt
nodejs_21
];
Expand Down
6 changes: 3 additions & 3 deletions pkg/yakdash/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func New(l layout.Root) model {
var p []panes.Pane
var allPanes []panes.Pane

var makePane func(node layout.Node) panes.Pane
makePane = func(node layout.Node) panes.Pane {
Expand Down Expand Up @@ -37,11 +37,11 @@ func New(l layout.Root) model {
}

for _, node := range l.Screens {
p = append(p, makePane(node))
allPanes = append(allPanes, makePane(node))
}

return model{
layout: l,
rootPane: makePane(l.Screens[0]),
rootPane: allPanes[0],
}
}

0 comments on commit 9624c5c

Please sign in to comment.