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: automate docs with eslint-doc-generator #504

Merged
merged 2 commits into from
Jan 29, 2023

Conversation

bmish
Copy link
Contributor

@bmish bmish commented Dec 24, 2022

eslint-doc-generator is a CLI tool I built for automating the generation of the README rules list table and rule doc title/notices for ESLint plugins. It follows common documentation conventions from this and other top ESLint plugins and will help us standardize documentation across ESLint plugins (and generally improve the usability of custom rules through better documentation and streamline the process of adding new rules). It has 100% test coverage and is used in many of the top ESLint plugins already.

The organization and representation of rules and configs in the README rules list is different from what you had before. See what you think.

ignoreConfig: ['all', 'off'],
ruleDocSectionInclude: ['Rule Details'],
ruleListSplit: 'meta.docs.category',
postprocess: doc => format(doc, { parser: 'markdown' }),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We run the results through prettier to ensure formatting requirements are met.

}
```

## Options
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Options sections are removed when a rule does not have options. This is part of the --rule-doc-section-options option.

@@ -82,3 +88,7 @@ Because when assuming types, false positives may be found, it's recommended to s
### `ignorePattern`

See the [ignorePattern](./options/ignore-pattern.md) docs.

### `ignoreImmediateMutation`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This option was not mentioned. This is part of the --rule-doc-section-options option.

package.json Outdated
@@ -52,14 +52,16 @@
"cz": "git-cz",
"format": "prettier --write \"./**/*.{md,ts}\"",
"prelint": "yarn build && yarn link && yarn link 'eslint-plugin-functional'",
"lint": "yarn lint-js && yarn lint-md",
"lint": "yarn lint-js && yarn lint-md && yarn lint-eslint-docs",
"lint-eslint-docs": "yarn update:eslint-docs --check",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ensures the docs are kept up-to-date.

src/util/rule.ts Outdated
ESLintUtils.NamedCreateRuleMeta<T> & {
docs: {
/** Used for splitting the README rules list into sub-lists. */
category: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to add this property to the rule meta object since we use it for splitting the rule lists. This is not an official ESLint property anymore but still commonly used by plugins.

README.md Outdated
[badge-no-object-orientation]: https://img.shields.io/badge/-no--object--orientation-yellow.svg
[badge-no-statements]: https://img.shields.io/badge/-no--statements-purple.svg
[badge-off]: https://img.shields.io/badge/-off-black.svg
[badge-stylistic]: https://img.shields.io/badge/-stylistic-gold.svg
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We use badges to represent most configs. Alternatively, the tools allow an emoji to be specified for each config as desired.

@RebeccaStevens
Copy link
Collaborator

This looks like a pretty cool tool.

Would you be able to recreate this PR based of the next branch?
The main branch probably won't be receiving any more updates until #480 is merged.

@bmish
Copy link
Contributor Author

bmish commented Dec 24, 2022

@RebeccaStevens do you have any ETA on v5? If not too long, I might just wait until it gets merged to master to let things settle down first.

@RebeccaStevens
Copy link
Collaborator

Well, it was supposed to go out a few months back but it's kept being pushed back.
It's almost done, there's just a couple of last fixes to make so it should be released soonish.

@RebeccaStevens
Copy link
Collaborator

@bmish I believe update 5 is done now. It should be release within the next week (assuming no issues are found before then).
Do you want to recreate this PR for it before release? If not, I'll see if I can do it.

@bmish
Copy link
Contributor Author

bmish commented Jan 26, 2023

Still seems like it would be easier for me to just wait until v5 is merged to main. I'll try fixing conflicts at that point.

@RebeccaStevens
Copy link
Collaborator

I believe all conflicts are now resolved and next is ready to be merged into main.
Ideally, it would be best to have this merged into next before that is merged into main.

@bmish bmish changed the base branch from main to next January 28, 2023 14:51
@bmish
Copy link
Contributor Author

bmish commented Jan 28, 2023

Okay targeting next now, will try to push to fix conflicts soon.

@bmish bmish force-pushed the eslint-doc-generator branch 2 times, most recently from 829dd6f to 870be6f Compare January 28, 2023 17:04
@bmish
Copy link
Contributor Author

bmish commented Jan 28, 2023

@RebeccaStevens I recreated this entire PR against next.

One note is I had to rename some rule docs which did not match their rule names.

@RebeccaStevens
Copy link
Collaborator

One note is I had to rename some rule docs which did not match their rule names.

Thanks, I realized that issue and was going to fix it but I guess I don't need to now :)

@codecov
Copy link

codecov bot commented Jan 29, 2023

Codecov Report

Merging #504 (1f50625) into next (70afc3b) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             next     #504   +/-   ##
=======================================
  Coverage   90.32%   90.32%           
=======================================
  Files          46       46           
  Lines        1209     1209           
  Branches      318      318           
=======================================
  Hits         1092     1092           
  Misses         50       50           
  Partials       67       67           
Flag Coverage Δ
4.0.2 90.23% <100.00%> (ø)
JS 90.07% <100.00%> (ø)
latest 90.07% <100.00%> (ø)
next 90.07% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/utils/rule.ts 75.32% <ø> (ø)
src/rules/functional-parameters.ts 97.67% <100.00%> (ø)
src/rules/immutable-data.ts 100.00% <100.00%> (ø)
src/rules/no-classes.ts 100.00% <100.00%> (ø)
src/rules/no-conditional-statements.ts 88.73% <100.00%> (ø)
src/rules/no-expression-statements.ts 95.65% <100.00%> (ø)
src/rules/no-let.ts 100.00% <100.00%> (ø)
src/rules/no-loop-statements.ts 100.00% <100.00%> (ø)
src/rules/no-mixed-types.ts 100.00% <100.00%> (ø)
src/rules/no-promise-reject.ts 100.00% <100.00%> (ø)
... and 10 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@RebeccaStevens RebeccaStevens merged commit 191fce8 into eslint-functional:next Jan 29, 2023
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