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

[Feature request] One attribute per line, if more than n attributes #191

Closed
RobertAKARobin opened this issue Jun 10, 2024 · 4 comments · Fixed by hashim21223445/eslint-plugin-prettier#1

Comments

@RobertAKARobin
Copy link
Contributor

RobertAKARobin commented Jun 10, 2024

type options = {
  enforceIfMoreThan: integer,
  closeStyle: `newline` | `newline-indent` | `sameline`
}

Example

{
  "@html-eslint/attribute-newline": ["error", {
    "enforceIfMoreThan": 2,
    "closeStyle": "newline"
  }]
}
<img alt="foo" src="foo.jpg" />

<img
  alt="foo"
  class="myclass"
  src="foo.jpg"
/>

Example

{
  "@html-eslint/attribute-newline": ["error", {
    "enforceIfMoreThan": 1,
    "closeStyle": "newline-indent"
  }]
}
<img src="foo.jpg" />

<img
  alt="foo"
  src="foo.jpg"
  />

Example

{
  "@html-eslint/attribute-newline": ["error", {
    "enforceIfMoreThan": 0,
    "closeStyle": "sameline"
  }]
}
<img />

<img
  alt="foo" />

Please let me know if this already exists — I didn't see it. If not I may try to make a PR for it.

@yeonjuan
Copy link
Owner

Hi @RobertAKARobin Thank you for your suggestion.I agree to add this rule. 👍
How about attrs-newline for the rule name? There are rules that include “attrs” in the name, so it would be nice to be consistent.

  • require-attrs
  • no-duplicate-attrs
  • ...

"closeStyle": "newline-indent"

I don't think we need this option in this rule, we already have a rule that deals with indent. - https://html-eslint.org/docs/rules/indent
If the new rule handles indentation, then the ndent rule and the new rule might conflict if used together.

@RobertAKARobin
Copy link
Contributor Author

Sure, that all makes sense to me!

RobertAKARobin added a commit to RobertAKARobin/html-eslint that referenced this issue Jun 18, 2024
RobertAKARobin added a commit to RobertAKARobin/html-eslint that referenced this issue Jun 18, 2024
RobertAKARobin added a commit to RobertAKARobin/html-eslint that referenced this issue Jun 18, 2024
RobertAKARobin added a commit to RobertAKARobin/html-eslint that referenced this issue Jun 18, 2024
@gian1200
Copy link
Contributor

Quick question. This new rule was added to the recommended list. Was it expected?

@RobertAKARobin
Copy link
Contributor Author

@gian1200 One of the tests failed unless the rule was added to the recommendations, so I assumed new rules were supposed to be added.

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