Skip to content

Commit a71637f

Browse files
lint: add annotation for key features in config.json
If a track's `config.json` file does not have valid key features, the error message will now also show an annotation which explains to the user what exactly is wrong and how to fix it.
1 parent 09d5108 commit a71637f

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

src/lint/track_config.nim

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,52 @@ const keyFeatureIcons = [
175175
].toHashSet()
176176

177177
proc isValidKeyFeature(data: JsonNode; context: string; path: Path): bool =
178+
const iconErrorAnnotation = """
179+
A key feature's `icon` is shown for the feature when presented on the website.
180+
The icon must be chosen from our list of supported icons:
181+
https://exercism.org/docs/building/tracks/icons#h-key-feature-icons
182+
You can choose any icon that you think fits, regardless of its name.
183+
184+
For more information on key features see:
185+
https://exercism.org/docs/building/tracks/config-json#h-key-features""".unindent()
186+
187+
const titleErrorAnnotation = """
188+
A key feature's `title` is a concise header for the key feature.
189+
As little technical jargon as possible should be used.
190+
Its length must be <= 25 and Markdown is not supported.
191+
192+
For more information on key features see:
193+
https://exercism.org/docs/building/tracks/config-json#h-key-features""".unindent()
194+
195+
const contentErrorAnnotation = """
196+
A key feature's `content` is a description of the key feature.
197+
Its length must be <= 100 and Markdown is not supported.
198+
199+
For more information on key features see:
200+
https://exercism.org/docs/building/tracks/config-json#h-key-features""".unindent()
201+
178202
if isObject(data, context, path):
179203
let checks = [
180-
hasString(data, "icon", path, context, allowed = keyFeatureIcons),
181-
hasString(data, "title", path, context, maxLen = 25),
182-
hasString(data, "content", path, context, maxLen = 100),
204+
hasString(data, "icon", path, context, allowed = keyFeatureIcons,
205+
errorAnnotation = iconErrorAnnotation),
206+
hasString(data, "title", path, context, maxLen = 25,
207+
errorAnnotation = titleErrorAnnotation),
208+
hasString(data, "content", path, context, maxLen = 100,
209+
errorAnnotation = contentErrorAnnotation),
183210
]
184211
result = allTrue(checks)
185212

186213
proc hasValidKeyFeatures(data: JsonNode; path: Path): bool =
214+
const errorAnnotation = """
215+
The key features succinctly describe the most important features
216+
of the language to promote the language to potential students.
217+
Exactly 6 key features must be specified.
218+
219+
For more information on key features see:
220+
https://exercism.org/docs/building/tracks/config-json#h-key-features""".unindent()
187221
result = hasArrayOf(data, "key_features", path, isValidKeyFeature,
188-
isRequired = false, allowedLength = 6..6)
222+
isRequired = false, allowedLength = 6..6,
223+
errorAnnotation = errorAnnotation)
189224

190225
const tags = [
191226
"paradigm/declarative",

0 commit comments

Comments
 (0)