JavaScript ESLint rule disable
Lint is a popular tool of performing a static code analysis. For JavaScript, you can use a popular tool ESLint. Sometimes you do not want to change some part of the code which violates the lint rules. In such case, there are a few ways how to disable the check:
- disable all rules in file
/* eslint-disable */ alert('foo');
- disable/enable certain rule/rules in file
/* eslint-disable no-alert, no-console */ alert('foo'); console.log('bar');
- disable in section
/* eslint-disable no-alert, no-console */ alert('foo'); console.log('bar'); /* eslint-enable no-alert, no-console */
- disable in line
alert('foo'); // eslint-disable-line no-alert // eslint-disable-next-line no-alert alert('foo'); alert('foo'); /* eslint-disable-line no-alert */ /* eslint-disable-next-line no-alert */ alert('foo');
To disable all rules, do not specify any.