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. Passing the store down implicitly via context in a react redux app
  2. Reinitialize addthis after loading ajax content
  3. Use node in es6 syntax with babel transpiling
  4. webpack with babel6 and react