From ea478ef643c432fbec38821eef5e1f41231ad6ee Mon Sep 17 00:00:00 2001 From: Tomas Doran Date: Thu, 7 Oct 2021 11:09:29 +0100 Subject: [PATCH] lint(track_config): check hello-world `status` (#436) With this commit, `configlet lint` now checks that a track-level `config.json` file follows the below rule: - The `exercises.practice[].status` value must, if `exercises.practice[].slug` is equal to `hello-world`, be either omitted or the string `active` Co-authored-by: ee7 <45465154+ee7@users.noreply.github.com> --- src/lint/track_config.nim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lint/track_config.nim b/src/lint/track_config.nim index a696d7f8..a83745c3 100644 --- a/src/lint/track_config.nim +++ b/src/lint/track_config.nim @@ -79,6 +79,15 @@ proc isValidPracticeExercise(data: JsonNode; context: string; ] result = allTrue(checks) + const k = "status" + if result and data["slug"].getStr() == "hello-world" and data.hasKey(k): + let statusVal = data[k].getStr() + if statusVal != "active": + let msg = &"The hello-world Practice Exercise has a {q k} of {q statusVal}, " & + "but for that exercise, either the value must be `active` or the " & + "key/value pair must be omitted (which implies `active`)" + result.setFalseAndPrint(msg, path) + proc hasValidExercises(data: JsonNode; path: Path): bool = const k = "exercises" if hasObject(data, k, path):