Fork me on GitHub

Hi all. I’m fairly new to Emacs. I’ve been playing for a few months and am fairly happy with Cider etc. This week I’ve been playing with Spacemacs and failing dismally to configure to for React with JS syntax highlighting, and especially indenting. Coming from Intellij, I’m familiar with configuring a plugin to point at at project’s .eslintrc file, and all code styles app applied and checked within the IDE. Should I be attempting a similar conceptual approach with Spacemacs, or is it normal to add indent preferences etc to it’s configuration? If my eslint --fix works correctly to format my code, should I be trying to configure a feedback cycle with Spacemacs to delegate this? The more posts I read, the more confused due to recommendations using js-mode, js2-mode, react-mode with specific configurations. Anyone know of simple tutorial etc for idiomatic setup, preferably on the vanilla side of Spacemacs?


@paulspencerwilliams first of all welcome! I'm glad you have found guts to try out Emacs. By now you probably already realized - It will be a bumpy ride, but if you stay determined and patient - I can promise you someday you'll discover an incredible power. Unfortunately there isn't a simple "out of the box" recipe for anything. You will have to build your own perfect world yourself. Because what works best for you might be a complete nonsense for someone else.


you should join Spacemacs's gitter channel, people are very welcoming there and eager to help


for JS setup (or any other lang) probably it's always good to dissect the Spacemacs layer - explore every package individually, and pick and choose what you like. Usually I end up building my own layer that may or may not be dependent on the "official" layer


for fixing indentation specifically you can try setting js-indent-level var. Or use editorconfig package. Whenever I am not sure how to "fix" something in Emacs I always use apropos. in Spacemacs it's SPC F1. So I would use it and type something like: "js indent". And try to set variables. Most of the time you can change things without ever having to restart Emacs


something you might be interested in


@paulspencerwilliams - I don't know eslint, so you may be trying to do something I don't. But I remember a couple of pain points with using Spacemacs for javascript stuff. One is that I had to set js2-basic-offset to 2, which you can do with M-x customize-option. Another is that I sometimes have to manually enter jsx-mode for a JSX file. I also stifled a couple of warnings (like missing semicolon and trailing comma) through the customize menu. Hopefully that helps…


Cheers for that @jeff.terrell. I did notice discrepancy between statefull and stateless components which may be the jsx mode issue you mention


Indeed @jeff.terrell, that's related to the problem. I noticed that it was in Javascript-IDE mode when not behaving correctly, and then applying react mode seemed to fix it. I need to get more savvy at ensuring Emacs detects the file correctly and applies the right mode.


Cool, glad I could help. I haven't ever bothered to figure out the cause of the problem with jsx-mode (and will have to also try react-mode). If you find anything out, do let me know. Cheers!