-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
check-tag-names: targeting JSDocs unnecessary with a type checker (e.g. TypeScript) #1005
Comments
We already support this through the likes of: settings: {
jsdoc: {
tagNamePreference: {
abstract: false,
},
},
}, ...but as I understand ESLint will not merge this beyond a single depth (i.e., it won't merge it with other jsdoc settings), I think we should add a blacklist option as well, and we can use that within the TypeScript config. |
Thanks for the quick response! A couple reasons why I don't think that solution is adequate:
|
I'm fine in theory with a separate rule and context-dependent tag allowances, but with this package being oriented to plain JSDoc as well as TypeScript users, I'm not sure we want to be adding a TypeScript dependency. Hopefully the detection you require can be done just by looking at the JSDoc structure and surrounding JS/TS AST? |
Cool, though it just occurred to me that we might be able to just add |
I'll admit, I'm not super familiar with how
That's a lot of configuration - and specific tailored 🧑🔧 fixers! And it's likely to change over time as TypeScript adds more support for JSDoc. Even if this is all doable in Footnotes
|
Ok, you make a compelling case, and it is good to see the rules spelled out. (I assume other JSDoc tags which are unrelated to types and have no special meaning for TypeScript would be allowed like I think though that users would still be best served if we kept the behavior within the |
🎉 This issue has been resolved in version 40.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Motivation
There are quite a few tags that are unnecessary when using TypeScript, such as
@abstract
,@access
/@private
, and@class
. Other tags are unnecessary when there's no comment, such as@this
. It'd be nice to have a lint rule that flags those unnecessary tags.This actually exists today in DefinitelyTyped-tools, the repo that contains dtslint rules for DefinitelyTyped. Its tracking issue for porting rules from TSLint to ESLint/typescript-eslint is microsoft/DefinitelyTyped-tools#648.
Current behavior
The
no-types
rule is similar in intent, but only covers unnecessary types. It doesn't cover other tags.Desired behavior
A port of the dtslint rule
no-redundant-jsdoc2
: https://github.com/microsoft/DefinitelyTyped-tools/blob/d5429a4fdb0832e89510ad35e44c7b32fa0149da/packages/dtslint/src/rules/noRedundantJsdoc2Rule.tsAlternatives considered
We could keep the implementation inside DefinitelyTyped-tools... but the plumbing in this project around JSDoc parsing & reporting is quite useful! ❤️ -
This seems like a universally applicable rule for TypeScript projects. I'd want to add it to the
recommended-typescript(-error)
presets.The text was updated successfully, but these errors were encountered: