Skip to content

Define custom lint rule to assert that each CLI command lists examples#67

Merged
andrewjensen merged 3 commits intomainfrom
adj/lint-require-cli-examples
May 6, 2026
Merged

Define custom lint rule to assert that each CLI command lists examples#67
andrewjensen merged 3 commits intomainfrom
adj/lint-require-cli-examples

Conversation

@andrewjensen
Copy link
Copy Markdown
Collaborator

@andrewjensen andrewjensen commented May 6, 2026

This defines a custom ESLint rule called require-cli-examples, to assert that each "leaf node" command includes examples in its help output.

This means that any command that has an action() must also call:

.addHelpText(
  "afterAll",
  createExampleText([ /* ... */ ])

This rule helps us guarantee good UX for users that need more information about a command.

The rule caught missing examples in the following commands, so this PR also defines examples for them:

  • dx auth login
  • dx auth logout
  • dx auth status
  • dx init

@andrewjensen andrewjensen marked this pull request as ready for review May 6, 2026 03:29
Copy link
Copy Markdown
Collaborator Author

@andrewjensen andrewjensen May 6, 2026

Choose a reason for hiding this comment

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

ESLint has its own little test helper with RuleTester, so this is basically just a shim to connect it with our main vitest suite.

See the custom rule tutorial: Step 6: write the test

Copy link
Copy Markdown
Contributor

@emmahoggan emmahoggan left a comment

Choose a reason for hiding this comment

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

Love this - pits of success 🔥

@andrewjensen andrewjensen merged commit af2192d into main May 6, 2026
3 checks passed
@andrewjensen andrewjensen deleted the adj/lint-require-cli-examples branch May 6, 2026 16:26
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