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

ESLint setting to support multiple attributes on 1 line in HTML #97

Open
ReneDrie opened this issue Feb 12, 2019 · 5 comments
Open

ESLint setting to support multiple attributes on 1 line in HTML #97

ReneDrie opened this issue Feb 12, 2019 · 5 comments

Comments

@ReneDrie
Copy link
Collaborator

It's default practice to put multiple attributes on a single line (if they fit within the line length) for HTML attributes. But currently this is disabled, so you always need to put all attributes on a new line.

We can add the following rule to ESLint to enable multiple attributes if they fit in the line length:
'vue/max-attributes-per-line': [2, { 'singleline': 999, 'multiline': { 'max': 1, 'allowFirstLine': false, }, }],

The only thing here is that when you do go over the line length, you'll have to modify all attributes. But maybe prettier can fix this?

@ThaNarie
Copy link

If it's solvable by prettier, then the lint rule could just be disabled, right?

@ReneDrie
Copy link
Collaborator Author

If it's solvable by prettier, then the lint rule could just be disabled, right?

I'm not sure if this is also solvable by prettier, might be good to investigate.

@hjeti
Copy link
Owner

hjeti commented Feb 12, 2019

We don't use prettier for vue files. SInce a few months it has support for vue but it did some weird things when I ran it on a vue file. I can check if they have updated the formatting or otherwise make the change proposed by rene.

@gianko
Copy link
Collaborator

gianko commented Feb 12, 2019

I really like this rule.

You can see all the attr right there, also is easy to add new, copy/paste if they are all in different lines.

@ReneDrie
Copy link
Collaborator Author

That was indeed the case. For consistency this right might be great. But native HTML rules always said that it's allowed to have multiple rules on a single line, as long as it fit's without the line length

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

4 participants