Be the first user to complete this post
|
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:
- Es6 Spread operator
- Use node in es6 syntax with babel transpiling
- Use es6 and es6+ in eslint with babel
- Use es6 and es6+ in eslint with babel
- Passing the store down implicitly via context in a react redux app