-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add url
s pointing to docs on all messages
#273
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the idea of adding more metadata for reporters to be able to surface 👍
const id = typeof meta === 'string' ? meta : meta.origin | ||
const url = typeof meta === 'string' ? undefined : meta.url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would make sense to use some of the same semantics eslint
uses? 🤔
They leverage a docs
field https://eslint.org/docs/developer-guide/working-with-rules#rule-basics
docs
(object) is required for core rules of ESLint:
description
(string) provides the short description of the rule in the rules indexcategory
(string) specifies the heading under which the rule is listed in the rules indexrecommended
(boolean) is whether the "extends": "eslint:recommended" property in a configuration file enables the ruleurl
(string) specifies the URL at which the full documentation can be accessed (enabling code editors to provide a helpful link on highlighted rule violations)suggestion
(boolean) specifies whether rules can return suggestions (defaults to false if omitted)
In particular, description
, category
, and url
seem relevant.
And having it scoped (to docs
or something else) keeps url
open to any other uses we may have in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could nest the url
property inside an object property docs
. Although none of the other properties seem to map to any properties relevant to vfile messages. I also don’t really see another use case for the url
property.
I think it’s fine as-is, but if you feel strong about this and it’s ok with @wooorm,, I’ll introduce the docs
object with only url
for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly about scoping.
I do find url
floating in meta confusing though.
If I saw
{
origin: "something",
url: "https://example.com"
}
without some additional context/comments, I'd have very little understanding of the intent.
Something like:
{
lintRuleName: "something",
documentationUrl: "https://example.com"
}
would be more verbose, but clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, thoughts @wooorm? 💭
Another approach could be to update the type definition to carry some description through.
#273 (comment)
Which would benefit folks using an IDE with TS-language-server support, but would still leave ambiguity otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
category
— that’s a bit likeorigin
recommended
— more needed because ESLint does stuff by default, whereas remark-lint is opt-in onlysuggestion
— some retext rules add anactual
/expected
, but lint rules don’tdescription
— how much should this be? Markdown? Short message? Isn’t either the error message or the full readme enough?vfile-reporter
does support anote
I believe btw, which can have some more information
Re Christian’s point on:
{
origin: "something",
url: "https://example.com"
}
looking nondescript, I’d say that perhaps it is that way because of how it’s abstracted. A more practical example:
{
origin: 'remark-lint:blockquote-indentation',
url: 'https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-blockquote-indentation#readme'
},
looks clear to me.
And for types as an alternative, the description is already defined in the types (@fileoverview
) and extracted and put into the readme.
We could:
- Put that description in the JSDoc attached to the rule
- Put the description in a string (and the URL), and instead generate the readme based on actual code rather than comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could:
- Put that description in the JSDoc attached to the rule
- Put the description in a string (and the URL), and instead generate the readme based on actual code rather than comments
Yes, we could. Although I doubt this has much added value. unified-lint-rule
could support note
anyway, but I think this is out of scope for this PR.
Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably outside of the scope of the PR, but another thing I noticed.
The readme for unified-lint-rule
doesn't include an API section
Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
Looks good to me. @ChristianMurphy? |
url
s pointing to docs on all messages
This comment has been minimized.
This comment has been minimized.
Released! |
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com> Reviewed-by: Titus Wormer <tituswormer@gmail.com> Closes remarkjsGH-272. Closes remarkjsGH-273.
Initial checklist
Description of changes
Allow
unified-lint-rule
to accept an object instead of a source string, which can specify named properties, includingsource
andurl
. Theurl
is set on all reported vfile messages.All
remark-lint
rules have been updated to use an object and set theurl
.Closes #272