Skip to content
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

Add svelte/attributes-line-break #762

Open
jamesst20 opened this issue May 23, 2024 · 2 comments
Open

Add svelte/attributes-line-break #762

jamesst20 opened this issue May 23, 2024 · 2 comments
Labels
enhancement New feature or request new rule

Comments

@jamesst20
Copy link

jamesst20 commented May 23, 2024

Motivation

There are currently 2 existing rules that helps formatting attributes line break:

  • "svelte/first-attribute-linebreak"
  • "svelte/max-attributes-per-line"

The problem with them is that there is no way to consider the line length to enforce proper style.

Description

"svelte/attributes-line-break": ["error", { printWidth: 90 }]

Examples

<script>
</script>

<!-- ✓ GOOD -->

<!-- 41 characters -->
<MyComponent attr1="test" attr2="test" />

<!-- 99 characters -->
<MyComponent
  attr1="test"
  attr2="test"
  attr3="some very long text that takes spaces and many..."
/>

<!-- ✗ BAD -->

<!-- 41 characters -->
<MyComponent
  attr1="test"
  attr2="test"
/>

<!-- 99 characters -->
<MyComponent  attr1="test"  attr2="test"  attr3="some very long text that takes spaces and many..."/>

Additional comments

These are only examples, I am not very much opiniated on the rule name or customization as long as it can give the proper result in the end.

Right now Prettier is able to enforce this style correctly, however Prettier is very opiniated and doesn't offer much customization and i would like to get rid of it.

@jamesst20 jamesst20 added enhancement New feature or request new rule labels May 23, 2024
@ota-meshi
Copy link
Member

Thank you for the rule suggestion.
I'm interested in that rule, but I think it conflicts with svelte/max-attributes-per-line.
Could you please consider changing the rule so that it doesn't conflict, or consider deprecating svelte/max-attributes-per-line and creating a new rule that includes the use case of svelte/max-attributes-per-line?

https://sveltejs.github.io/eslint-plugin-svelte/rules/max-attributes-per-line/

@jamesst20
Copy link
Author

Thank you for the rule suggestion. I'm interested in that rule, but I think it conflicts with svelte/max-attributes-per-line. Could you please consider changing the rule so that it doesn't conflict, or consider deprecating svelte/max-attributes-per-line and creating a new rule that includes the use case of svelte/max-attributes-per-line?

https://sveltejs.github.io/eslint-plugin-svelte/rules/max-attributes-per-line/

Indeed I'm open to all this. I currently have these 2 rules disabled in favor of Prettier for the time being until anyone implement this suggestion :)

Do you have a proposal? I could edit the top post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new rule
Projects
None yet
Development

No branches or pull requests

2 participants