Skip to content

Plugin does not properly handle disabling max-lines rule. #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bozzaj opened this issue Jan 8, 2018 · 3 comments
Closed

Plugin does not properly handle disabling max-lines rule. #339

bozzaj opened this issue Jan 8, 2018 · 3 comments

Comments

@bozzaj
Copy link

bozzaj commented Jan 8, 2018

  • ESLint Version: 4.14.0
  • eslint-plugin-vue Version: 4.1.0
  • Node Version: 8.9.1

Please show your full configuration:

rules: {
    "max-lines": ["error", {
        "max": 300,
        "skipBlankLines": true,
        "skipComments": true
    }],
}

What did you do? Please include the actual source code causing the issue.

See Vue eslint online demo

What did you expect to happen?
Expected the max-lines rule to be disabled for the document.

See Eslint demo

I can't use the same document as the Eslint demo will fail on a Vue document that starts with , but in this case, we're looking at just the fact that the document is greater than 300 lines.

What actually happened? Please include the actual, raw output from ESLint.
1:1     File must be at most 300 lines long. It's 315 lines long. (max-lines)

@mysticatea
Copy link
Member

Thank you for this issue.

I understand your intention: currently, we have no way to disable errors on the outside of <template> and <script>. And the error of max-lines is one of vue-eslint-parser's known limitations.

I don't think JS style comments make sense on the outside of <script> element.
And currently, we ignore HTML comments on the outside of <template> element, too. (#338 is a bit related)

I'm not sure the best solution... 🤔

@bozzaj
Copy link
Author

bozzaj commented Jan 8, 2018

Ah, I missed the known limitations. That makes sense unfortunately.

As for comments outside of <template> and <script>, that kind of makes sense as well, Technically, neither option (JS style or HTML style) is a perfect solution, though I expected the HTML style to work in this case, which was why I originally filed the issue under comment-directive.

eslint-plugin-html skipped <template> so I was able to disable max-lines at the beginning of the script since that was technically considered the first line.

Looking at Vue docs under Single File Components. See this link.

If you look at the example code, there's an HTML comment before the <template> tag. If you use the "following by example" decision, this would lead me to believe that comment-directive should be able to take care of the issue.

Hope you can come to some sort of decent resolution! eslint-plugin-vue is a major plus in building consistent code! In the meantime, I can use "warn" for max-lines and deal with them accordingly.

@michalsnik
Copy link
Member

I remember there was a proposal for this kind of rule that would support setting max lines for each block of code separately, as in terms of single Vue components rule for checking lines in entire component might not be really relevant. See #202
But in terms of disabling rule for entire file I'm not the is a proper solution atm. For now I guess we'll have to live with some limitations. I'll rather continue this discussion in the proposal #202 as solely max-lines rule is not very useful in Vue components as is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants