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

Indent props aligned to first. #1429

Closed
justincorrigible opened this issue Sep 13, 2017 · 5 comments
Closed

Indent props aligned to first. #1429

justincorrigible opened this issue Sep 13, 2017 · 5 comments

Comments

@justincorrigible
Copy link

Wishing there was a rule to force indentation of props similar to the parameter indentation by eslint.
https://eslint.org/docs/rules/indent#functiondeclaration

My idea would be to have something that looks like this:

<ComponentBlah prop1='stuff'
               prop2='stuff'
               prop3='stuff' />

Am I missing this as an option for an existing rule?

@jseminck
Copy link
Contributor

I don't think that we have a rule that enforces this style at the moment.

@justincorrigible
Copy link
Author

justincorrigible commented Sep 13, 2017

How difficult is it to implement such a thing for a new contributor? I may be able to give it a try.
or perhaps this is something that can be added on top of the main "indent" rule?

@jseminck
Copy link
Contributor

I think it would be possible to implement. Can't say how hard it would be, definitely not easy but not impossible either.

  • Find all JSXExpressions
  • Count the number of props in each expression. If <= 1 ignore
  • Store the location of the first prop (line, number of characters before -- I am not sure if this info is readily available but I'm quite sure it's possible to get it).
  • Check whether every other prop is on a new line and has the same amount of characters as whitespace in front of it

I'm not sure if this should be a new rule, an option to an existing rule, or if it's something we want at all. I personally do not like this style at all and much more prefer:

<MyComponent
  prop1={x}
  prop2={y}
  prop3={z}
/>

But I understand everyone wants something different 😄

@justincorrigible
Copy link
Author

Thanks 👍 may try an implementation this weekend.

@sbonami
Copy link

sbonami commented Jan 24, 2018

@hallaathrad did anything come of this?

Edit:
Oh, dupe of #398 it seems. I'll follow along there!

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

No branches or pull requests

3 participants