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.

user no-unused-vars except function

See original GitHub issue

my code:

var name = 'TM';
function show() {
    console.log('this is test');
}
//something
<button onClick="show()">Test</button>
//something

it have error: error ‘name’ is defined but never used no-unused-vars error ‘show’ is defined but never used no-unused-vars

i only want to ignore function. how to do??

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Dn9xcommented, Aug 17, 2016

@platinumazure @ilyavolodin @vitorbal @ljharb very thanks. I think best way is i use // eslint-disable-line. because i dont need use CommonJS or ECMAScript modules. very thanks.

1reaction
platinumazurecommented, Aug 16, 2016

I think you want to use the /* exported */ comment here. That tells ESLint that your function is intended to be exported to global scope and used by a different file.

/* exported show */

function show() {
    // ...
}

Reference: http://eslint.org/docs/rules/no-unused-vars#exported

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
How to disable warn about some unused params, but keep ...
Only way that I found is to use ignore pattern argsIgnorePattern in rule options. If your variable is unused, just add underscore _ctx...
Read more >
option to exclude functions from no-unused-vars #5086 - GitHub
I want to keep the no-unused-vars rule as an error, but in an ES2015 module, functions that are not called are considered "unused...
Read more >
Rule no-unused-vars - ESLint中文文档
This rule is aimed at eliminating unused variables, functions and variables in parameters of functions, as such, warns when one is found. A...
Read more >
Assigned a Value but Never Used | React JS Debugging
Assigned a Value but Never Used | No Unused Vars | React JS Debugging | Eslint Warnings & Errors.
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