-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprecious.toml
More file actions
165 lines (152 loc) · 4.31 KB
/
precious.toml
File metadata and controls
165 lines (152 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# When adding new tidiers, consider what labels it should have. If it's fast, set labels like this:
#
# labels = [ "default", "fast-tidy" ]
#
# "Fast" here means anything less than 0.1s. These tidiers are intended to be invoked frequently,
# for example from editors on save. Slower tidiers should only be invoked manually, either by
# running the relevant mage command or by explicitly running `precious` from the CLI.
exclude = [
"vendor/**",
]
[commands.golangci-lint]
type = "both"
include = "**/*.go"
# Based on my local testing, this seemed like a reasonable value for this option.
invoke.per-dir-or-once = 7
working-dir = "root"
path-args = "dir"
cmd = [
"mise", "exec", "github:golangci/golangci-lint", "--",
"golangci-lint",
"run",
"--allow-parallel-runners",
"--color", "always",
"--timeout", "5m",
]
tidy-flags = "--fix"
ok-exit-codes = [0]
lint-failure-exit-codes = [1]
ignore-stderr = 'Skipped \d+ issues by rules:'
[commands.goimports]
type = "both"
include = "**/*.go"
invoke = "once"
path-args = "file"
cmd = "$PRECIOUS_ROOT/etc/goimports-wrapper.sh"
lint-flags = "--lint"
ok-exit-codes = [0]
# We could run this via golangci-lint but we want to exclude more directories
# for gosec than we do for other linting. There doesn't seem to be a way to
# configure these excludes when running gosec as part of golangci-lint.
[commands.gosec]
type = "lint"
include = "**/*.go"
exclude = [
"cmd/**/*.go",
]
invoke = "once"
working-dir = "root"
path-args = "dir"
# This wrapper lets us control the output with an env var so we can generate a
# SARIF report in Evergreen but use the default format for linting.
cmd = [ "$PRECIOUS_ROOT/etc/gosec-wrapper.sh", "-severity", "high", "-terse" ]
ok-exit-codes = [0]
lint-failure-exit-codes = [1]
[commands.prettier-yaml]
type = "both"
invoke = "once"
working-dir = "root"
path-args = "file"
include = [ "**/*.yml", "**/*.yaml" ]
cmd = [ "mise", "exec", "npm:prettier", "--", "prettier" ]
lint-flags = "--check"
tidy-flags = "--write"
ok-exit-codes = [0]
lint-failure-exit-codes = [1]
ignore-stderr = ".*"
[commands.prettier-json]
type = "both"
invoke = "once"
working-dir = "root"
path-args = "file"
include = [ "**/*.json", "**/*.json" ]
cmd = [ "mise", "exec", "npm:prettier", "--", "prettier" ]
lint-flags = "--check"
tidy-flags = "--write"
ok-exit-codes = [0]
lint-failure-exit-codes = [1]
ignore-stderr = ".*"
[commands.prettier-md]
type = "both"
invoke = "once"
working-dir = "root"
path-args = "file"
include = [ "*.md" ]
cmd = [
"mise", "exec", "npm:prettier", "--",
"prettier",
"--print-width", "100",
"--prose-wrap", "always",
]
lint-flags = "--check"
tidy-flags = "--write"
ok-exit-codes = [0]
lint-failure-exit-codes = [1]
ignore-stderr = ".*"
[commands.omegasort-gitignore]
type = "both"
include = "**/.gitignore"
cmd = [ "mise", "exec", "github:houseabsolute/omegasort", "--", "omegasort", "--sort=path", "--comment-prefix=# ", "--unique" ]
lint-flags = "--check"
tidy-flags = "--in-place"
ok-exit-codes = 0
lint-failure-exit-codes = 1
ignore-stderr = ".*"
[commands.shellcheck]
type = "lint"
include = "**/*.sh"
cmd = [ "mise", "exec", "github:koalaman/shellcheck", "--", "shellcheck", "--color=always", "--external-sources" ]
ok-exit-codes = 0
lint-failure-exit-codes = 1
[commands.shfmt]
type = "both"
include = "**/*.sh"
cmd = [ "mise", "exec", "github:mvdan/sh", "--", "shfmt", "--simplify", "--indent", "4" ]
lint-flags = "--diff"
tidy-flags = "--write"
ok-exit-codes = 0
lint-failure-exit-codes = 1
[commands.golines]
type = "both"
include = "**/*.go"
invoke = "once"
working-dir = "root"
path-args = "file"
# This wrapper will tidy or lint based on the presence of the "--lint" flag.
cmd = "$PRECIOUS_ROOT/etc/golines-wrapper.sh"
lint-flags = "--lint"
ok-exit-codes = [0]
lint-failure-exit-codes = [1]
[commands.github-codeowners]
type = "lint"
invoke = "once"
path-args = "none"
# We need to run this whenever new files are added to make sure they have an owner, so it's easiest
# to just apply this linter to all files.
include = "**/*"
cmd = [ "$PRECIOUS_ROOT/etc/github-codeowners-wrapper.sh" ]
ok-exit-codes = 0
lint-failure-exit-codes = 1
[commands.typos]
type = "both"
include = "**/*"
exclude = [
".golangci.yml",
".mailmap",
"go.mod",
]
cmd = [ "typos", "--sort" ]
tidy-flags = "--write-changes"
invoke = "once"
ok-exit-codes = 0
lint-failure-exit-codes = 2