mvvmlint
mvvmlint: state goes through the view-model
go-widgets/mvvmlint fires only in
packages that import the toolkit.
- A widget’s state field assigned by hand.
entry.Text = "x", where the static type ofentryis a toolkit widget andTextis a state field, is flagged.&entry.Text— what the binders take — is not an assignment and is never flagged; neither is a composite literal (toolkit.Entry{Text: "x"}), nor composing a callback such asOnChange. - Widgets and no view-model. A package that imports the toolkit but not
go-widgets/mvvmgets one diagnostic.-requirevm=falseturns this off for a widget library that legitimately has no view-model.
The state fields are those of the toolkit’s widgets (Text, Items, Rows,
Root, Selected, Value, Checked, …); -statefields= replaces the list.
A file named *_binding.go, or containing //mvvmlint:allow, is exempt from
the first rule.
go install github.com/go-widgets/mvvmlint/cmd/mvvmlint@latest
go vet -vettool="$(go env GOPATH)/bin/mvvmlint" ./...# .github/workflows/mvvm.yml
name: mvvm
on:
pull_request:
push:
branches: [main]
jobs:
mvvm:
uses: go-widgets/mvvmlint/.github/workflows/mvvmlint.yml@mainapp-template ships with this job.
Created on by tannevaled
Modified on by tannevaled