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

Indentation is unexpected without parenthesis #93

Open
axelson opened this issue Jan 17, 2019 · 5 comments
Open

Indentation is unexpected without parenthesis #93

axelson opened this issue Jan 17, 2019 · 5 comments

Comments

@axelson
Copy link

axelson commented Jan 17, 2019

I expect different indentation for the following code:

Actual:

  render () {
    var a = (
      <div>
        abc
      </div>
    )
    var b = <div>
              abc
            </div>
  }

Expected:

  render () {
    var a = (
      <div>
        abc
      </div>
    )
    var b = <div>
      abc
    </div>
  }

Basically I expect similar indentation with and without the parentheses. Is this something that is accomplishable in rjsx-mode?

Please check if the bug still exists when using js2-jsx-mode (if applicable). If so, it is most likely an upstream bug and should be reported there.

js2-jsx-mode seems to have broken indentation in this scenario as well but in a different way

@felipeochoa
Copy link
Owner

Nope, that's not possible currently, but PRs welcome

@axelson
Copy link
Author

axelson commented Jan 17, 2019

Do you have any pointers on implementing this type of indentation?

@felipeochoa
Copy link
Owner

You may be able to get it done simply by editing `rjsx--indent-line-to-offset'

The indentation code works by tracking a parent JSX element, relative to which we indent children. This all happens here.

@vaer-k
Copy link

vaer-k commented May 3, 2019

This becomes pretty unpleasant when formatting stateless components with arrow functions:

const Stuff = ({ value, children }) =>
  <form>
    {children} 
    <input
      type="text"
      value={value}/>
  </form>

becomes

const Stuff = ({ value, children }) =>
      <form>
      {children} 
      <input
type="text"
value={value}/>
  </form>

@knobo
Copy link

knobo commented May 3, 2019

But "this" what @vaer-k is refering to is a bug in js2 (I think)
/mooz/js2-mode/issues/526

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