Skip to content

docs(eslint-plugin): standardize rule description format #4976

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

Merged

Conversation

Josh-Cena
Copy link
Member

PR Checklist

Overview

Right, so here's some unwieldy chores.

  1. All rule descriptions now use imperative mood—no third-person singular.
  2. All rule descriptions start with enforce/require/disallow—following ESLint format.
  3. Some wordings have been refactored to be shorter.

Should we add it to the tests that descriptions must start with enforce/require/disallow?

@nx-cloud
Copy link

nx-cloud bot commented May 15, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 0544b7a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @Josh-Cena!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@netlify
Copy link

netlify bot commented May 15, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 0544b7a
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/62938c0d8ab4c200094aea70
😎 Deploy Preview https://deploy-preview-4976--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

| [`@typescript-eslint/semi`](./semi.md) | Require or disallow semicolons instead of ASI | | :wrench: | |
| [`@typescript-eslint/space-before-function-paren`](./space-before-function-paren.md) | Enforces consistent spacing before function parenthesis | | :wrench: | |
| [`@typescript-eslint/space-infix-ops`](./space-infix-ops.md) | This rule is aimed at ensuring there are spaces around infix operators. | | :wrench: | |
| [`@typescript-eslint/space-before-blocks`](./space-before-blocks.md) | Enforce consistent spacing before blocks | | :wrench: | |
Copy link
Member Author

Choose a reason for hiding this comment

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

There are some rules missing in this file. I assume it's simply an oversight.

Copy link
Member

@bradzacher bradzacher May 16, 2022

Choose a reason for hiding this comment

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

there shouldn't be any missing files - it should be tested against and enforced.

or maybe this readme file isn't tested like the main readme is...?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's tested as comprehensively as the main readme, 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 should definitely fix this! Considering this file powers our website - it should be generated and tested just like the one in the main readme!

Or perhaps we should just generate the website table at website build time instead of making it rely on a markdown file on disk?

Copy link
Member Author

Choose a reason for hiding this comment

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

Certainly. I've added docs/rules/README.md to the tests.

we should just generate the website table at website build time

We can do that later; it's a bit harder.

@codecov
Copy link

codecov bot commented May 15, 2022

Codecov Report

Merging #4976 (3282f97) into main (8febf11) will increase coverage by 2.50%.
The diff coverage is n/a.

❗ Current head 3282f97 differs from pull request most recent head 0544b7a. Consider uploading reports for the commit 0544b7a to get more accurate results

@@            Coverage Diff             @@
##             main    #4976      +/-   ##
==========================================
+ Coverage   91.32%   93.83%   +2.50%     
==========================================
  Files         132      286     +154     
  Lines        1487     9838    +8351     
  Branches      224     2939    +2715     
==========================================
+ Hits         1358     9231    +7873     
- Misses         65      328     +263     
- Partials       64      279     +215     
Flag Coverage Δ
unittest 93.83% <ø> (+2.50%) ⬆️

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

Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/array-type.ts 97.18% <ø> (ø)
packages/eslint-plugin/src/rules/await-thenable.ts 100.00% <ø> (ø)
packages/eslint-plugin/src/rules/ban-ts-comment.ts 97.05% <ø> (ø)
...ages/eslint-plugin/src/rules/ban-tslint-comment.ts 100.00% <ø> (ø)
packages/eslint-plugin/src/rules/ban-types.ts 100.00% <ø> (ø)
...t-plugin/src/rules/class-literal-property-style.ts 100.00% <ø> (ø)
packages/eslint-plugin/src/rules/comma-dangle.ts 93.33% <ø> (ø)
packages/eslint-plugin/src/rules/comma-spacing.ts 100.00% <ø> (ø)
...lugin/src/rules/consistent-indexed-object-style.ts 92.06% <ø> (ø)
...int-plugin/src/rules/consistent-type-assertions.ts 88.88% <ø> (ø)
... and 220 more

@@ -1,6 +1,6 @@
# `array-type`

Requires using either `T[]` or `Array<T>` for arrays.
Require using either `T[]` or `Array<T>` for arrays.
Copy link
Member

Choose a reason for hiding this comment

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

Oh, interesting! I was actually thinking of going the other way and preferring third-person singular. "Requires XYZ" and such.

Reasoning: imperative mood reads (to me, at least) as a command: that you should do the thing in the sentence. That's only true for some rules, and then within each rule not true for all projects.

OTOH third-person singular indicates it's describing the rule. That's more directly the goal of these description strings & docs.

For reference, https://eslint.org/docs/rules uses imperative but the individual pages such as https://eslint.org/docs/rules/array-callback-return use third-person singular.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, maybe I should line up the format with ESLint's, then? Using third-person singular for individual pages.

As for the "command-sounding" tone, though, the imperative mood reads like a description as well. "Require"/"Disallow" etc. sound obvious enough that the omitted subject is "the rule", instead of "you must do X".

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I'm thinking it would make sense for ESLint to use third-person singular everywhere 🤷

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW, I like saving one character😥

@Josh-Cena Josh-Cena force-pushed the standardize-description branch from f8b7b7f to 88c3061 Compare May 16, 2022 15:23
@bradzacher bradzacher added the documentation Documentation ("docs") that needs adding/updating label May 16, 2022
@bradzacher bradzacher changed the title chore: standardize rule description format docs(eslint-plugin): standardize rule description format May 16, 2022
@Josh-Cena
Copy link
Member Author

Merge conflicts, merge conflicts... 😥

Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

this is looking good to me
I'll leave it to our resident documentation master @JoshuaKGoldberg for the final stamp.

@JoshuaKGoldberg
Copy link
Member

I'm a bit swamped with PR things at the moment, but should get through my backlog... soon! This week!

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Fantastic, thanks! This standardization will be super helpful as we continue to automate the site.

text: `${rule.meta.docs?.description.replace(
/(?<!`)(require|enforce|disallow)/gi,
'$1s',
)}.`,
Copy link
Member

Choose a reason for hiding this comment

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

Continuing the thread from #4976 (comment): I'd really rather we didn't do the extra work to massage between one and two. In addition to requiring (admittedly clever) tricks like this one, I get a bit of cognitively dissonance having slightly different descriptions for the same rule in multiple places.

It's fine having this here for now, so we can just move this discussion to #5096 as a followup if you feel strongly.

Copy link
Member Author

@Josh-Cena Josh-Cena May 29, 2022

Choose a reason for hiding this comment

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

I agree. I also mentioned in #5085 (comment) I'd like this to be eventually automated as well. However, I do prefer the table to be imperative because it looks more... succinct & professional? My own feeling when reading the ESLint docs.

@JoshuaKGoldberg JoshuaKGoldberg enabled auto-merge (squash) May 29, 2022 15:06
@JoshuaKGoldberg JoshuaKGoldberg merged commit dc58ff5 into typescript-eslint:main May 29, 2022
@Josh-Cena Josh-Cena deleted the standardize-description branch May 29, 2022 15:19
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Documentation ("docs") that needs adding/updating
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants