Eslint: disable warning - defined but never used for a specific function?

So, I have this function:

function render(){
    // do stuff
}

I do not call this function because it is called from html as an event function, for example:

<textarea id="input" class="input-box" onkeyup="render()"></textarea>

Well, he eslintdoes not see this, therefore he gives a warning ( renderdefined, but never used). Is there a way to indicate that the function is called elsewhere? Or just turn off the warning?

For example, if a global variable is used, I can do /* global SomeVar*/it and it will turn off the warning about an undefined variable. Maybe something like this could be done on functions such as in the example?

+4
source share
1 answer

, (, - no-unused-vars)

function render() { // eslint-disable-line no-unused-vars
    // do stuff
    var x; // still raises defined but never used
}
+4

Source: https://habr.com/ru/post/1682612/


All Articles