Skip to content

Commit

Permalink
lint(track_config): check hello-world status (#436)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bobtfish and ee7 authored Oct 7, 2021
1 parent d2010a1 commit ea478ef
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/lint/track_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ea478ef

Please sign in to comment.