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. Use node in es6 syntax with babel transpiling
  2. Chromium flag to by pass the popup to grant media permissions in webRTC
  3. Writing multiline sql queries in javascript using knex
  4. Generating container components with connect utility in react redux app
  5. Use node in es6 syntax with babel transpiling
  6. Dynamic module loading with require
  7. exports is not defined
  8. Redux: Implementing store from scratch