I want eslint to stop linting inside comments // and /* */.
when in comments I want to have freedom to write as I please. (disable 80 char limitation etc..)
that’s pretty basic in my opinion and yet I can’t find it anywhere, is there a predefined rule to do that?
Thanks
Advertisement
Answer
Sure, to disable line length checking inside comments just use the following rule in your .eslintrc.js
:
JavaScript
x
4
1
rules: {
2
"max-len": ["warn", { "code": 80, "ignoreComments": true }]
3
}
4
This way ESLint will complain about lines with more than 80 characters only if they’re not comments. Check the documentation for rule max-len for more info.
Also notice that any ESLint rule you define for your project can be ignored in specific code blocks if you want, for example:
JavaScript
1
4
1
/* eslint-disable max-len */
2
YOUR LONG LINE HERE
3
/* eslint-enable max-len */
4