question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 (in import 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:closed
  • Created 6 years ago
  • Reactions:53
  • Comments:33 (9 by maintainers)

github_iconTop GitHub Comments

8reactions
clshortfusecommented, May 9, 2018

VSCode (and Typescript) now supports

/** @typedef {import('../foo/bar').baz} baz */

So you don’t have to perform unused imports anymore.

7reactions
ChadKillingsworthcommented, Nov 1, 2017

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:

import Foo from 'foo';

{
  const Foo = somethingElse;
  /**
   * @param {Foo} what does this mean? -- it means somethingElse. No ambiguity at all.
   */
  function x() {}
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found