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
Update: Add type jsdoc to rule template #113
Conversation
|
Neat! Can you explain a bit more about how this works and the benefits it provides in the PR description? It looks like this allows code editors to see the type/structure of ESLint rule objects and thus provide information/autocomplete about the various rule fields. I like it. If this turns out to be the recommended way to annotate non-TypeScript rules with type information, then we could also add it to the Working with Rules rule example: eslint/eslint#15085 |
This is the feature of vscode, and it seems also to be supported by webstorm. |
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 it!
@@ -8,6 +8,9 @@ | |||
// Rule Definition | |||
//------------------------------------------------------------------------------ | |||
|
|||
/** | |||
* @type {import('eslint').Rule.RuleModule} |
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.
Do we need to include @types/eslint
to make this work?
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.
My understanding is no. VSCode has Automatic Type Acquistion where it automatically retrieves the corresponding @types/
package for your dependencies.
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.
Huh, that’s cool. I wonder if that has any negative effect when running tsc
? I don’t want to please VS Code only to anger TypeScript. Can you double check that?
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.
These rules are JS files so I don't think anyone will be running tsc
with them?
However, I checked what happens when using @type
in a TS file, and TS shows a non-blocking hint:
JSDoc types may be moved to TypeScript types. ts(80004)
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.
Fair enough. I run TSC
on JavaScript files frequently to generate .d.ts files from JSDoc comments. :)
No description provided.