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

Update: Add type jsdoc to rule template #113

Merged
merged 1 commit into from Sep 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions rule/templates/_rule.js
Expand Up @@ -8,6 +8,9 @@
// Rule Definition
//------------------------------------------------------------------------------

/**
* @type {import('eslint').Rule.RuleModule}
Copy link
Member

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?

Copy link
Sponsor Member

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.

Copy link
Member

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?

Copy link
Sponsor Member

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)

Copy link
Member

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. :)

*/
module.exports = {
meta: {
type: null, // `problem`, `suggestion`, or `layout`
Expand Down