Be the first user to complete this post

  • 0
Add to List

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.



Also Read:

  1. Dynamic module loading with require
  2. Sublime Text plugins to boost your productivity
  3. Dynamic module loading with require
  4. Use es6 and es6+ in eslint with babel