Eslint-plugin-vue: directive-comment cannot disable max-lines rule

Created on 8 Jan 2018  路  2Comments  路  Source: vuejs/eslint-plugin-vue

eslint-plugin-vue Version: 4.1.0
eslint Version: 4.14.0

Attempting to use the rule:
<!-- eslint-disable max-lines -->

at the beginning of a large file that starts with HTML (such as a single file component) won't actually disable the rule. It'll just move the error to the comment line. It seems to be the use of comment.loc.start within processBlock() which doesn't actually start at the beginning of the line. A possible fix would be to replace this with:
{ line: comment.loc.start.line, column: -1 }

which seems to work fine.

won't do

Most helpful comment

I see (and understand) what you mean with the online demo. However, this is not the same behavior as core eslint-disable, at least not for max-lines. To properly disable the max-lines rule, you need to have the disable at the very beginning of the file.

For a .js file, you place at the beginning of the file:
/* eslint-disable max-lines */

and then the rule is disabled for that file. However, if I do the same thing in a .vue file using this plugin, the max-lines rule is not disabled. I get an error at the comment still saying that the file fails the max-lines.

See Vue eslint demo

Perhaps my bug notification referenced the new directive-comment, but I see now that's it's a general issue with the plugin itself.

I will open a separate issue.

All 2 comments

Thank you for the report.

This is intentional behavior. eslint-disable comment does not disable errors before the comment. This is the same behavior as the core eslint-disable. See online demo

I see (and understand) what you mean with the online demo. However, this is not the same behavior as core eslint-disable, at least not for max-lines. To properly disable the max-lines rule, you need to have the disable at the very beginning of the file.

For a .js file, you place at the beginning of the file:
/* eslint-disable max-lines */

and then the rule is disabled for that file. However, if I do the same thing in a .vue file using this plugin, the max-lines rule is not disabled. I get an error at the comment still saying that the file fails the max-lines.

See Vue eslint demo

Perhaps my bug notification referenced the new directive-comment, but I see now that's it's a general issue with the plugin itself.

I will open a separate issue.

Was this page helpful?
0 / 5 - 0 ratings