Home

Using StandardJS in Spacemacs/Emacs

Date: 2020-07-22

At the moment of writing this, I was using Spacemacs with its javascript layer without any customization. While working on javascript project that uses StandardJS as linter, I was getting a lot of warnings (mostly about missing semicolon), and was not getting any of StandardJS warnings.

To make javascript layer in Spacemacs work with StandardJS, I did following:

  1. Installed standard npm package globally (npm install -g standard).
  2. Turned off js2-mode's strict warnings (because it has its own linter rules which we don't want to see any more).
  3. Set indentation in js2-mode to 2 spaces.

So at the end, this is what my javascript layer configuration looks like:

emacs-lisp
(javascript :variables
            js2-mode-show-strict-warnings nil  ;; We now have standardjs for warnings.
            js2-basic-offset 2
            js-indent-level 2)

Thanks for reading till the end! If you found this interesting, check out Home for more of my writing. To learn more about my current main project, check out Wasp .

Built with care with Emacs (Org Mode).