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

lint: add kebab-case checks #274

Merged
merged 11 commits into from
Apr 10, 2021
Merged

Conversation

ee7
Copy link
Member

@ee7 ee7 commented Apr 9, 2021

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:


This PR currently causes the following diff to the output of configlet lint:

rust

+The `exercises.concept.prerequisites` array contains `&str`, but every value must be lowercase and kebab-case:
+./config.json
+
+The `concepts.slug` value is `&str`, but it must be a lowercase and kebab-case string:
+./config.json
+
+Configlet detected at least one problem.
+For more information on resolving the problems, please see the documentation:
+https://github.com/exercism/docs/blob/main/building/configlet/lint.md

What should the definition of "kebab string" be?

  • A string that only contains characters in {'a'..'z', '0'..'9', '-'} (the definition in e898324)
  • A string that matches ^([a-z0-9]+)(-[a-z0-9]+)*$
  • A string that does not contain a character in {'A'..'Z', '_', ' '}
  • Something else

I think we can either

  1. Disallow special characters for all kebab strings, and tell the Rust track to write the concept name as something like "string-slices" instead.
  2. Allow special characters in a concept name, so something like &str is allowed, but disallow them in the other kebab strings.

See e.g.

@ee7 ee7 requested a review from ErikSchierboom as a code owner April 9, 2021 10:19
This commit implements these checks for a track `config.json`:
- The `"slug"` value must be a non-empty, non-blank, lowercased string
  using kebab-case
- The `"exercises.concept[].slug"` value must be a non-empty, non-blank,
  lowercased string using kebab-case
- The `"exercises.concept[].concepts"` values must be non-empty,
  non-blank, lowercased strings using kebab-case
- The `"exercises.concept[].prerequisites"` values must be non-empty,
  non-blank, lowercased strings using kebab-case
- The `"exercises.practice[].slug"` value must be a non-empty,
  non-blank, lowercased string using kebab-case
- The `"exercises.practice[].practices"` values must be non-empty,
  non-blank, lowercased strings using kebab-case
- The `"exercises.practice[].prerequisites"` values must be non-empty,
  non-blank, lowercased strings using kebab-case
- The `"exercises.foregone"` values must be non-empty, non-blank,
  lowercased strings using kebab-case
- The `"concepts[].slug"` value must be a non-empty, non-blank,
  lowercased string using kebab-case
@ee7 ee7 force-pushed the lint-add-kebab-case-checks branch from 0b2eb58 to e898324 Compare April 9, 2021 10:21
@ErikSchierboom
Copy link
Member

Option 1 is what we want. I'll update the docs to clarify.

Copy link
Member

@ErikSchierboom ErikSchierboom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the extensive tests!

@ee7 ee7 merged commit 615754b into exercism:main Apr 10, 2021
@ee7 ee7 deleted the lint-add-kebab-case-checks branch April 10, 2021 11:39
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