Proposed rule change: no-unused-vars should consider a var "used" in JSDoc
See original GitHub issue- ESLint Version: 4.3.0
- Node Version: 7.10.1
- npm Version: 4.2.0
What rule do you want to change?
no-unused-vars
Does this change cause the rule to produce more or fewer warnings?
- Fewer warnings
How will the change be implemented? (New option, new default behavior, etc.)?
- New default behavior
Please provide some example code that this change will affect:
import Foo from "foo";
/**
* @param {Foo} f
*/
function bar(f){ return f.baz; }
What does the rule currently do for this code?
- The rule flags the first instance of
Foo
(inimport Foo
) as an unused var.
What will the rule do after it’s changed?
- The rule should not flag
Foo
as unused because it is referenced in the JSDoc.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:53
- Comments:33 (9 by maintainers)
Top Results From Across the Web
Avoiding eslint error no-unused-vars when importing for VS ...
When enabling this rule, types in jsdoc comments will resolve as used variables, i.e. will not be marked as unused by no-unused-vars.
Read more >no-unused-vars - ESLint - Pluggable JavaScript Linter
This rule is aimed at eliminating unused variables, functions, and function parameters. A variable foo is considered to be used if any of...
Read more >eslint-plugin-jsdoc - npm Package Health Analysis - Snyk
a string to indicate the type that should be preferred in its place (and which fix mode can replace); this can be one...
Read more >eslint-plugin-jsdoc - npm
Note that the format will not be changed unless you use a ... no-unused-vars - It is common to define variables for clarity...
Read more >How to fix Definition for rule typescript-eslint no-use-before ...
I am new to eslint and I cannot figure out how to solve this issue. The beginning of my imports ... idea how...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
VSCode (and Typescript) now supports
/** @typedef {import('../foo/bar').baz} baz */
So you don’t have to perform unused imports anymore.
As a maintainer of closure-compiler, I can pipe in here. The scope of a JSDoc comment is exactly where it occurs. From the above example: