felipeochoa / rjsx-mode

A JSX major mode for Emacs
https://github.com/felipeochoa/rjsx-mode
MIT License
641 stars 32 forks source link

Wrong indentation with no parens and no semicolon #130

Open ezmiller opened 3 years ago

ezmiller commented 3 years ago

I think this may be a bug. I am seeing the following behavior when writing jsx without parens and no semicolons:

const Component = <div>Hello World</div>
      const foo = 'foo'

It should not be indented:

const Component = <div>Hello World</div>
const foo = 'foo'
felipeochoa commented 3 years ago

Hmm, it does not reproduce on my end; I get the correct indentation. Can you provide the whole file?

nawetimebomb commented 2 years ago

I think this is a common Emacs "issue". Not really an issue but how Emacs behave on indenting stuff with any mode as I have seem a similar behavior on cc-mode before. What I mean is, it's probably more related to electric-indent-mode than rjsx-mode.

It happens to me but as soon as I press TAB or RET on the second line, it will correct the indentation. You could probably add a hook to before-save-hook to new-line-and-indent.

(add-hook 'before-save-hook #'new-line-and-indent)