Skip to content

Rule proposition: Maximum number of props per line #47

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
filipalacerda opened this issue Jun 23, 2017 · 3 comments
Closed

Rule proposition: Maximum number of props per line #47

filipalacerda opened this issue Jun 23, 2017 · 3 comments

Comments

@filipalacerda
Copy link
Contributor

We often struggle to read templates with a different number of props per line.

This rule would limit the maximum number of props on a single line can to improve readability.
There should also be the possibility to disable this rule when a tag has only one prop.

Proposal
'vue/max-props-per-line': {max: Number, when: 'always|multiline'}

The default could be: 'vue/max-props-per-line': {max: 1, when: 'always'}

  1. Enforcing one prop per line always 'vue/max-props-per-line': {max: 1, when: 'always'}
<component 
  prop="something"
  foo="bar"
  />

<component
  prop="something"
  />
  1. Enforcing one prop per line only when it has multilines it would accept: 'vue/max-props-per-line': {max: 1, when: 'multiline'}
<component prop="something" foo="bar" />

<component
  prop="something"
  foo="bar" 
  />
@mysticatea
Copy link
Member

Thank you for this proposal.

The concept sounds good to me.
One point, I feel the when property is odd.

What do you think if it separates setting for each single line and multiline?

{
    "vue/max-attributes-per-line": ["error", {
        "singleline": 3,
        "multiline": 1
    }]
}

@filipalacerda
Copy link
Contributor Author

I took it from eslint-react-plugin 🙊 😅

I like your suggestion better! 💪

Thanks for the feedback!

@michalsnik
Copy link
Member

I was about to propose the same thing as @mysticatea :D Seems perfect, I like it!

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

No branches or pull requests

3 participants