-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit implements some stricter checks for the track-level `config.json` file. `configlet lint` now checks that every value of every below key is a "kebab-case string": - `slug` - `exercises.concept[].slug` - `exercises.concept[].concepts` - `exercises.concept[].prerequisites` - `exercises.practice[].slug` - `exercises.practice[].practices` - `exercises.practice[].prerequisites` - `exercises.foregone` - `concepts[].slug` We define a "kebab-case string" as a string that matches the regular expression: `^[a-z0-9]+(-[a-z0-9]+)*$` See: - https://github.com/exercism/docs/blob/4a42d3399139/building/configlet/lint.md#rule-configjson-file-is-valid - https://github.com/exercism/docs/pull/113/files
- Loading branch information
Showing
4 changed files
with
141 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import "."/[ | ||
test_binary, | ||
test_lint, | ||
test_probspecs, | ||
test_uuid, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import std/unittest | ||
import "."/[lint/validators] | ||
|
||
proc main = | ||
suite "isKebabCase": | ||
test "invalid kebab-case strings": | ||
check: | ||
# Some short, invalid strings | ||
not isKebabCase("") | ||
not isKebabCase(" ") | ||
not isKebabCase("-") | ||
not isKebabCase("_") | ||
not isKebabCase("--") | ||
not isKebabCase("---") | ||
not isKebabCase("a ") | ||
not isKebabCase(" a") | ||
not isKebabCase("a-") | ||
not isKebabCase("-a") | ||
not isKebabCase("--a") | ||
not isKebabCase("a--") | ||
not isKebabCase("-a-") | ||
not isKebabCase("a--b") | ||
# Containing character not in [a-z0-9] | ||
not isKebabCase("&") | ||
not isKebabCase("&str") | ||
not isKebabCase("hello!") | ||
# Invalid dash usage | ||
not isKebabCase("hello-world-") | ||
not isKebabCase("-hello-world") | ||
not isKebabCase("-hello-world-") | ||
not isKebabCase("hello--world") | ||
not isKebabCase("hello---world") | ||
# Invalid separator: space | ||
not isKebabCase("hello world") | ||
not isKebabCase("hello World") | ||
not isKebabCase("Hello world") | ||
not isKebabCase("Hello World") | ||
not isKebabCase("HELLO WORLD") | ||
# Invalid separator: underscore | ||
not isKebabCase("hello_world") | ||
not isKebabCase("hello_World") | ||
not isKebabCase("Hello_world") | ||
not isKebabCase("Hello_World") | ||
not isKebabCase("HELLO_WORLD") | ||
# Containing uppercase, with dash | ||
not isKebabCase("hello-World") | ||
not isKebabCase("Hello-world") | ||
not isKebabCase("Hello-World") | ||
not isKebabCase("HELLO-WORLD") | ||
# Containing uppercase, with no separator | ||
not isKebabCase("helloWorld") | ||
not isKebabCase("Helloworld") | ||
not isKebabCase("HelloWorld") | ||
not isKebabCase("HELLOWORLD") | ||
|
||
test "valid kebab-case strings": | ||
check: | ||
isKebabCase("a") | ||
isKebabCase("1") | ||
isKebabCase("123") | ||
isKebabCase("123-456") | ||
isKebabCase("hello-123") | ||
isKebabCase("123-hello") | ||
isKebabCase("hello") | ||
isKebabCase("hello-world") | ||
isKebabCase("hello-world-hello") | ||
isKebabCase("hello-world-hello-world") | ||
|
||
main() | ||
{.used.} |