Skip to content

Rule proposal: vue/padding-line-between-blocks #855

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
1 of 4 tasks
posva opened this issue Mar 14, 2019 · 9 comments · Fixed by #1021
Closed
1 of 4 tasks

Rule proposal: vue/padding-line-between-blocks #855

posva opened this issue Mar 14, 2019 · 9 comments · Fixed by #1021

Comments

@posva
Copy link
Member

posva commented Mar 14, 2019

Please describe what the rule should do:

Enforce empty lines between blocks (template, script, style, and any other root level block)

What category should the rule belong to?

  • Enforces code style
  • Warns about a potential error
  • Suggests an alternate way of doing something
  • Other (please specify:)

Provide 2-3 code examples that this rule should warn about:

<!-- BAD -->
<template>
  <div></div>
</template>
<script>
export default {}
</script>
<custom></custom>
<!-- GOOD -->
<template>
  <div></div>
</template>

<script>
export default {}
</script>

<custom></custom>

Additional context

Having empty lines between blocks improves readability and allows quick navigation per paragraph ({/} in Vim)

similar to https://eslint.org/docs/rules/padding-line-between-statements#rule-details

@posva posva changed the title Empty lines between blocks Empty lines between blocks: vue/no-empty-line-between-blocks Mar 14, 2019
@posva posva changed the title Empty lines between blocks: vue/no-empty-line-between-blocks Empty lines between blocks: vue/empty-line-between-blocks Mar 14, 2019
@posva posva changed the title Empty lines between blocks: vue/empty-line-between-blocks Rule proposal: vue/empty-line-between-blocks Mar 14, 2019
@posva posva changed the title Rule proposal: vue/empty-line-between-blocks Rule proposal: vue/padding-line-between-blocks Mar 14, 2019
@nathanchase
Copy link

+1 for this rule! Additionally, I'd like to see it implemented within any given element in a Vue template, like so:

<!-- GOOD -->
<template>
    <div>
        <p>Item 1</p>

        <p>Item 2</p>
    </div>
</template
<!-- BAD -->
<template>
    <div>
        <p>Item 1</p>
        <p>Item 2</p>
    </div>
</template

@posva
Copy link
Member Author

posva commented Oct 6, 2019

@nathanchase That should definitely go in another rule as it there are many ways of configuring it. I even wonder if there isn't already something

@nathanchase
Copy link

@nathanchase That should definitely go in another rule as it there are many ways of configuring it. I even wonder if there isn't already something

I've looked, and surprisingly can't find anything within ESLint that applies specifically to ensuring newlines between elements in a Vue template.

@EmilyRosina
Copy link

➕ for the rule addition AND to separate @nathanchase's suggestion to another rule, as they're not the same thing 😸 but i also could not find any rules to satisfy either

@jacobparis
Copy link

This rule is similar to @nathanchase's suggestion and would make a good model for the new rule

https://eslint.org/docs/rules/lines-between-class-members

@gerasimvol
Copy link

same for script options, please 🙏

// BAD
export default {
  name: 'ComponentName',
  components: { .... }
}
// GOOD
export default {
  name: 'ComponentName',

  components: { .... }
}

@milewski
Copy link

milewski commented Feb 5, 2020

Please also pad the root tag itself -->

<!-- GOOD -->
<template>

  <div>

      <div>Demo 1</div>

      <div>Demo 2</div>

  </div>

</template>
<!-- BAD -->
<template>
  <div>
      <div>Demo1</div>
      <div>Demo2</div>
  </div>
</template>

@jamesdixon
Copy link

Is there an analogous option for script methods? I'm badlyyyyyy in need of this 😄

@juanbrujo
Copy link

https://eslint.vuejs.org/rules/padding-line-between-blocks.html

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

Successfully merging a pull request may close this issue.

9 participants