So I have this function:
function render(){ // do stuff }
I do not call that function, because it is called from html as an event function, like:
<textarea id="input" class="input-box" onkeyup="render()"></textarea>
Well eslint
does not see that, so it gives that warning (render
is defined, but never used). Is there a way to specify that function is called elsewhere? Or just mute the warning?
For example if global variable is used, I can do /* global SomeVar*/
and it will mute warning of not defined variable. Maybe something similar could be done on functions like in example?
disable warnings eslintUse /* eslint-disable */ to ignore all warnings in a file. You may use special comments to disable some warnings. Use // eslint-disable-next-line to ignore the next line. Use /* eslint-disable */ to ignore all warnings in a file.
Add no-unused-vars-rest to the plugins section of your . eslintrc configuration file, and configure the rule under the rules section. Don't forget to disable the core rule no-unused-vars . Alternatively you may use the plugin's recommended configuration, which applies the above configuration.
If you are using ESLint and you need to disable the next line, use this code: eslint-disable-next-line.
Provide a config comment telling it to ignore that rule (defined but never used is the no-unused-vars
rule)
function render() { // eslint-disable-line no-unused-vars // do stuff var x; // still raises defined but never used }
If you dont want to change the code.
ESLint provides both a way to disable, both to enable the linting via comments. You only added before functions /* eslint-disable */
and after functions /* eslint-enable */
Example
/* eslint-disable */ <-- Before function function render(){ // do stuff } /* eslint-enable */ <-- After function
More info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With