For a while, JSX
and new es6 syntax had flaky support in emacs, but there's been huge work on a lot of packages. Using emacs for JavaScript with React, ES6, and Flow (or Typescript, etc) is really easy and powerful in Emacs these days.
This is how you can work on modern web development projects with full support for tooling like JSX, Flow types, live eslint errors, automatic prettier.js formatting, and more.
Set up web-mode
web-mode
provides most of the underlying functionality, so a huge shout-out to the maintainer(s) there.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(add-hook 'after-init-hook #'global-flycheck-mode) | |
(setq-default flycheck-disabled-checkers | |
(append flycheck-disabled-checkers | |
'(javascript-jshint))) | |
(flycheck-add-mode 'javascript-eslint 'web-mode) | |
(flycheck-add-next-checker 'javascript-eslint) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setf *print-length* 50) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defmacro with-gensyms ((&rest names) &body body) | |
`(let ,(loop for n in names collect `(,n (gensym))) | |
,@body)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let MapComponent = React.createClass({ | |
render: function() { | |
return ( | |
<p>Hi</p> | |
); | |
} | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Development version to be run inside GHCi. | |
-- | |
-- Modified DevelMain.hs to reload Chrome browser tabs on recompile | |
-- | |
-- start this up with: | |
-- cabal repl --ghc-options="-O0 -fobject-code" | |
-- | |
-- run with: | |
-- :l DevelMain | |
-- DevelMain.update |