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

docs: update rules table during build #274

Merged
merged 3 commits into from
Aug 30, 2024
Merged

docs: update rules table during build #274

merged 3 commits into from
Aug 30, 2024

Conversation

fasttime
Copy link
Member

@fasttime fasttime commented Aug 28, 2024

Added a tool that generates the rules table in README.md automatically from rules metadata. The rules table will be generated per npm script during the build.

Maybe we will also want to make sure that the rules table is up-to-date each time a commit is merged into the main branch. I'm not sure what's the best way to achieve this.

Fixes #273

@nzakas
Copy link
Member

nzakas commented Aug 28, 2024

It seems like we could do this via lint-staged whenever a change is made in the src/rules directory and cover our bases?

@fasttime
Copy link
Member Author

It seems like we could do this via lint-staged whenever a change is made in the src/rules directory and cover our bases?

Updated in bf20bb2. I also tweaked the tool so it doesn't crash if someone forgets to add metadata to a rule.

Comment on lines 41 to 44
const docs = rule?.meta?.docs;
const ruleLink = `[\`${ruleName}\`](./docs/rules/${ruleName}.md)`;
const recommendedText = recommended ? "yes" : "no";
const description = docs?.description || "_no description_";
const recommendedText = docs?.recommended ? "yes" : "no";
Copy link
Member

Choose a reason for hiding this comment

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

We will ensure that all rules have description. Is there a reason you're validating whether it's present?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks! I noticed that when a rule has no meta.docs the build fails without indicating which rule is the culprit, so I added a fallback to avoid the error. But if all rules will have a description there is no need for a fallback. I've reverted that change now.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nzakas nzakas merged commit 8196064 into main Aug 30, 2024
13 checks passed
@nzakas nzakas deleted the issue273 branch August 30, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs: README: wrong rule description, missing recommended list
2 participants