Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Share On Stumbleupon
Contact us
Hide Buttons

Disable eslint no-unused-vars warning on global functions

If you are not working in a nodejs or commonjs or modular environment, and you have functions that are defined in the global scope in a different file, you have probably noticed that eslint complains with the no-unused-vars lint error.

The only way that ive found that actually prevents eslint from complaining is by adding an eslint rule for a single line.
You could also potentially add it to the globals object in your .eslintrc file but I believe that leaks concerns and adds an extra step towards maintenance.

Here’s how its done.

// This is my global function that will used in another file
function foo(options) { // eslint-disable-line no-unused-vars 
}

NOTE: One of the other things I tried was adding /* exported foo */ at the top of my file, but for some reason it didn’t work. Just putting it out there in case someone else gets lucky.

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...