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

RuleCreator's types do not support rules without a documentation URL #4133

Closed
3 tasks done
JoshuaKGoldberg opened this issue Nov 12, 2021 · 2 comments · Fixed by #4136
Closed
3 tasks done

RuleCreator's types do not support rules without a documentation URL #4133

JoshuaKGoldberg opened this issue Nov 12, 2021 · 2 comments · Fixed by #4136
Labels
package: utils Issues related to the @typescript-eslint/utils package triage Waiting for maintainers to take a look

Comments

@JoshuaKGoldberg
Copy link
Member

  • I have tried restarting my IDE and the issue persists. N/A
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

Going off the code snippet here: #4124 (comment)

The recommended RuleCreator adds a requirement to provide a urlCreator: (ruleName: string) => string parameter. However, when writing rules that don't have a dedicated docs page -such as local one-of rules with eslint-plugin-local-rules, there should not be a url attached.

Can we make that urlCreator optional so that the docs doesn't attach a url if not needed?

Versions

package version
@typescript-eslint/experimental-utils 5.3.1
TypeScript N/A
node N/A
@JoshuaKGoldberg JoshuaKGoldberg added triage Waiting for maintainers to take a look package: utils Issues related to the @typescript-eslint/utils package labels Nov 12, 2021
@JoshuaKGoldberg
Copy link
Member Author

Or, alternately, maybe export createRule on its own? 💡

@bradzacher
Copy link
Member

It could probably be optional - yeah.
There's no explicit need for it - but it is definitely best-practice to provide one.

By providing a documentation URL, tools can link directly to the docs which helps people understand linting so, so much more! For example, this is how vscode-eslint gives users access to the docs:

(1) Via a quick-action:
image

(2) via a link on the "rule ID"
image

IMO it's probably better to have the default require the function so that docs are the default best-practice. Making it an optional arg means that people will probably just forget about it.
I'd be in support of providing another API like createRuleWithoutDocs so that a user can explicitly opt out of providing documentation.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: utils Issues related to the @typescript-eslint/utils package triage Waiting for maintainers to take a look
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants