@radicaltools/cli 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +353 -33
- package/dist/hub-catalogue/concern/concern-api-collections.radical +1136 -0
- package/dist/hub-catalogue/concern/concern-api-errors.radical +1180 -0
- package/dist/hub-catalogue/concern/concern-api-evolution.radical +1174 -0
- package/dist/hub-catalogue/concern/concern-api-idempotency.radical +1218 -0
- package/dist/hub-catalogue/concern/concern-api-resource-design.radical +1102 -0
- package/dist/hub-catalogue/concern/concern-api-style-guide.radical +1210 -0
- package/dist/hub-catalogue/concern/concern-architecture-style.radical +1268 -0
- package/dist/hub-catalogue/concern/concern-audit-trail.radical +1096 -0
- package/dist/hub-catalogue/concern/concern-authentication.radical +895 -0
- package/dist/hub-catalogue/concern/concern-authorization.radical +1686 -0
- package/dist/hub-catalogue/concern/concern-availability.radical +1028 -0
- package/dist/hub-catalogue/concern/concern-backend-stack.radical +1037 -0
- package/dist/hub-catalogue/concern/concern-backup-recovery.radical +1560 -0
- package/dist/hub-catalogue/concern/concern-caching.radical +1294 -0
- package/dist/hub-catalogue/concern/concern-capacity.radical +915 -0
- package/dist/hub-catalogue/concern/concern-code-documentation.radical +1397 -0
- package/dist/hub-catalogue/concern/concern-code-quality-gate.radical +1409 -0
- package/dist/hub-catalogue/concern/concern-code-review-branching.radical +1416 -0
- package/dist/hub-catalogue/concern/concern-code-style.radical +1058 -0
- package/dist/hub-catalogue/concern/concern-communication-style.radical +1508 -0
- package/dist/hub-catalogue/concern/concern-data-classification.radical +970 -0
- package/dist/hub-catalogue/concern/concern-data-consistency.radical +1112 -0
- package/dist/hub-catalogue/concern/concern-data-store.radical +1282 -0
- package/dist/hub-catalogue/concern/concern-decomposition.radical +1318 -0
- package/dist/hub-catalogue/concern/concern-definition-of-done.radical +1214 -0
- package/dist/hub-catalogue/concern/concern-delivery-metrics.radical +966 -0
- package/dist/hub-catalogue/concern/concern-dependency-hygiene.radical +1345 -0
- package/dist/hub-catalogue/concern/concern-deployment.radical +1203 -0
- package/dist/hub-catalogue/concern/concern-encryption.radical +1318 -0
- package/dist/hub-catalogue/concern/concern-error-handling-logging.radical +1197 -0
- package/dist/hub-catalogue/concern/concern-eu-dora.radical +1321 -0
- package/dist/hub-catalogue/concern/concern-frontend-stack.radical +1647 -0
- package/dist/hub-catalogue/concern/concern-incident-management.radical +1204 -0
- package/dist/hub-catalogue/concern/concern-infrastructure.radical +2183 -0
- package/dist/hub-catalogue/concern/concern-integration-resilience.radical +1116 -0
- package/dist/hub-catalogue/concern/concern-messaging.radical +973 -0
- package/dist/hub-catalogue/concern/concern-module-boundaries.radical +867 -0
- package/dist/hub-catalogue/concern/concern-observability.radical +997 -0
- package/dist/hub-catalogue/concern/concern-operational-readiness.radical +1249 -0
- package/dist/hub-catalogue/concern/concern-personal-data.radical +1949 -0
- package/dist/hub-catalogue/concern/concern-quality-priorities.radical +1091 -0
- package/dist/hub-catalogue/concern/concern-rate-limiting.radical +1445 -0
- package/dist/hub-catalogue/concern/concern-release-versioning.radical +1358 -0
- package/dist/hub-catalogue/concern/concern-retention.radical +1399 -0
- package/dist/hub-catalogue/concern/concern-secrets.radical +1284 -0
- package/dist/hub-catalogue/concern/concern-secure-coding.radical +1379 -0
- package/dist/hub-catalogue/concern/concern-secure-development.radical +1245 -0
- package/dist/hub-catalogue/concern/concern-security-detection.radical +1153 -0
- package/dist/hub-catalogue/concern/concern-supply-chain.radical +1386 -0
- package/dist/hub-catalogue/concern/concern-technical-debt.radical +1450 -0
- package/dist/hub-catalogue/concern/concern-technology-lifecycle.radical +1145 -0
- package/dist/hub-catalogue/concern/concern-tenant-isolation.radical +1440 -0
- package/dist/hub-catalogue/concern/concern-test-strategy.radical +1212 -0
- package/dist/hub-catalogue/concern/concern-threat-modelling.radical +1143 -0
- package/dist/index.js +12712 -7144
- package/package.json +5 -3
|
@@ -0,0 +1,1058 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hub": {
|
|
3
|
+
"id": "concern-code-style",
|
|
4
|
+
"category": "concern",
|
|
5
|
+
"name": "Code style and conventions",
|
|
6
|
+
"description": "How the code looks and reads, so that a diff shows only what changed in meaning: which formatter and how far it is configured, which style guide covers what the formatter leaves open, how names are checked, what editors do on save, and how reformatting stays out of git blame. The snippets are for a repository with TypeScript (Prettier or Biome) and Python (Ruff); each tool line names the equivalents for Go, Kotlin, Java and C#.",
|
|
7
|
+
"tags": [
|
|
8
|
+
"maintainability",
|
|
9
|
+
"code style",
|
|
10
|
+
"formatting",
|
|
11
|
+
"style guide",
|
|
12
|
+
"naming conventions",
|
|
13
|
+
"editorconfig"
|
|
14
|
+
],
|
|
15
|
+
"requiredMetamodel": "c4-ddd-governance-builtin",
|
|
16
|
+
"concern": {
|
|
17
|
+
"id": "code-style",
|
|
18
|
+
"trigger": "LIST NODES WHERE (type = \"container\" OR type = \"webapp\") AND external != true",
|
|
19
|
+
"why": "code lives in these elements, so how it is formatted, named and laid out has to be decided; one decision usually covers a whole repository and is bound to every element built from it.",
|
|
20
|
+
"group": "coding"
|
|
21
|
+
},
|
|
22
|
+
"sources": [
|
|
23
|
+
{
|
|
24
|
+
"title": "Prettier: Option Philosophy",
|
|
25
|
+
"url": "https://prettier.io/docs/option-philosophy"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"title": "Prettier: Configuration File (EditorConfig, how the file is found)",
|
|
29
|
+
"url": "https://prettier.io/docs/configuration"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"title": "Prettier: Install (an exact version for everyone)",
|
|
33
|
+
"url": "https://prettier.io/docs/install"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"title": "Biome: Formatter",
|
|
37
|
+
"url": "https://biomejs.dev/formatter/"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"title": "Ruff: The Ruff Formatter",
|
|
41
|
+
"url": "https://docs.astral.sh/ruff/formatter/"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"title": "EditorConfig Specification",
|
|
45
|
+
"url": "https://spec.editorconfig.org/"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"title": "Google Style Guides (TypeScript, Java, Python, Shell and others)",
|
|
49
|
+
"url": "https://google.github.io/styleguide/"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"title": "PEP 8: Style Guide for Python Code",
|
|
53
|
+
"url": "https://peps.python.org/pep-0008/"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"title": "Effective Go (not actively updated since 2009; read with Go Code Review Comments)",
|
|
57
|
+
"url": "https://go.dev/doc/effective_go"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"title": "Go Code Review Comments",
|
|
61
|
+
"url": "https://go.dev/wiki/CodeReviewComments"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"title": "Kotlin: Coding conventions",
|
|
65
|
+
"url": "https://kotlinlang.org/docs/coding-conventions.html"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"title": "Microsoft: .NET C# coding conventions",
|
|
69
|
+
"url": "https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"title": "typescript-eslint: naming-convention",
|
|
73
|
+
"url": "https://typescript-eslint.io/rules/naming-convention/"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"title": "pre-commit: a framework for managing git hooks",
|
|
77
|
+
"url": "https://pre-commit.com/"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"title": "GitHub Docs: Ignore commits in the blame view",
|
|
81
|
+
"url": "https://docs.github.com/en/repositories/working-with-files/using-files/viewing-and-understanding-files"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"title": "Git: git-blame (blame.ignoreRevsFile)",
|
|
85
|
+
"url": "https://git-scm.com/docs/git-blame"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"templateParams": [
|
|
89
|
+
{
|
|
90
|
+
"key": "FORMATTER",
|
|
91
|
+
"title": "Formatter",
|
|
92
|
+
"label": "How far is the formatter configured?",
|
|
93
|
+
"hint": "That a formatter runs on commit and in CI is decided in the Code quality gate pack; this decides which formatter each language gets and how many of its options the team sets. Every option is a style argument the formatter was meant to end.",
|
|
94
|
+
"defaultValue": "defaults",
|
|
95
|
+
"options": [
|
|
96
|
+
{
|
|
97
|
+
"value": "defaults",
|
|
98
|
+
"label": "an opinionated formatter on its defaults",
|
|
99
|
+
"description": "One opinionated formatter per language, configured no further than the minimum (by default one option, the line width): Prettier or Biome for TypeScript and JavaScript, Ruff format or Black for Python, gofmt, ktlint, google-java-format, dotnet format. The whole tree is reformatted once in a commit hidden from blame. Pick it for new code, and for existing code whenever one reformatting commit is affordable."
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"value": "matched",
|
|
103
|
+
"label": "a formatter configured to match the existing code",
|
|
104
|
+
"description": "The same formatters, with the options set so that the existing code changes as little as possible (quote style, indentation, line width), each option kept with a comment naming the convention it preserves. Pick it for a large existing codebase with many long-lived branches, where reformatting every line would conflict with all of them, or where a published convention the code follows (a framework's, a customer's) differs from the tool's defaults."
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"key": "GUIDE",
|
|
110
|
+
"title": "Style guide",
|
|
111
|
+
"label": "Which style guide covers what the formatter leaves open?",
|
|
112
|
+
"hint": "A formatter decides layout; naming, file organisation, imports and idioms still need a written rule. A published guide is free and well argued; a guide of your own fits the team but has to be kept short to be read.",
|
|
113
|
+
"defaultValue": "published",
|
|
114
|
+
"options": [
|
|
115
|
+
{
|
|
116
|
+
"value": "published",
|
|
117
|
+
"label": "the published guide of each language",
|
|
118
|
+
"description": "Each language follows its published guide as it is: PEP 8 for Python, the Google TypeScript and Java Style Guides, the Kotlin coding conventions, Effective Go with Go Code Review Comments, the Microsoft C# coding conventions; CONTRIBUTING.md links them and the team amends none. Pick it by default, and whenever nobody on the team wants to maintain a guide."
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"value": "own",
|
|
122
|
+
"label": "our own short guide built on a published one",
|
|
123
|
+
"description": "A short guide of the team's own in docs/STYLE.md (30 rules at most by default), each rule naming the published rule it adopts or changes and whether a lint rule or the reviewer checks it. Pick it when the team has conventions no published guide covers (domain terms in names, module layout, test naming), or several languages need one voice."
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"key": "NAMING",
|
|
129
|
+
"title": "Naming",
|
|
130
|
+
"label": "How are the naming rules checked?",
|
|
131
|
+
"hint": "Names carry most of what a reader learns from code. A naming rule the linter checks is never argued about in review; one that only the reviewer checks depends on who reviews.",
|
|
132
|
+
"defaultValue": "linted",
|
|
133
|
+
"options": [
|
|
134
|
+
{
|
|
135
|
+
"value": "linted",
|
|
136
|
+
"label": "lint rules at error severity",
|
|
137
|
+
"description": "The guide's naming rules are lint rules at error severity: typescript-eslint naming-convention, Ruff's pep8-naming rules (N801 class names, N802 function names, N803 arguments, N806 variables), ktlint's class-, function- and property-naming, IDE1006 for C#, staticcheck ST1003 for Go. Pick it by default."
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"value": "written",
|
|
141
|
+
"label": "written rules checked in review",
|
|
142
|
+
"description": "The naming rules are written in the guide with an example of a right and a wrong name for each kind of identifier, and the reviewer checks them. Pick it when the linter of a language has no naming rule that expresses the convention (domain terms, abbreviations), or for short-lived code."
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"key": "EDITOR",
|
|
148
|
+
"title": "Editors",
|
|
149
|
+
"label": "How do editors follow the style?",
|
|
150
|
+
"hint": "An editor that formats on save in the project's way keeps the commit hook from ever changing anything; an editor left to each developer is their own business, and the hook catches what it misses.",
|
|
151
|
+
"defaultValue": "shared",
|
|
152
|
+
"options": [
|
|
153
|
+
{
|
|
154
|
+
"value": "shared",
|
|
155
|
+
"label": "committed editor settings with format on save",
|
|
156
|
+
"description": "Besides .editorconfig, the repository commits .vscode/settings.json (format on save, the project's formatter per language) and .vscode/extensions.json recommending the formatter's extension, which uses the project's own formatter version. Pick it when most of the team uses VS Code or an editor that reads its settings, and new people should be set up by opening the folder."
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"value": "editorconfig",
|
|
160
|
+
"label": ".editorconfig alone",
|
|
161
|
+
"description": "Only .editorconfig is shared (charset, line endings, indentation, final newline, line width); no editor-specific settings are committed, and each developer configures format on save in their own editor. Pick it when the team uses many different editors, or settings in the repository have caused conflicts."
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"key": "LINE_WIDTH",
|
|
167
|
+
"label": "Which line width do the formatters and .editorconfig share (characters)?",
|
|
168
|
+
"defaultValue": "100",
|
|
169
|
+
"type": "number"
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"key": "MAX_FORMAT_OPTIONS",
|
|
173
|
+
"label": "How many formatting options may a formatter's configuration set at most? (an opinionated formatter on its defaults only)",
|
|
174
|
+
"defaultValue": "1",
|
|
175
|
+
"type": "number"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"key": "MAX_GUIDE_RULES",
|
|
179
|
+
"label": "How many rules may our own style guide hold at most? (our own guide only)",
|
|
180
|
+
"defaultValue": "30",
|
|
181
|
+
"type": "number"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"key": "BLAME_DAYS",
|
|
185
|
+
"label": "Within how many days must a reformatting commit be listed in .git-blame-ignore-revs?",
|
|
186
|
+
"defaultValue": "2",
|
|
187
|
+
"type": "number"
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
"nodes": [
|
|
192
|
+
{
|
|
193
|
+
"id": "need",
|
|
194
|
+
"type": "need",
|
|
195
|
+
"label": "A diff shows only what changed in meaning",
|
|
196
|
+
"x": 0,
|
|
197
|
+
"y": 0,
|
|
198
|
+
"kind": "brief",
|
|
199
|
+
"source": "Hub concern pack: Code style and conventions",
|
|
200
|
+
"description": "The element is read and changed by many people over years. Its code has to look the same whoever wrote it, so that a diff shows what changed in meaning and nothing else, a reviewer spends no time on layout or taste, a name tells the reader what a thing is, and git blame leads to the change that gave a line its meaning, not to the commit that reformatted it. The snippets assume the formatter settings at the repository root (.editorconfig, .prettierrc.json or biome.json, pyproject.toml with Ruff pinned among the development dependencies, .pre-commit-config.yaml where the Python hook comes from pre-commit), CONTRIBUTING.md at the root, the team's own guide, if there is one, in docs/STYLE.md, and GitHub Actions as CI."
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"id": "req-one-config",
|
|
204
|
+
"type": "requirement",
|
|
205
|
+
"label": "Formatter settings in one place",
|
|
206
|
+
"x": 260,
|
|
207
|
+
"y": 0,
|
|
208
|
+
"ears_type": "ubiquitous",
|
|
209
|
+
"action": "keep the settings of each language's formatter in one configuration file at the repository root, with 0 nested formatter configuration files and 0 formatting options passed on a command line, so that a file is formatted the same wherever it lies and whoever runs the formatter",
|
|
210
|
+
"rationale": "Prettier looks for its configuration from the formatted file upwards, so a .prettierrc in a subfolder silently formats that folder differently, and an option on a command line applies only where that command runs (Prettier, Configuration File)."
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"id": "req-same-version",
|
|
214
|
+
"type": "requirement",
|
|
215
|
+
"label": "One formatter version everywhere",
|
|
216
|
+
"x": 260,
|
|
217
|
+
"y": 130,
|
|
218
|
+
"ears_type": "ubiquitous",
|
|
219
|
+
"action": "run each formatter in one exact version pinned in the repository (Prettier or Biome without a range in package.json, ruff==x.y.z among the Python development dependencies), with the commit hook and the editor using that same version, so that 0 files change when another machine runs the formatter",
|
|
220
|
+
"rationale": "Even a patch release of Prettier can format differently, which is why Prettier and Biome both install with an exact version (Prettier, Install); pre-commit installs a hook's own copy at the rev in .pre-commit-config.yaml, which drifts from the project's version unless it is kept equal (pre-commit)."
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"id": "req-blame-ignore",
|
|
224
|
+
"type": "requirement",
|
|
225
|
+
"label": "Reformatting hidden from blame",
|
|
226
|
+
"x": 260,
|
|
227
|
+
"y": 260,
|
|
228
|
+
"ears_type": "event-driven",
|
|
229
|
+
"trigger": "a commit that changes a formatter's settings or version, with the reformatting it causes, reaches the main branch",
|
|
230
|
+
"action": "list its full SHA, under a comment saying what it changed, in .git-blame-ignore-revs at the repository root within {{BLAME_DAYS}} days, so that git blame with blame.ignoreRevsFile set and the forge's blame view skip it",
|
|
231
|
+
"rationale": "A reformatting commit touches thousands of lines and hides who changed each one and why; GitHub's blame view skips the commits listed in .git-blame-ignore-revs at the root (GitHub Docs, Ignore commits in the blame view), and git blame does the same with blame.ignoreRevsFile, one unabbreviated object name per line (git-blame)."
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"id": "req-editorconfig",
|
|
235
|
+
"type": "requirement",
|
|
236
|
+
"label": "Editors follow one .editorconfig",
|
|
237
|
+
"x": 260,
|
|
238
|
+
"y": 390,
|
|
239
|
+
"ears_type": "ubiquitous",
|
|
240
|
+
"action": "keep a root .editorconfig (root = true) whose [*] section sets charset utf-8, end_of_line lf, insert_final_newline true, trim_trailing_whitespace true and max_line_length {{LINE_WIDTH}}, with indentation per file type, agreeing with every formatter setting it overlaps, and keep 0 tracked text files that break it",
|
|
241
|
+
"rationale": "EditorConfig makes every editor, and the files no formatter covers (shell scripts, Makefiles, Dockerfiles), follow the same basic style (EditorConfig Specification); Prettier reads indentation, line endings and line width from it, so setting them once there leaves no second value to drift (Prettier, Configuration File)."
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"id": "req-defaults",
|
|
245
|
+
"type": "requirement",
|
|
246
|
+
"label": "Formatters on their defaults",
|
|
247
|
+
"x": 260,
|
|
248
|
+
"y": 520,
|
|
249
|
+
"ears_type": "ubiquitous",
|
|
250
|
+
"action": "format each language with its opinionated formatter on its defaults, with no more than {{MAX_FORMAT_OPTIONS}} formatting options set in each formatter's configuration file, besides the files it ignores and the settings it reads from .editorconfig",
|
|
251
|
+
"rationale": "The point of a formatter is to end the debates over style; with options, they become debates over which options to use, which is why Prettier accepts no new ones and Biome deliberately resists them (Prettier, Option Philosophy; Biome, Formatter); Effective Go lets the machine take care of formatting for the same reason.",
|
|
252
|
+
"hubWhen": {
|
|
253
|
+
"FORMATTER": [
|
|
254
|
+
"defaults"
|
|
255
|
+
]
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"id": "req-matched",
|
|
260
|
+
"type": "requirement",
|
|
261
|
+
"label": "Every option says what it keeps",
|
|
262
|
+
"x": 260,
|
|
263
|
+
"y": 650,
|
|
264
|
+
"ears_type": "ubiquitous",
|
|
265
|
+
"action": "set only the formatter options needed to keep a convention the existing code already follows, each preceded in its configuration file by a comment naming that convention, and change an option only in a pull request that reformats the whole tree with it",
|
|
266
|
+
"rationale": "An option without a reason is the next style debate waiting to happen (Prettier, Option Philosophy); the comment keeps the reason next to the option, so that when the convention no longer matters the option can go (Ruff, The Ruff Formatter, exposes only a few options beyond Black's, such as quote style, indent style and line endings).",
|
|
267
|
+
"hubWhen": {
|
|
268
|
+
"FORMATTER": [
|
|
269
|
+
"matched"
|
|
270
|
+
]
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"id": "req-guide-published",
|
|
275
|
+
"type": "requirement",
|
|
276
|
+
"label": "Published guides, unamended",
|
|
277
|
+
"x": 260,
|
|
278
|
+
"y": 780,
|
|
279
|
+
"ears_type": "ubiquitous",
|
|
280
|
+
"action": "follow, for each language in the element, the published style guide the decision names, linked from CONTRIBUTING.md, with 0 local amendments; a rule the team wants changed supersedes the decision",
|
|
281
|
+
"rationale": "A published guide comes with its reasons already argued (PEP 8; Google Style Guides; Kotlin, Coding conventions; Go Code Review Comments; Microsoft, C# coding conventions); amendments made one review at a time turn it into an unwritten guide of the team's own.",
|
|
282
|
+
"hubWhen": {
|
|
283
|
+
"GUIDE": [
|
|
284
|
+
"published"
|
|
285
|
+
]
|
|
286
|
+
}
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
"id": "req-guide-own",
|
|
290
|
+
"type": "requirement",
|
|
291
|
+
"label": "Our guide stays short and sourced",
|
|
292
|
+
"x": 260,
|
|
293
|
+
"y": 910,
|
|
294
|
+
"ears_type": "ubiquitous",
|
|
295
|
+
"action": "keep the team's style guide in docs/STYLE.md, linked from CONTRIBUTING.md, with at most {{MAX_GUIDE_RULES}} rules, each naming the published guide and section it adopts or changes and whether a lint rule (by its id) or the reviewer checks it",
|
|
296
|
+
"rationale": "A guide of the team's own is read only while it is short, and trusted only where each rule says where it comes from (PEP 8: a style guide is about consistency; Google Style Guides); a rule that says who checks it is not left to whoever happens to review.",
|
|
297
|
+
"hubWhen": {
|
|
298
|
+
"GUIDE": [
|
|
299
|
+
"own"
|
|
300
|
+
]
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
"id": "req-naming-linted",
|
|
305
|
+
"type": "requirement",
|
|
306
|
+
"label": "Names checked by the linter",
|
|
307
|
+
"x": 260,
|
|
308
|
+
"y": 1040,
|
|
309
|
+
"ears_type": "ubiquitous",
|
|
310
|
+
"action": "check the guide's naming rules with the linter at error severity (typescript-eslint naming-convention; Ruff's pep8-naming N rules; ktlint's class-, function- and property-naming; IDE1006 at error in .editorconfig for C#; staticcheck ST1003 for Go), so that a name that breaks them fails the commit hook and CI",
|
|
311
|
+
"rationale": "A naming rule the linter checks is applied the same way to every change and never argued about in review (typescript-eslint, naming-convention; PEP 8, Naming Conventions); at warning severity it is ignored.",
|
|
312
|
+
"hubWhen": {
|
|
313
|
+
"NAMING": [
|
|
314
|
+
"linted"
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"id": "req-naming-reviewed",
|
|
320
|
+
"type": "requirement",
|
|
321
|
+
"label": "Names checked in review",
|
|
322
|
+
"x": 260,
|
|
323
|
+
"y": 1170,
|
|
324
|
+
"ears_type": "ubiquitous",
|
|
325
|
+
"action": "write the naming rules in the style guide with an example of a right and a wrong name for each kind of identifier (type, function, variable, constant, file), and check the names of every change against them in review",
|
|
326
|
+
"rationale": "Where no lint rule can express a convention (domain terms, abbreviations), the written rule and its examples are what the reviewer checks against (PEP 8, Naming Conventions; Kotlin, Coding conventions: naming rules).",
|
|
327
|
+
"unchecked": "The reviewer, in every pull request review, against the naming rules of the guide; no lint rule checks them in this variant.",
|
|
328
|
+
"hubWhen": {
|
|
329
|
+
"NAMING": [
|
|
330
|
+
"written"
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
"id": "req-editor-shared",
|
|
336
|
+
"type": "requirement",
|
|
337
|
+
"label": "Editors format on save",
|
|
338
|
+
"x": 260,
|
|
339
|
+
"y": 1300,
|
|
340
|
+
"ears_type": "ubiquitous",
|
|
341
|
+
"action": "commit editor settings that format every file on save with the project's own formatter: .vscode/settings.json with editor.formatOnSave true and a default formatter for each language in the repository, and .vscode/extensions.json recommending that formatter's extension",
|
|
342
|
+
"rationale": "Code formatted while it is written never reaches the commit hook unformatted; an editor that formats with the project's own pinned version formats as CI does, which is why everyone has to get the exact same version (Prettier, Install).",
|
|
343
|
+
"hubWhen": {
|
|
344
|
+
"EDITOR": [
|
|
345
|
+
"shared"
|
|
346
|
+
]
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
"id": "req-editor-own",
|
|
351
|
+
"type": "requirement",
|
|
352
|
+
"label": "Only .editorconfig shared",
|
|
353
|
+
"x": 260,
|
|
354
|
+
"y": 1430,
|
|
355
|
+
"ears_type": "ubiquitous",
|
|
356
|
+
"action": "commit no editor-specific settings (.vscode/settings.json, .idea/, *.code-workspace, .zed/, .fleet/), so that .editorconfig is the only editor configuration in the repository and each developer's own editor settings stay theirs",
|
|
357
|
+
"rationale": "Settings of one editor committed for everyone conflict with the settings of the others and change with every personal preference; .editorconfig is read by most editors and carries what they must agree on (EditorConfig Specification).",
|
|
358
|
+
"hubWhen": {
|
|
359
|
+
"EDITOR": [
|
|
360
|
+
"editorconfig"
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"id": "sc-one-config",
|
|
366
|
+
"type": "scenario",
|
|
367
|
+
"label": "Second configuration refused",
|
|
368
|
+
"x": 520,
|
|
369
|
+
"y": 0,
|
|
370
|
+
"given": "the repository with its formatter settings at the root",
|
|
371
|
+
"when": "a pull request adds a .prettierrc.json under src/legacy, and another adds --print-width 120 to the format script",
|
|
372
|
+
"then": "the check fails on both, naming the file and the line"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"id": "sc-same-version",
|
|
376
|
+
"type": "scenario",
|
|
377
|
+
"label": "Version drift refused",
|
|
378
|
+
"x": 520,
|
|
379
|
+
"y": 130,
|
|
380
|
+
"given": "package.json with \"prettier\": \"^3.6.0\", and a pre-commit rev of ruff one release behind the version pyproject.toml pins",
|
|
381
|
+
"when": "the check runs",
|
|
382
|
+
"then": "it fails on both, naming the version to pin"
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
"id": "sc-blame-ignore",
|
|
386
|
+
"type": "scenario",
|
|
387
|
+
"label": "Unlisted reformat flagged",
|
|
388
|
+
"x": 520,
|
|
389
|
+
"y": 260,
|
|
390
|
+
"given": "a commit on main that raised the Prettier version and reformatted 40 files",
|
|
391
|
+
"when": "the daily check runs {{BLAME_DAYS}} days later and the SHA is not in .git-blame-ignore-revs",
|
|
392
|
+
"then": "the check fails naming the commit; once the SHA is listed it passes and git blame skips the commit"
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
"id": "sc-editorconfig",
|
|
396
|
+
"type": "scenario",
|
|
397
|
+
"label": "File breaking .editorconfig refused",
|
|
398
|
+
"x": 520,
|
|
399
|
+
"y": 390,
|
|
400
|
+
"given": "the root .editorconfig and pyproject.toml",
|
|
401
|
+
"when": "a pull request adds a shell script with CRLF line endings, and another sets Ruff's line-length to 120 while .editorconfig says {{LINE_WIDTH}}",
|
|
402
|
+
"then": "the first fails the .editorconfig check naming the file, and the second fails the consistency check naming both values"
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
"id": "sc-defaults",
|
|
406
|
+
"type": "scenario",
|
|
407
|
+
"label": "Extra option refused",
|
|
408
|
+
"x": 520,
|
|
409
|
+
"y": 520,
|
|
410
|
+
"given": "a .prettierrc.json that sets only the line width",
|
|
411
|
+
"when": "a pull request adds \"singleQuote\": true to it",
|
|
412
|
+
"then": "the check fails: the file now sets more than {{MAX_FORMAT_OPTIONS}} options",
|
|
413
|
+
"hubWhen": {
|
|
414
|
+
"FORMATTER": [
|
|
415
|
+
"defaults"
|
|
416
|
+
]
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
"id": "sc-matched",
|
|
421
|
+
"type": "scenario",
|
|
422
|
+
"label": "Unexplained option refused",
|
|
423
|
+
"x": 520,
|
|
424
|
+
"y": 650,
|
|
425
|
+
"given": "a .prettierrc.yaml whose options each follow a comment naming the convention",
|
|
426
|
+
"when": "a pull request adds tabWidth: 4 without a comment above it",
|
|
427
|
+
"then": "the check fails naming the line",
|
|
428
|
+
"hubWhen": {
|
|
429
|
+
"FORMATTER": [
|
|
430
|
+
"matched"
|
|
431
|
+
]
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
"id": "sc-guide-published",
|
|
436
|
+
"type": "scenario",
|
|
437
|
+
"label": "Missing guide link refused",
|
|
438
|
+
"x": 520,
|
|
439
|
+
"y": 780,
|
|
440
|
+
"given": "a repository with TypeScript and Python files",
|
|
441
|
+
"when": "CONTRIBUTING.md links only PEP 8, and a pull request adds docs/STYLE.md",
|
|
442
|
+
"then": "the check fails naming the missing Google TypeScript Style Guide link and the amending file",
|
|
443
|
+
"hubWhen": {
|
|
444
|
+
"GUIDE": [
|
|
445
|
+
"published"
|
|
446
|
+
]
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"id": "sc-guide-own",
|
|
451
|
+
"type": "scenario",
|
|
452
|
+
"label": "Guide kept short",
|
|
453
|
+
"x": 520,
|
|
454
|
+
"y": 910,
|
|
455
|
+
"given": "docs/STYLE.md with {{MAX_GUIDE_RULES}} rules",
|
|
456
|
+
"when": "a pull request adds one more rule, and another adds a rule without a Checked by line",
|
|
457
|
+
"then": "both fail the check, naming the count and the rule",
|
|
458
|
+
"hubWhen": {
|
|
459
|
+
"GUIDE": [
|
|
460
|
+
"own"
|
|
461
|
+
]
|
|
462
|
+
}
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"id": "sc-naming-linted",
|
|
466
|
+
"type": "scenario",
|
|
467
|
+
"label": "Wrong name refused",
|
|
468
|
+
"x": 520,
|
|
469
|
+
"y": 1040,
|
|
470
|
+
"given": "the linter configuration",
|
|
471
|
+
"when": "a pull request adds a TypeScript class named order_service and a Python function named GetOrder",
|
|
472
|
+
"then": "the linter reports both at error severity and the check fails",
|
|
473
|
+
"hubWhen": {
|
|
474
|
+
"NAMING": [
|
|
475
|
+
"linted"
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
"id": "sc-naming-reviewed",
|
|
481
|
+
"type": "scenario",
|
|
482
|
+
"label": "Reviewer checks names",
|
|
483
|
+
"x": 520,
|
|
484
|
+
"y": 1170,
|
|
485
|
+
"given": "the naming rules in the guide",
|
|
486
|
+
"when": "a pull request adds a function whose name breaks one of them",
|
|
487
|
+
"then": "the reviewer asks for the name to be changed, citing the rule, before approving",
|
|
488
|
+
"hubWhen": {
|
|
489
|
+
"NAMING": [
|
|
490
|
+
"written"
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"id": "sc-editor-shared",
|
|
496
|
+
"type": "scenario",
|
|
497
|
+
"label": "Settings shared",
|
|
498
|
+
"x": 520,
|
|
499
|
+
"y": 1300,
|
|
500
|
+
"given": "a repository with TypeScript and Python files",
|
|
501
|
+
"when": "the check reads the committed editor settings",
|
|
502
|
+
"then": "format on save is on, both languages have a default formatter, and each formatter's extension is recommended",
|
|
503
|
+
"hubWhen": {
|
|
504
|
+
"EDITOR": [
|
|
505
|
+
"shared"
|
|
506
|
+
]
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
{
|
|
510
|
+
"id": "sc-editor-own",
|
|
511
|
+
"type": "scenario",
|
|
512
|
+
"label": "Editor settings stay out",
|
|
513
|
+
"x": 520,
|
|
514
|
+
"y": 1430,
|
|
515
|
+
"given": "the repository",
|
|
516
|
+
"when": "a pull request adds .vscode/settings.json",
|
|
517
|
+
"then": "the check fails naming the file",
|
|
518
|
+
"hubWhen": {
|
|
519
|
+
"EDITOR": [
|
|
520
|
+
"editorconfig"
|
|
521
|
+
]
|
|
522
|
+
}
|
|
523
|
+
},
|
|
524
|
+
{
|
|
525
|
+
"id": "adr-format-defaults",
|
|
526
|
+
"type": "adr",
|
|
527
|
+
"label": "Opinionated formatters on their defaults",
|
|
528
|
+
"x": 780,
|
|
529
|
+
"y": 0,
|
|
530
|
+
"concern": "code-style",
|
|
531
|
+
"status": "accepted",
|
|
532
|
+
"date": "",
|
|
533
|
+
"context": "Code lives in this element and is read far more often than it is written, by people who did not write it; how it looks decides whether a diff shows what changed in meaning or drowns it in moved braces, and whether review time goes to design or to taste. The forces: a formatter ends the arguments about layout, but every option it offers starts a new argument about the option; adopting or upgrading a formatter rewrites thousands of lines at once and buries who wrote what under one commit; two versions of the same formatter, or a second configuration file in a subfolder, format the same file two ways and every save produces a diff; a published style guide costs nothing to adopt but leaves the team's own conventions unwritten, while a guide of the team's own grows until nobody reads it; naming rules nobody checks are kept by whoever reviews; and editors that format on save in one way and the commit hook in another fight over every file. Running the formatter on commit and checking it in CI, and the lint rules that find bugs, are the Code quality gate's decision; comments and documentation are the Code documentation pack's; how errors and logs are written is the Error handling and logging pack's; the review itself is the Code review and branching pack's.",
|
|
534
|
+
"decision": "Each language is formatted by its opinionated formatter on its defaults: Prettier for TypeScript, JavaScript, JSON, CSS and Markdown (or Biome, which formats and lints in one tool), Ruff format for Python (Black-compatible; Black where Ruff is not used), gofmt for Go, ktlint with the ktlint_official code style for Kotlin, google-java-format for Java, dotnet format for C#. A formatter's configuration file sets no more than {{MAX_FORMAT_OPTIONS}} formatting options besides the files it ignores; the line width ({{LINE_WIDTH}}), indentation and line endings are set once in the root .editorconfig, which Prettier, ktlint and dotnet format read, and Ruff's line-length is set to the same value. Each formatter is pinned to one exact version, used alike by the commit hook, CI and the editor. Adopting the formatter, upgrading it or changing an option is a pull request of its own that reformats the whole tree and changes nothing else, and its commit is listed in .git-blame-ignore-revs. That the formatter runs on commit and is checked in CI is the Code quality gate's decision. Style guide: {{GUIDE}}. Naming: {{NAMING}}. Editors: {{EDITOR}}.",
|
|
535
|
+
"consequences": "• Layout is never discussed in review again; every file looks the same whoever wrote it.\n• The first adoption reformats most lines at once: every open branch conflicts and has to be rebased with the formatter run on it, and blame needs the ignore file to stay useful.\n• Some defaults will annoy someone (Prettier's 80 columns, Biome's tabs); the decision accepts that, and the line width is the one setting the team chose.\n• A formatter upgrade can change hundreds of lines; with an exact pin it arrives as one reviewed, blame-ignored pull request instead of noise in unrelated changes.\n• The exact pin of the formatter is an exception to any range policy for dependencies, which the formatters' own install guides ask for.",
|
|
536
|
+
"alternatives": "1. A formatter configured to match the existing code: fewer lines change at adoption, but every option is a style argument kept alive and a setting to maintain.\n2. No formatter, style left to the reviewer: no adoption cost, and a style comment in every review for as long as the code lives.\n3. A different formatter per team or folder: each team gets its taste, and every cross-team change reformats the files it touches.",
|
|
537
|
+
"hubWhen": {
|
|
538
|
+
"FORMATTER": [
|
|
539
|
+
"defaults"
|
|
540
|
+
]
|
|
541
|
+
}
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"id": "adr-format-matched",
|
|
545
|
+
"type": "adr",
|
|
546
|
+
"label": "Formatters configured to match the existing code",
|
|
547
|
+
"x": 780,
|
|
548
|
+
"y": 130,
|
|
549
|
+
"concern": "code-style",
|
|
550
|
+
"status": "accepted",
|
|
551
|
+
"date": "",
|
|
552
|
+
"context": "Code lives in this element and is read far more often than it is written, by people who did not write it; how it looks decides whether a diff shows what changed in meaning or drowns it in moved braces, and whether review time goes to design or to taste. The forces: a formatter ends the arguments about layout, but every option it offers starts a new argument about the option; adopting or upgrading a formatter rewrites thousands of lines at once and buries who wrote what under one commit; two versions of the same formatter, or a second configuration file in a subfolder, format the same file two ways and every save produces a diff; a published style guide costs nothing to adopt but leaves the team's own conventions unwritten, while a guide of the team's own grows until nobody reads it; naming rules nobody checks are kept by whoever reviews; and editors that format on save in one way and the commit hook in another fight over every file. Running the formatter on commit and checking it in CI, and the lint rules that find bugs, are the Code quality gate's decision; comments and documentation are the Code documentation pack's; how errors and logs are written is the Error handling and logging pack's; the review itself is the Code review and branching pack's.",
|
|
553
|
+
"decision": "Each language is formatted by one formatter (Prettier or Biome, Ruff format, gofmt, ktlint, google-java-format, dotnet format), configured so that the existing code changes as little as possible: an option is set only to keep a convention the code already follows (quote style, indentation, trailing commas, the line width of {{LINE_WIDTH}}), and each is preceded by a comment naming that convention, so the settings live in files that hold comments (.prettierrc.yaml, pyproject.toml, .editorconfig). Formatters without options (gofmt, google-java-format) run on their defaults. Each formatter is pinned to one exact version, used alike by the commit hook, CI and the editor. Changing an option, or upgrading a formatter, is a pull request of its own that reformats the whole tree, and its commit is listed in .git-blame-ignore-revs. That the formatter runs on commit and is checked in CI is the Code quality gate's decision. Style guide: {{GUIDE}}. Naming: {{NAMING}}. Editors: {{EDITOR}}.",
|
|
554
|
+
"consequences": "• Adoption changes few lines, so long-lived branches keep merging and blame stays mostly intact.\n• Every option is a style choice the team made and may argue about again; the comment on each says why it is there and when it could go.\n• Options interact with formatter upgrades: a new release may treat an option differently, and the configuration needs reading at each major version.\n• Code copied from elsewhere, or from tools that write code (generators, assistants), arrives in the formatter's defaults and is reformatted on commit.\n• The exact pin of the formatter is an exception to any range policy for dependencies, which the formatters' own install guides ask for.",
|
|
555
|
+
"alternatives": "1. An opinionated formatter on its defaults: nothing to argue about or maintain, at the cost of one large reformatting commit.\n2. Formatting only the files a change touches: no big commit, but the code stays in two styles for years and every touched file shows unrelated reformatting in its diff.\n3. No formatter: no adoption cost, and layout argued in every review.",
|
|
556
|
+
"hubWhen": {
|
|
557
|
+
"FORMATTER": [
|
|
558
|
+
"matched"
|
|
559
|
+
]
|
|
560
|
+
}
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
"id": "adr-guide-published",
|
|
564
|
+
"type": "adr",
|
|
565
|
+
"label": "Published style guides, as they are",
|
|
566
|
+
"x": 780,
|
|
567
|
+
"y": 260,
|
|
568
|
+
"concern": "code-style",
|
|
569
|
+
"status": "accepted",
|
|
570
|
+
"date": "",
|
|
571
|
+
"context": "Code lives in this element and is read far more often than it is written, by people who did not write it; how it looks decides whether a diff shows what changed in meaning or drowns it in moved braces, and whether review time goes to design or to taste. The forces: a formatter ends the arguments about layout, but every option it offers starts a new argument about the option; adopting or upgrading a formatter rewrites thousands of lines at once and buries who wrote what under one commit; two versions of the same formatter, or a second configuration file in a subfolder, format the same file two ways and every save produces a diff; a published style guide costs nothing to adopt but leaves the team's own conventions unwritten, while a guide of the team's own grows until nobody reads it; naming rules nobody checks are kept by whoever reviews; and editors that format on save in one way and the commit hook in another fight over every file. Running the formatter on commit and checking it in CI, and the lint rules that find bugs, are the Code quality gate's decision; comments and documentation are the Code documentation pack's; how errors and logs are written is the Error handling and logging pack's; the review itself is the Code review and branching pack's.",
|
|
572
|
+
"decision": "What the formatter leaves open (naming, imports, file and module organisation, idioms) follows each language's published guide as it is: PEP 8 for Python, the Google TypeScript Style Guide for TypeScript and JavaScript, the Google Java Style Guide for Java, the Kotlin coding conventions for Kotlin, Effective Go read with Go Code Review Comments for Go (Effective Go is not updated for generics or modules), and the Microsoft C# coding conventions for C#. CONTRIBUTING.md links the guide of every language in the repository; the team amends none of them, and a rule it wants to change supersedes this decision. The Airbnb JavaScript Style Guide is not used: its ESLint preset does not support ESLint 9 and its flat configuration.",
|
|
573
|
+
"consequences": "• No guide to write or maintain; newcomers know the rules from other projects, and every rule comes with its reasons.\n• Where the guide and the formatter disagree on layout, the formatter wins; the guide matters for everything else.\n• Conventions of the team's own (domain terms, module layout) stay unwritten unless they become a decision.\n• A guide that changes upstream changes the team's rules without a pull request; the links point at the current version.",
|
|
574
|
+
"alternatives": "1. Our own short guide built on a published one: covers the team's conventions, and has to be kept short and current.\n2. No guide: every reviewer applies their own, and the same change gets different comments from different people.\n3. The Airbnb JavaScript Style Guide: widely known, but its lint preset has not followed ESLint into flat configuration.",
|
|
575
|
+
"hubWhen": {
|
|
576
|
+
"GUIDE": [
|
|
577
|
+
"published"
|
|
578
|
+
]
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
"id": "adr-guide-own",
|
|
583
|
+
"type": "adr",
|
|
584
|
+
"label": "Our own short style guide",
|
|
585
|
+
"x": 780,
|
|
586
|
+
"y": 390,
|
|
587
|
+
"concern": "code-style",
|
|
588
|
+
"status": "accepted",
|
|
589
|
+
"date": "",
|
|
590
|
+
"context": "Code lives in this element and is read far more often than it is written, by people who did not write it; how it looks decides whether a diff shows what changed in meaning or drowns it in moved braces, and whether review time goes to design or to taste. The forces: a formatter ends the arguments about layout, but every option it offers starts a new argument about the option; adopting or upgrading a formatter rewrites thousands of lines at once and buries who wrote what under one commit; two versions of the same formatter, or a second configuration file in a subfolder, format the same file two ways and every save produces a diff; a published style guide costs nothing to adopt but leaves the team's own conventions unwritten, while a guide of the team's own grows until nobody reads it; naming rules nobody checks are kept by whoever reviews; and editors that format on save in one way and the commit hook in another fight over every file. Running the formatter on commit and checking it in CI, and the lint rules that find bugs, are the Code quality gate's decision; comments and documentation are the Code documentation pack's; how errors and logs are written is the Error handling and logging pack's; the review itself is the Code review and branching pack's.",
|
|
591
|
+
"decision": "What the formatter leaves open follows the team's own guide in docs/STYLE.md, linked from CONTRIBUTING.md and built on the published guide of each language (PEP 8, the Google TypeScript and Java Style Guides, the Kotlin coding conventions, Effective Go with Go Code Review Comments, the Microsoft C# coding conventions). The guide holds at most {{MAX_GUIDE_RULES}} rules; each is a heading \"### S<n>. <rule>\" followed by a \"Based on:\" line naming the published guide and section it adopts or changes, and a \"Checked by:\" line naming the lint rule by its id, or \"review\". Whatever the guide does not say, the published guide decides. A rule is added or changed by a pull request to the guide, reviewed like code.",
|
|
592
|
+
"consequences": "• The team's own conventions (domain terms in names, module layout, test naming) are written down and checked, not remembered.\n• The guide is short enough to be read in one sitting, and each rule says where it comes from and who checks it.\n• Someone has to keep the guide current; past {{MAX_GUIDE_RULES}} rules, adding one means removing or merging another.\n• Rules checked by review only depend on who reviews; the \"Checked by\" line makes that visible, and moving a rule to a lint rule is the way out.",
|
|
593
|
+
"alternatives": "1. The published guide of each language, as it is: nothing to write, and the team's own conventions stay unwritten.\n2. A long guide covering everything: complete on the day it is written, unread a month later.\n3. Conventions kept only in lint configuration: checked, but without the reasons a reader needs.",
|
|
594
|
+
"hubWhen": {
|
|
595
|
+
"GUIDE": [
|
|
596
|
+
"own"
|
|
597
|
+
]
|
|
598
|
+
}
|
|
599
|
+
},
|
|
600
|
+
{
|
|
601
|
+
"id": "ff-one-config",
|
|
602
|
+
"type": "fitness-fn",
|
|
603
|
+
"label": "One formatter configuration, at the root",
|
|
604
|
+
"x": 1040,
|
|
605
|
+
"y": 0,
|
|
606
|
+
"characteristic": "maintainability",
|
|
607
|
+
"scope": "atomic",
|
|
608
|
+
"cadence": "triggered",
|
|
609
|
+
"trigger": "pull-request",
|
|
610
|
+
"invocation": "automated",
|
|
611
|
+
"description": "A CI step lists the tracked formatter configuration files outside the root (Prettier, Biome, Ruff, .editorconfig, a [tool.ruff] table in a nested pyproject.toml) and greps the places that run a formatter for formatting flags; either fails the step. A monorepo that needs a package of its own configuration lists it here as an exception, in the same pull request.\n\nThreshold: 0 formatter configuration files below the repository root and 0 formatting options on a formatter's command line in package.json, Makefile, shell scripts, workflows and .pre-commit-config.yaml\n\nTool: git ls-files and git grep in a CI step (the same over build.gradle.kts for ktlint and Spotless, or Directory.Build.props for dotnet format)\n\n```bash\n#!/usr/bin/env bash\n# CI step: each formatter's settings live in one file at the repository root\nset -euo pipefail\nnested=$(git ls-files -- '*/.prettierrc*' '*/prettier.config.*' '*/biome.json' '*/biome.jsonc' '*/ruff.toml' '*/.ruff.toml' '*/.editorconfig'\n git grep -l -e '^\\[tool\\.ruff' -- '*/pyproject.toml' || true)\n[ -z \"$nested\" ] || { echo \"formatter settings below the root; move them to the root file:\"; echo \"$nested\"; exit 1; }\nflags=$(git grep -nE -e '(prettier|biome format|ruff format|black)[^|;&]*--(print-width|tab-width|use-tabs|single-quote|no-semi|trailing-comma|line-width|indent-width|indent-style|line-length|skip-string-normalization)' \\\n -- package.json Makefile '*.sh' '.github/workflows/*' .pre-commit-config.yaml || true)\n[ -z \"$flags\" ] || { echo \"formatting options on a command line; put them in the root file:\"; echo \"$flags\"; exit 1; }\necho \"formatter settings: one file per language, at the root\"\n```"
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
"id": "ff-version-match",
|
|
615
|
+
"type": "fitness-fn",
|
|
616
|
+
"label": "One exact formatter version",
|
|
617
|
+
"x": 1040,
|
|
618
|
+
"y": 130,
|
|
619
|
+
"characteristic": "maintainability",
|
|
620
|
+
"scope": "atomic",
|
|
621
|
+
"cadence": "triggered",
|
|
622
|
+
"trigger": "pull-request",
|
|
623
|
+
"invocation": "automated",
|
|
624
|
+
"description": "A CI step reads the formatter versions from package.json and compares the rev of the ruff-pre-commit hook with the version pyproject.toml pins. On the Node side the hook (lint-staged) and the editor (the Prettier and Biome extensions use the project's installed copy first) run the version in node_modules, so an exact pin is enough; on the Python side pre-commit installs a copy of its own, which this keeps equal, and the Ruff extension finds Ruff in the environment first (ruff.importStrategy fromEnvironment, its default).\n\nThreshold: Prettier and Biome pinned without a range in package.json; the ruff-pre-commit rev equal to the ruff==x.y.z pinned in pyproject.toml; the step fails on any difference\n\nTool: jq, grep and sed in a CI step (for Kotlin and Java: the ktlint or Spotless version in libs.versions.toml; for C#: the SDK version in global.json)\n\n```bash\n#!/usr/bin/env bash\n# CI step: one exact formatter version, for the commit hook, CI and the editor alike\nset -euo pipefail\nfail=0\nfor tool in prettier @biomejs/biome; do\n v=$(jq -r --arg t \"$tool\" '(.devDependencies // {})[$t] // empty' package.json 2>/dev/null || true)\n [ -z \"$v\" ] || [[ \"$v\" =~ ^[0-9]+\\.[0-9]+\\.[0-9]+$ ]] || { echo \"package.json: $tool is $v; pin it exactly (npm i -D -E $tool)\"; fail=1; }\ndone\nif [ -f .pre-commit-config.yaml ] && grep -q 'astral-sh/ruff-pre-commit' .pre-commit-config.yaml; then\n hook=$(grep -A2 'astral-sh/ruff-pre-commit' .pre-commit-config.yaml | sed -n 's/^ *rev: *v\\{0,1\\}\\([0-9.]*\\).*/\\1/p')\n pinned=$(grep -oE '\"ruff==[0-9.]+\"' pyproject.toml | grep -oE '[0-9.]*[0-9]' || true)\n [ \"$hook\" = \"$pinned\" ] || { echo \"pre-commit runs ruff $hook, pyproject.toml pins ruff==$pinned; make them equal\"; fail=1; }\nfi\nexit $fail\n```"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
"id": "ff-blame-ignore",
|
|
628
|
+
"type": "fitness-fn",
|
|
629
|
+
"label": "Reformatting commits listed for blame",
|
|
630
|
+
"x": 1040,
|
|
631
|
+
"y": 260,
|
|
632
|
+
"characteristic": "maintainability",
|
|
633
|
+
"scope": "atomic",
|
|
634
|
+
"cadence": "triggered",
|
|
635
|
+
"trigger": "nightly",
|
|
636
|
+
"invocation": "automated",
|
|
637
|
+
"description": "A daily job on main lists every commit whose diff changes a formatter version or a formatting setting in package.json, pyproject.toml, the formatter configuration or .editorconfig, and looks for its full SHA in .git-blame-ignore-revs. Listing a version bump that reformatted nothing is harmless: blame skips only the lines that commit changed. Each developer runs git config blame.ignoreRevsFile .git-blame-ignore-revs once (or the repository's setup script does); GitHub reads the file by itself.\n\nThreshold: 0 commits older than {{BLAME_DAYS}} days that changed a formatter's settings or version and are missing from .git-blame-ignore-revs; younger ones are reported as warnings\n\nTool: git log -G in a scheduled GitHub Actions job (actions/checkout with fetch-depth: 0)\n\n```bash\n#!/usr/bin/env bash\n# run daily on main by .github/workflows/blame-ignore.yml (actions/checkout with fetch-depth: 0)\nset -euo pipefail\n# changed lines that mean \"a formatter's settings or version changed\"\nSETTINGS='\"(prettier|@biomejs/biome)\": \"|ruff==|black==|printWidth|tabWidth|useTabs|lineWidth|indentWidth|indentStyle|line-length|quote-style|indent-style|indent_size|indent_style|max_line_length'\ncutoff=$(( $(date +%s) - {{BLAME_DAYS}} * 86400 ))\nlate=0\nwhile read -r sha committed; do\n grep -qx \"$sha\" .git-blame-ignore-revs 2>/dev/null && continue\n if [ \"$committed\" -lt \"$cutoff\" ]; then\n echo \"::error::$sha changed a formatter's settings or version and is not in .git-blame-ignore-revs\"; late=1\n else\n echo \"::warning::$sha changed a formatter's settings or version; list it in .git-blame-ignore-revs\"\n fi\ndone < <(git log --format='%H %ct' -G \"$SETTINGS\" HEAD -- package.json pyproject.toml .prettierrc.json .prettierrc.yaml biome.json .editorconfig)\nexit $late\n```"
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
"id": "ff-editorconfig",
|
|
641
|
+
"type": "fitness-fn",
|
|
642
|
+
"label": "Every file follows .editorconfig",
|
|
643
|
+
"x": 1040,
|
|
644
|
+
"y": 390,
|
|
645
|
+
"characteristic": "maintainability",
|
|
646
|
+
"scope": "atomic",
|
|
647
|
+
"cadence": "triggered",
|
|
648
|
+
"trigger": "pull-request",
|
|
649
|
+
"invocation": "automated",
|
|
650
|
+
"description": "The root .editorconfig carries what every editor and every file must agree on; editorconfig-checker runs over the tracked files on every pull request and fails on any file that breaks it, which covers the files no formatter touches. Its line-length check is off, because the formatters decide where lines break and leave long strings and URLs whole.\n\nThreshold: 0 tracked text files that break the root .editorconfig (charset, line endings, final newline, trailing whitespace, indentation); line length is left to the formatters\n\nTool: editorconfig-checker (npm package editorconfig-checker, or its Docker image) in a CI step\n\n```ini\n# .editorconfig, at the repository root\nroot = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ninsert_final_newline = true\ntrim_trailing_whitespace = true\nindent_style = space\nindent_size = 2\nmax_line_length = {{LINE_WIDTH}}\n\n[*.py]\nindent_size = 4\n\n[{*.go,Makefile}]\nindent_style = tab\n\n[*.md]\ntrim_trailing_whitespace = false\n\n# CI step: npx --yes editorconfig-checker@7.0.0 -format github-actions -disable-max-line-length\n```"
|
|
651
|
+
},
|
|
652
|
+
{
|
|
653
|
+
"id": "ff-editorconfig-consistent",
|
|
654
|
+
"type": "fitness-fn",
|
|
655
|
+
"label": ".editorconfig agrees with the formatters",
|
|
656
|
+
"x": 1040,
|
|
657
|
+
"y": 520,
|
|
658
|
+
"characteristic": "maintainability",
|
|
659
|
+
"scope": "atomic",
|
|
660
|
+
"cadence": "triggered",
|
|
661
|
+
"trigger": "pull-request",
|
|
662
|
+
"invocation": "automated",
|
|
663
|
+
"description": "A script reads .editorconfig (with a section added for its preamble, so Python's configparser accepts it), checks the [*] section, refuses Prettier settings that .editorconfig already carries (Prettier reads them from it, so a second value could only disagree), and compares Ruff's line-length, which does not read .editorconfig, with the width set for Python files. For ktlint and dotnet format nothing needs comparing: they read their settings from .editorconfig itself.\n\nThreshold: .editorconfig has root = true and its [*] section sets charset utf-8, end_of_line lf, insert_final_newline, trim_trailing_whitespace and max_line_length {{LINE_WIDTH}}; .prettierrc.json sets none of printWidth, tabWidth, useTabs, endOfLine; Ruff's line-length equals the .editorconfig width for Python\n\nTool: Python 3.11 or later (configparser, tomllib) in a CI step\n\n```python\n# scripts/check_editorconfig.py (CI: python3 scripts/check_editorconfig.py): .editorconfig and the formatters agree\nimport configparser, json, pathlib, sys, tomllib\n\nec = configparser.ConfigParser(interpolation=None)\nec.read_string(\"[preamble]\\n\" + pathlib.Path(\".editorconfig\").read_text())\nstar = ec[\"*\"] if ec.has_section(\"*\") else {}\nproblems = [] if ec.get(\"preamble\", \"root\", fallback=\"\") == \"true\" else [\".editorconfig: no root = true before the first section\"]\nfor key, value in {\"charset\": \"utf-8\", \"end_of_line\": \"lf\", \"insert_final_newline\": \"true\", \"trim_trailing_whitespace\": \"true\", \"max_line_length\": \"{{LINE_WIDTH}}\"}.items():\n if star.get(key) != value:\n problems.append(f\".editorconfig [*]: {key} is {star.get(key)}, should be {value}\")\nprettier = pathlib.Path(\".prettierrc.json\")\nfor key in json.loads(prettier.read_text()) if prettier.exists() else []:\n if key in (\"printWidth\", \"tabWidth\", \"useTabs\", \"endOfLine\"):\n problems.append(f\".prettierrc.json sets {key}; set it once in .editorconfig, which Prettier reads\")\npyproject = pathlib.Path(\"pyproject.toml\")\nruff = tomllib.loads(pyproject.read_text()).get(\"tool\", {}).get(\"ruff\", {}) if pyproject.exists() else {}\npy_width = ec.get(\"*.py\", \"max_line_length\", fallback=star.get(\"max_line_length\"))\nif ruff and str(ruff.get(\"line-length\", 88)) != py_width:\n problems.append(f\"pyproject.toml [tool.ruff] line-length is {ruff.get('line-length', 88)}, .editorconfig says {py_width} for *.py\")\nprint(\"\\n\".join(problems) or \".editorconfig agrees with the formatters\")\nsys.exit(1 if problems else 0)\n```"
|
|
664
|
+
},
|
|
665
|
+
{
|
|
666
|
+
"id": "ff-minimal-config",
|
|
667
|
+
"type": "fitness-fn",
|
|
668
|
+
"label": "Formatters stay on their defaults",
|
|
669
|
+
"x": 1040,
|
|
670
|
+
"y": 650,
|
|
671
|
+
"characteristic": "maintainability",
|
|
672
|
+
"scope": "atomic",
|
|
673
|
+
"cadence": "triggered",
|
|
674
|
+
"trigger": "pull-request",
|
|
675
|
+
"invocation": "automated",
|
|
676
|
+
"description": "A CI step counts the formatting options each configuration file sets, leaving out what is not a style choice ($schema, enabled, the files a formatter includes or ignores), and fails when one sets more than the decision allows. Settings read from .editorconfig are not counted: they are the shared ones. For ktlint the same count applies to the ktlint_ properties in .editorconfig; gofmt and google-java-format have no options to count.\n\nThreshold: At most {{MAX_FORMAT_OPTIONS}} formatting options in .prettierrc.json (overrides included), in biome.json's formatter sections, and in pyproject.toml's [tool.ruff] line-length and [tool.ruff.format]; the step fails above it\n\nTool: jq and Python (tomllib) in a CI step\n\n```bash\n#!/usr/bin/env bash\n# CI step: each formatter runs on its defaults\nset -euo pipefail\nMAX={{MAX_FORMAT_OPTIONS}}\nfail=0\ncheck() { echo \"$2: $1 formatting option(s)\"; [ \"$1\" -le \"$MAX\" ] || { echo \" more than $MAX: remove options or supersede the decision\"; fail=1; }; }\n[ ! -f .prettierrc.json ] || check \"$(jq '(del(.\"$schema\", .overrides) | length) + ([.overrides[]?.options | length] | add // 0)' .prettierrc.json)\" .prettierrc.json\n[ ! -f biome.json ] || check \"$(jq '[(.formatter // {} | del(.enabled, .includes)), .javascript.formatter, .json.formatter, .css.formatter] | map(. // {} | length) | add' biome.json)\" biome.json\n[ ! -f pyproject.toml ] || check \"$(python3 -c 'import tomllib; r = tomllib.load(open(\"pyproject.toml\", \"rb\")).get(\"tool\", {}).get(\"ruff\", {}); print(len(r.get(\"format\", {})) + (\"line-length\" in r))')\" \"pyproject.toml [tool.ruff]\"\nexit $fail\n```",
|
|
677
|
+
"hubWhen": {
|
|
678
|
+
"FORMATTER": [
|
|
679
|
+
"defaults"
|
|
680
|
+
]
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"id": "ff-option-reasons",
|
|
685
|
+
"type": "fitness-fn",
|
|
686
|
+
"label": "Every formatter option has its reason",
|
|
687
|
+
"x": 1040,
|
|
688
|
+
"y": 780,
|
|
689
|
+
"characteristic": "maintainability",
|
|
690
|
+
"scope": "atomic",
|
|
691
|
+
"cadence": "triggered",
|
|
692
|
+
"trigger": "pull-request",
|
|
693
|
+
"invocation": "automated",
|
|
694
|
+
"description": "A CI step walks the formatter configuration files and fails on an option whose line above is not a comment; the comment names the convention of the existing code that the option keeps. A pull request that changes an option is also a reformat of the whole tree, which the Code quality gate's formatter check over the whole tree enforces.\n\nThreshold: 0 formatter options in .prettierrc.yaml, pyproject.toml's [tool.ruff] line-length and [tool.ruff.format], and the [*.{kt,kts}] ktlint properties of .editorconfig without a comment on the line above\n\nTool: awk in a CI step\n\n```bash\n#!/usr/bin/env bash\n# CI step: every formatter option is preceded by a comment naming the convention it keeps\nset -euo pipefail\nstatus=0\nreasons() { # file, the section whose options need a reason ('' = the whole file), the option names to check\n awk -v f=\"$1\" -v section=\"$2\" -v keys=\"$3\" '\n /^\\[/ { inside = ($0 == section) }\n (section == \"\" || inside) && $0 ~ (\"^(\" keys \")[ ]*[:=]\") && prev !~ /^[ ]*#/ { print f \":\" NR \": \" $1 \" has no comment above it naming the convention it keeps\"; bad = 1 }\n { prev = $0 }\n END { exit bad }' \"$1\" || status=1\n}\n[ ! -f .prettierrc.yaml ] || reasons .prettierrc.yaml '' '[A-Za-z]+'\n[ ! -f pyproject.toml ] || reasons pyproject.toml '[tool.ruff]' 'line-length|indent-width'\n[ ! -f pyproject.toml ] || reasons pyproject.toml '[tool.ruff.format]' '[a-z-]+'\n[ ! -f .editorconfig ] || reasons .editorconfig '[*.{kt,kts}]' 'ktlint_[a-z_-]+'\nexit $status\n```",
|
|
695
|
+
"hubWhen": {
|
|
696
|
+
"FORMATTER": [
|
|
697
|
+
"matched"
|
|
698
|
+
]
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
"id": "ff-guide-linked",
|
|
703
|
+
"type": "fitness-fn",
|
|
704
|
+
"label": "Published guides linked, none amended",
|
|
705
|
+
"x": 1040,
|
|
706
|
+
"y": 910,
|
|
707
|
+
"characteristic": "maintainability",
|
|
708
|
+
"scope": "atomic",
|
|
709
|
+
"cadence": "triggered",
|
|
710
|
+
"trigger": "pull-request",
|
|
711
|
+
"invocation": "automated",
|
|
712
|
+
"description": "A CI step looks for the files of each language, expects the link to its guide in CONTRIBUTING.md, and fails when a guide of the team's own appears, which would amend the published ones without a decision. For Go the link is Go Code Review Comments, the maintained companion of Effective Go.\n\nThreshold: CONTRIBUTING.md links the published guide of every language with tracked files in the repository, and no docs/STYLE.md exists\n\nTool: git ls-files and grep in a CI step\n\n```bash\n#!/usr/bin/env bash\n# CI step: CONTRIBUTING.md links the published guide of every language in the repository, and nothing amends them\nset -euo pipefail\nmissing=0\nwhile read -r ext guide; do\n [ \"$(git ls-files -- \"*.$ext\" | wc -l)\" -gt 0 ] || continue\n grep -qF \"$guide\" CONTRIBUTING.md || { echo \"CONTRIBUTING.md does not link the .$ext style guide: $guide\"; missing=1; }\ndone <<'GUIDES'\npy https://peps.python.org/pep-0008/\nts https://google.github.io/styleguide/tsguide.html\njava https://google.github.io/styleguide/javaguide.html\nkt https://kotlinlang.org/docs/coding-conventions.html\ngo https://go.dev/wiki/CodeReviewComments\ncs https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions\nGUIDES\n[ ! -e docs/STYLE.md ] || { echo \"docs/STYLE.md amends the published guides: supersede the decision first\"; missing=1; }\nexit $missing\n```",
|
|
713
|
+
"hubWhen": {
|
|
714
|
+
"GUIDE": [
|
|
715
|
+
"published"
|
|
716
|
+
]
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"id": "ff-guide-rules",
|
|
721
|
+
"type": "fitness-fn",
|
|
722
|
+
"label": "Our guide stays short and sourced",
|
|
723
|
+
"x": 1040,
|
|
724
|
+
"y": 1040,
|
|
725
|
+
"characteristic": "maintainability",
|
|
726
|
+
"scope": "atomic",
|
|
727
|
+
"cadence": "triggered",
|
|
728
|
+
"trigger": "pull-request",
|
|
729
|
+
"invocation": "automated",
|
|
730
|
+
"description": "A CI step reads docs/STYLE.md, where every rule is a heading \"### S<n>. <rule>\" followed by its \"Based on:\" and \"Checked by:\" lines, counts the rules and fails on a rule without either line, on more rules than the decision allows, or when CONTRIBUTING.md does not link the guide.\n\nThreshold: docs/STYLE.md holds between 1 and {{MAX_GUIDE_RULES}} rules, every rule has a \"Based on:\" and a \"Checked by:\" line, and CONTRIBUTING.md links it\n\nTool: awk and grep in a CI step\n\n```bash\n#!/usr/bin/env bash\n# CI step: docs/STYLE.md stays short, and every rule says where it comes from and who checks it\nset -euo pipefail\ngrep -qF 'docs/STYLE.md' CONTRIBUTING.md || { echo \"CONTRIBUTING.md does not link docs/STYLE.md\"; exit 1; }\nawk -v max={{MAX_GUIDE_RULES}} '\n function close_rule() { if (rule != \"\" && (!based || !checked)) { print \"docs/STYLE.md: \" rule \" lacks a Based on: or Checked by: line\"; bad = 1 } }\n /^### S[0-9]+\\./ { close_rule(); rule = $0; based = 0; checked = 0; n++ }\n /^Based on: ./ { based = 1 }\n /^Checked by: ./ { checked = 1 }\n END {\n close_rule()\n if (n == 0 || n > max) { print \"docs/STYLE.md holds \" n \" rules; it must hold 1 to \" max; bad = 1 }\n exit bad\n }' docs/STYLE.md\n```",
|
|
731
|
+
"hubWhen": {
|
|
732
|
+
"GUIDE": [
|
|
733
|
+
"own"
|
|
734
|
+
]
|
|
735
|
+
}
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"id": "ff-naming-lint",
|
|
739
|
+
"type": "fitness-fn",
|
|
740
|
+
"label": "Naming rules at error severity",
|
|
741
|
+
"x": 1040,
|
|
742
|
+
"y": 1170,
|
|
743
|
+
"characteristic": "maintainability",
|
|
744
|
+
"scope": "atomic",
|
|
745
|
+
"cadence": "triggered",
|
|
746
|
+
"trigger": "pull-request",
|
|
747
|
+
"invocation": "automated",
|
|
748
|
+
"description": "The naming rules of the guide are added to the shared ESLint configuration at error severity; object and type properties are left free because they follow wire formats. A CI step asks ESLint for the configuration it resolves for a source file, so a rule turned off or down to a warning in some later block is noticed, and pipes a wrongly named Python function through Ruff with the project's configuration. For Kotlin, ktlint's standard:class-naming, function-naming and property-naming run unless disabled in .editorconfig; for C#, dotnet_diagnostic.IDE1006.severity = error; for Go, staticcheck's ST1003, which is off by default and has to be listed.\n\nThreshold: @typescript-eslint/naming-convention at severity 2 (error) in the configuration ESLint resolves for src; Ruff reports N802 on a probe with a wrongly named function; the step fails otherwise\n\nTool: ESLint with typescript-eslint (naming-convention); Ruff (pep8-naming, N); ktlint, IDE1006 and staticcheck ST1003 for Kotlin, C# and Go\n\n```js\n// eslint.config.js: the naming rules of the style guide, at error (merged into the shared configuration)\nimport { defineConfig } from 'eslint/config'\nimport tseslint from 'typescript-eslint'\n\nexport default defineConfig({\n files: ['src/**/*.{ts,tsx}'],\n languageOptions: { parser: tseslint.parser },\n plugins: { '@typescript-eslint': tseslint.plugin },\n rules: {\n '@typescript-eslint/naming-convention': ['error',\n { selector: 'default', format: ['camelCase'], leadingUnderscore: 'allow' },\n { selector: 'variable', modifiers: ['const'], format: ['camelCase', 'UPPER_CASE'] },\n { selector: 'typeLike', format: ['PascalCase'] },\n { selector: 'enumMember', format: ['PascalCase'] },\n { selector: 'import', format: ['camelCase', 'PascalCase'] },\n { selector: ['objectLiteralProperty', 'typeProperty'], format: null }, // keys follow the wire format\n ],\n },\n})\n// CI step:\n// npx eslint --print-config src/index.ts | jq -e '.rules[\"@typescript-eslint/naming-convention\"][0] == 2'\n// printf 'def GetOrder():\\n pass\\n' | ruff check --stdin-filename src/naming_probe.py - | grep -q N802 # pyproject.toml: [tool.ruff.lint] extend-select = [\"N\"]\n```",
|
|
749
|
+
"hubWhen": {
|
|
750
|
+
"NAMING": [
|
|
751
|
+
"linted"
|
|
752
|
+
]
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
"id": "ff-editor-settings",
|
|
757
|
+
"type": "fitness-fn",
|
|
758
|
+
"label": "Editor settings format on save",
|
|
759
|
+
"x": 1040,
|
|
760
|
+
"y": 1300,
|
|
761
|
+
"characteristic": "maintainability",
|
|
762
|
+
"scope": "atomic",
|
|
763
|
+
"cadence": "triggered",
|
|
764
|
+
"trigger": "pull-request",
|
|
765
|
+
"invocation": "automated",
|
|
766
|
+
"description": "A CI step reads the committed editor settings, kept as plain JSON without comments so jq can read them, and fails when format on save is off, a language in the repository has no default formatter, or that formatter's extension is not recommended. The Prettier extension (esbenp.prettier-vscode), Biome's (biomejs.biome) and Ruff's (charliermarsh.ruff) use the project's installed formatter before their bundled one. JetBrains IDEs read .editorconfig and need their Prettier or Ruff on-save setting turned on once per developer.\n\nThreshold: .vscode/settings.json has editor.formatOnSave true and a default formatter for every language with tracked files; .vscode/extensions.json recommends each of those formatters\n\nTool: jq in a CI step\n\n```bash\n#!/usr/bin/env bash\n# CI step: the committed editor settings format on save with the project's formatter\nset -euo pipefail\ns=.vscode/settings.json; x=.vscode/extensions.json\njq -e '.\"editor.formatOnSave\" == true' \"$s\" >/dev/null || { echo \"$s: editor.formatOnSave is not true\"; exit 1; }\nwhile read -r lang pattern; do\n [ \"$(git ls-files -- \"$pattern\" | wc -l)\" -gt 0 ] || continue\n ext=$(jq -r --arg l \"[$lang]\" '.[$l][\"editor.defaultFormatter\"] // .[\"editor.defaultFormatter\"] // empty' \"$s\")\n [ -n \"$ext\" ] || { echo \"$s: no default formatter for $lang\"; exit 1; }\n jq -e --arg e \"$ext\" '.recommendations | index($e)' \"$x\" >/dev/null || { echo \"$x: $ext is not recommended\"; exit 1; }\ndone <<'LANGUAGES'\ntypescript *.ts\ntypescriptreact *.tsx\njavascript *.js\npython *.py\nLANGUAGES\necho \"editors format on save with the project's formatters\"\n```",
|
|
767
|
+
"hubWhen": {
|
|
768
|
+
"EDITOR": [
|
|
769
|
+
"shared"
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
"id": "ff-no-editor-files",
|
|
775
|
+
"type": "fitness-fn",
|
|
776
|
+
"label": "Only .editorconfig is shared",
|
|
777
|
+
"x": 1040,
|
|
778
|
+
"y": 1430,
|
|
779
|
+
"characteristic": "maintainability",
|
|
780
|
+
"scope": "atomic",
|
|
781
|
+
"cadence": "triggered",
|
|
782
|
+
"trigger": "pull-request",
|
|
783
|
+
"invocation": "automated",
|
|
784
|
+
"description": "A CI step lists the tracked editor-specific settings files and fails on any, so a personal setting committed by mistake is caught in the pull request; .editorconfig must exist, being the one configuration every editor shares. Recommending extensions in .vscode/extensions.json is not a setting and stays allowed.\n\nThreshold: 0 tracked editor-specific settings files (.vscode/settings.json, .idea/, *.code-workspace, .zed/, .fleet/); .editorconfig present\n\nTool: git ls-files in a CI step\n\n```bash\n#!/usr/bin/env bash\n# CI step: .editorconfig is the only editor configuration in the repository\nset -euo pipefail\ntracked=$(git ls-files -- '.vscode/settings.json' '.idea/*' '*.code-workspace' '.zed/*' '.fleet/*')\n[ -z \"$tracked\" ] || { echo \"editor-specific settings are committed; keep them out of the repository (.gitignore):\"; echo \"$tracked\"; exit 1; }\n[ -f .editorconfig ] || { echo \".editorconfig is missing\"; exit 1; }\necho \"only .editorconfig is shared\"\n```",
|
|
785
|
+
"hubWhen": {
|
|
786
|
+
"EDITOR": [
|
|
787
|
+
"editorconfig"
|
|
788
|
+
]
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
],
|
|
792
|
+
"relations": [
|
|
793
|
+
{
|
|
794
|
+
"id": "req-one-config--derives--need",
|
|
795
|
+
"sourceId": "req-one-config",
|
|
796
|
+
"targetId": "need",
|
|
797
|
+
"relationType": "derives"
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
"id": "req-same-version--derives--need",
|
|
801
|
+
"sourceId": "req-same-version",
|
|
802
|
+
"targetId": "need",
|
|
803
|
+
"relationType": "derives"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
"id": "req-blame-ignore--derives--need",
|
|
807
|
+
"sourceId": "req-blame-ignore",
|
|
808
|
+
"targetId": "need",
|
|
809
|
+
"relationType": "derives"
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
"id": "req-editorconfig--derives--need",
|
|
813
|
+
"sourceId": "req-editorconfig",
|
|
814
|
+
"targetId": "need",
|
|
815
|
+
"relationType": "derives"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"id": "req-defaults--derives--need",
|
|
819
|
+
"sourceId": "req-defaults",
|
|
820
|
+
"targetId": "need",
|
|
821
|
+
"relationType": "derives"
|
|
822
|
+
},
|
|
823
|
+
{
|
|
824
|
+
"id": "req-matched--derives--need",
|
|
825
|
+
"sourceId": "req-matched",
|
|
826
|
+
"targetId": "need",
|
|
827
|
+
"relationType": "derives"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
"id": "req-guide-published--derives--need",
|
|
831
|
+
"sourceId": "req-guide-published",
|
|
832
|
+
"targetId": "need",
|
|
833
|
+
"relationType": "derives"
|
|
834
|
+
},
|
|
835
|
+
{
|
|
836
|
+
"id": "req-guide-own--derives--need",
|
|
837
|
+
"sourceId": "req-guide-own",
|
|
838
|
+
"targetId": "need",
|
|
839
|
+
"relationType": "derives"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
"id": "req-naming-linted--derives--need",
|
|
843
|
+
"sourceId": "req-naming-linted",
|
|
844
|
+
"targetId": "need",
|
|
845
|
+
"relationType": "derives"
|
|
846
|
+
},
|
|
847
|
+
{
|
|
848
|
+
"id": "req-naming-reviewed--derives--need",
|
|
849
|
+
"sourceId": "req-naming-reviewed",
|
|
850
|
+
"targetId": "need",
|
|
851
|
+
"relationType": "derives"
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
"id": "req-editor-shared--derives--need",
|
|
855
|
+
"sourceId": "req-editor-shared",
|
|
856
|
+
"targetId": "need",
|
|
857
|
+
"relationType": "derives"
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
"id": "req-editor-own--derives--need",
|
|
861
|
+
"sourceId": "req-editor-own",
|
|
862
|
+
"targetId": "need",
|
|
863
|
+
"relationType": "derives"
|
|
864
|
+
},
|
|
865
|
+
{
|
|
866
|
+
"id": "sc-one-config--verifies--req-one-config",
|
|
867
|
+
"sourceId": "sc-one-config",
|
|
868
|
+
"targetId": "req-one-config",
|
|
869
|
+
"relationType": "verifies"
|
|
870
|
+
},
|
|
871
|
+
{
|
|
872
|
+
"id": "sc-same-version--verifies--req-same-version",
|
|
873
|
+
"sourceId": "sc-same-version",
|
|
874
|
+
"targetId": "req-same-version",
|
|
875
|
+
"relationType": "verifies"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
"id": "sc-blame-ignore--verifies--req-blame-ignore",
|
|
879
|
+
"sourceId": "sc-blame-ignore",
|
|
880
|
+
"targetId": "req-blame-ignore",
|
|
881
|
+
"relationType": "verifies"
|
|
882
|
+
},
|
|
883
|
+
{
|
|
884
|
+
"id": "sc-editorconfig--verifies--req-editorconfig",
|
|
885
|
+
"sourceId": "sc-editorconfig",
|
|
886
|
+
"targetId": "req-editorconfig",
|
|
887
|
+
"relationType": "verifies"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"id": "sc-defaults--verifies--req-defaults",
|
|
891
|
+
"sourceId": "sc-defaults",
|
|
892
|
+
"targetId": "req-defaults",
|
|
893
|
+
"relationType": "verifies"
|
|
894
|
+
},
|
|
895
|
+
{
|
|
896
|
+
"id": "sc-matched--verifies--req-matched",
|
|
897
|
+
"sourceId": "sc-matched",
|
|
898
|
+
"targetId": "req-matched",
|
|
899
|
+
"relationType": "verifies"
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
"id": "sc-guide-published--verifies--req-guide-published",
|
|
903
|
+
"sourceId": "sc-guide-published",
|
|
904
|
+
"targetId": "req-guide-published",
|
|
905
|
+
"relationType": "verifies"
|
|
906
|
+
},
|
|
907
|
+
{
|
|
908
|
+
"id": "sc-guide-own--verifies--req-guide-own",
|
|
909
|
+
"sourceId": "sc-guide-own",
|
|
910
|
+
"targetId": "req-guide-own",
|
|
911
|
+
"relationType": "verifies"
|
|
912
|
+
},
|
|
913
|
+
{
|
|
914
|
+
"id": "sc-naming-linted--verifies--req-naming-linted",
|
|
915
|
+
"sourceId": "sc-naming-linted",
|
|
916
|
+
"targetId": "req-naming-linted",
|
|
917
|
+
"relationType": "verifies"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"id": "sc-naming-reviewed--verifies--req-naming-reviewed",
|
|
921
|
+
"sourceId": "sc-naming-reviewed",
|
|
922
|
+
"targetId": "req-naming-reviewed",
|
|
923
|
+
"relationType": "verifies"
|
|
924
|
+
},
|
|
925
|
+
{
|
|
926
|
+
"id": "sc-editor-shared--verifies--req-editor-shared",
|
|
927
|
+
"sourceId": "sc-editor-shared",
|
|
928
|
+
"targetId": "req-editor-shared",
|
|
929
|
+
"relationType": "verifies"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"id": "sc-editor-own--verifies--req-editor-own",
|
|
933
|
+
"sourceId": "sc-editor-own",
|
|
934
|
+
"targetId": "req-editor-own",
|
|
935
|
+
"relationType": "verifies"
|
|
936
|
+
},
|
|
937
|
+
{
|
|
938
|
+
"id": "ff-one-config--implements--adr-format-defaults",
|
|
939
|
+
"sourceId": "ff-one-config",
|
|
940
|
+
"targetId": "adr-format-defaults",
|
|
941
|
+
"relationType": "implements"
|
|
942
|
+
},
|
|
943
|
+
{
|
|
944
|
+
"id": "ff-one-config--implements--adr-format-matched",
|
|
945
|
+
"sourceId": "ff-one-config",
|
|
946
|
+
"targetId": "adr-format-matched",
|
|
947
|
+
"relationType": "implements"
|
|
948
|
+
},
|
|
949
|
+
{
|
|
950
|
+
"id": "ff-version-match--implements--adr-format-defaults",
|
|
951
|
+
"sourceId": "ff-version-match",
|
|
952
|
+
"targetId": "adr-format-defaults",
|
|
953
|
+
"relationType": "implements"
|
|
954
|
+
},
|
|
955
|
+
{
|
|
956
|
+
"id": "ff-version-match--implements--adr-format-matched",
|
|
957
|
+
"sourceId": "ff-version-match",
|
|
958
|
+
"targetId": "adr-format-matched",
|
|
959
|
+
"relationType": "implements"
|
|
960
|
+
},
|
|
961
|
+
{
|
|
962
|
+
"id": "ff-blame-ignore--implements--adr-format-defaults",
|
|
963
|
+
"sourceId": "ff-blame-ignore",
|
|
964
|
+
"targetId": "adr-format-defaults",
|
|
965
|
+
"relationType": "implements"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"id": "ff-blame-ignore--implements--adr-format-matched",
|
|
969
|
+
"sourceId": "ff-blame-ignore",
|
|
970
|
+
"targetId": "adr-format-matched",
|
|
971
|
+
"relationType": "implements"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
"id": "ff-editorconfig--implements--adr-format-defaults",
|
|
975
|
+
"sourceId": "ff-editorconfig",
|
|
976
|
+
"targetId": "adr-format-defaults",
|
|
977
|
+
"relationType": "implements"
|
|
978
|
+
},
|
|
979
|
+
{
|
|
980
|
+
"id": "ff-editorconfig--implements--adr-format-matched",
|
|
981
|
+
"sourceId": "ff-editorconfig",
|
|
982
|
+
"targetId": "adr-format-matched",
|
|
983
|
+
"relationType": "implements"
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
"id": "ff-editorconfig-consistent--implements--adr-format-defaults",
|
|
987
|
+
"sourceId": "ff-editorconfig-consistent",
|
|
988
|
+
"targetId": "adr-format-defaults",
|
|
989
|
+
"relationType": "implements"
|
|
990
|
+
},
|
|
991
|
+
{
|
|
992
|
+
"id": "ff-editorconfig-consistent--implements--adr-format-matched",
|
|
993
|
+
"sourceId": "ff-editorconfig-consistent",
|
|
994
|
+
"targetId": "adr-format-matched",
|
|
995
|
+
"relationType": "implements"
|
|
996
|
+
},
|
|
997
|
+
{
|
|
998
|
+
"id": "ff-minimal-config--implements--adr-format-defaults",
|
|
999
|
+
"sourceId": "ff-minimal-config",
|
|
1000
|
+
"targetId": "adr-format-defaults",
|
|
1001
|
+
"relationType": "implements"
|
|
1002
|
+
},
|
|
1003
|
+
{
|
|
1004
|
+
"id": "ff-option-reasons--implements--adr-format-matched",
|
|
1005
|
+
"sourceId": "ff-option-reasons",
|
|
1006
|
+
"targetId": "adr-format-matched",
|
|
1007
|
+
"relationType": "implements"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"id": "ff-guide-linked--implements--adr-guide-published",
|
|
1011
|
+
"sourceId": "ff-guide-linked",
|
|
1012
|
+
"targetId": "adr-guide-published",
|
|
1013
|
+
"relationType": "implements"
|
|
1014
|
+
},
|
|
1015
|
+
{
|
|
1016
|
+
"id": "ff-guide-rules--implements--adr-guide-own",
|
|
1017
|
+
"sourceId": "ff-guide-rules",
|
|
1018
|
+
"targetId": "adr-guide-own",
|
|
1019
|
+
"relationType": "implements"
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
"id": "ff-naming-lint--implements--adr-format-defaults",
|
|
1023
|
+
"sourceId": "ff-naming-lint",
|
|
1024
|
+
"targetId": "adr-format-defaults",
|
|
1025
|
+
"relationType": "implements"
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
"id": "ff-naming-lint--implements--adr-format-matched",
|
|
1029
|
+
"sourceId": "ff-naming-lint",
|
|
1030
|
+
"targetId": "adr-format-matched",
|
|
1031
|
+
"relationType": "implements"
|
|
1032
|
+
},
|
|
1033
|
+
{
|
|
1034
|
+
"id": "ff-editor-settings--implements--adr-format-defaults",
|
|
1035
|
+
"sourceId": "ff-editor-settings",
|
|
1036
|
+
"targetId": "adr-format-defaults",
|
|
1037
|
+
"relationType": "implements"
|
|
1038
|
+
},
|
|
1039
|
+
{
|
|
1040
|
+
"id": "ff-editor-settings--implements--adr-format-matched",
|
|
1041
|
+
"sourceId": "ff-editor-settings",
|
|
1042
|
+
"targetId": "adr-format-matched",
|
|
1043
|
+
"relationType": "implements"
|
|
1044
|
+
},
|
|
1045
|
+
{
|
|
1046
|
+
"id": "ff-no-editor-files--implements--adr-format-defaults",
|
|
1047
|
+
"sourceId": "ff-no-editor-files",
|
|
1048
|
+
"targetId": "adr-format-defaults",
|
|
1049
|
+
"relationType": "implements"
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
"id": "ff-no-editor-files--implements--adr-format-matched",
|
|
1053
|
+
"sourceId": "ff-no-editor-files",
|
|
1054
|
+
"targetId": "adr-format-matched",
|
|
1055
|
+
"relationType": "implements"
|
|
1056
|
+
}
|
|
1057
|
+
]
|
|
1058
|
+
}
|