Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing "non-blank" linting rule #110

Closed
wants to merge 1 commit into from

Conversation

ee7
Copy link
Member

@ee7 ee7 commented Apr 9, 2021

With this PR, we now specify in lint.md that all kebab strings are non-blank:

$ git grep --break --heading 'kebab'
building/configlet/lint.md
52:- The `"slug"` value must be a non-empty, non-blank, lowercased string using kebab-case
75:- The `"exercises.concept[].slug"` value must be a non-empty, non-blank, lowercased string using kebab-case
87:- The `"exercises.concept[].concepts"` values must be non-empty, non-blank, lowercased strings using kebab-case
94:- The `"exercises.concept[].prerequisites"` values must be non-empty, non-blank, lowercased strings using kebab-case
105:- The `"exercises.practice[].slug"` value must be a non-empty, non-blank, lowercased string using kebab-case
119:- The `"exercises.practice[].practices"` values must be non-empty, non-blank, lowercased strings using kebab-case
126:- The `"exercises.practice[].prerequisites"` values must be non-empty, non-blank, lowercased strings using kebab-case
134:- The `"exercises.foregone"` values must be non-empty, non-blank, lowercased strings using kebab-case
142:- The `"concepts[].slug"` value must be a non-empty, non-blank, lowercased string using kebab-case

building/tracks/concept-exercises.md
476:1. Use [kebab-case][kebab-case].
489:- `TimFromMarketing`: does not use kebab-case (i.e. `tim-from-marketing`)
496:[kebab-case]: https://en.wiktionary.org/wiki/kebab_case

building/tracks/config-json.md
10:- `slug`: the track's language as a lowercased, kebab-case string (e.g. `"csharp"`) (required)
35:- `%{kebab_slug}`: the `kebab-case` exercise slug (e.g. `bit-manipulation`)
83:- `slug`: the exercise's slug, which is a lowercased, kebab-case string. The slug must be unique across all concept _and_ practice exercise slugs within the track
137:- `slug`: the exercise's slug, which is a lowercased, kebab-case string. The slug must be unique across all concept _and_ practice exercise slugs within the track
215:- `slug`: the concept's slug, which is a lowercased, kebab-case string. The slug must be unique across all concepts within the track

@iHiD
Copy link
Member

iHiD commented Apr 9, 2021

How does an empty string differ from a blank string? (in Ruby, they're the same thing for example)

@ee7
Copy link
Member Author

ee7 commented Apr 9, 2021

We're using the definitions:

  • an "empty string" is zero-length, ""
  • a "blank string" is a non-empty string that is whitespace-only, e.g. " "

@iHiD
Copy link
Member

iHiD commented Apr 9, 2021

Thanks.

Is there any situation where we allow blank strings, or could we define them to be synonyms?

Also are those definitions somewhere in the file (I can't see them) - if not could we add them pls?

@ee7
Copy link
Member Author

ee7 commented Apr 11, 2021

Is there any situation where we allow blank strings, or could we define them to be synonyms?

Currently, nearly every "regular string" in the spec is specified to be both non-empty and non-blank. The exception is:

  • The "language_versions" key is optional
  • The "language_versions" value must be a string

But that might be an oversight in the spec, and currently configlet lint produces an error for an optional key that has the value of the empty string.

Also are those definitions somewhere in the file

Not currently.

if not could we add them pls?

We could, but we might be able to find a better wording while we're at it. I think it could be nice to condense

  • The "language" value must be a non-empty, non-blank string
  • The "slug" value must be a non-empty, non-blank, lowercased string using kebab-case

down to something like

  • The "language" value must be a non-trivial string¹
  • The "slug" value must be a kebab-case string²

Glossary:

  1. Non-trivial string: a string that has at least one non-whitespace character.
  2. kebab-case string: a string that contains only characters in the range [a-z0-9], optionally separated by dashes (e.g. "two-fer"). It must match the regular expression: ^[a-z0-9]+(-[a-z0-9]+)*$

I've tried to do exactly that in #115. That PR also resolves the issue that this PR addressed, so I'm closing this one.

@ee7 ee7 closed this Apr 11, 2021
@ee7 ee7 deleted the lint-practices-non-blank branch April 11, 2021 09:42
@iHiD
Copy link
Member

iHiD commented Apr 11, 2021

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants