Skip to content
Advertisement

disable linting inside comments

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:

rules: {
    "max-len": ["warn", { "code": 80, "ignoreComments": true }]
}

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:

/* eslint-disable max-len */
YOUR LONG LINE HERE
/* eslint-enable max-len */
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement