Questions tagged [javascript]

for the use (typically editing) of JavaScript code in Emacs.

For generic questions, use the tag . For the latest for , use the tag. Unrelated to is the support for the language in Emacs.

Useful Links

109 questions
22
votes
3 answers

How to use skewer-mode?

I am currently struggling to use skewer-mode in Emacs. I downloaded and installed skewer-mode via MELPA, so all the dependencies should be inplace. For testing purposes I even downloaded the boidsjs demo. I'll open up boids.js, then type…
JacksGT
  • 393
  • 2
  • 9
19
votes
5 answers

How to edit jsx (react) files in emacs?

I've use js2-mode but it don't indent html in javascript properly. I've found this repo https://github.com/jsx/jsx-mode.el but it's not for react, it's for some other jsx. What do you use for editing react application with jsx files?
jcubic
  • 691
  • 1
  • 4
  • 16
13
votes
1 answer

How to get org-babel source block working with ES6-7?

I'm having difficulty getting org-babel to evaluate this block of code with emacs v24.5 node v5.0.0 babel-node v.6.6.5 #+BEGIN_SRC js :cmd "babel-node" let arr = [1, 2]; let [x, y] = arr; console.log(x); console.log(y); …
Johnathan Foong
  • 133
  • 1
  • 6
13
votes
2 answers

How prettify (newlines and indentation) an optimized HTML/JS file?

For example, I have the following bunch of characters (HTML): http://pastebin.com/pwTPp8wd I thought everyone stumbled it upon a processed file, especially when someone would speed up the processing of large HTML/Javascript/whatever file. Then there…
ReneFroger
  • 3,855
  • 22
  • 63
11
votes
1 answer

How to navigate a JavaScript project?

I'm currently working on a JavaScript project using Backbone.js and I wonder how can I navigate between files, based on method and object definitions. For example, I keep references to some of my views in the global object App.Views, and I would…
caisah
  • 4,056
  • 1
  • 23
  • 43
11
votes
1 answer

Javascript mode compatible with es6

Does anyone know of a javascript editing mode that supports the es6 syntax additions (arrow functions, extends, imports, generators, etc.)? I've done some quick searching but it looks like so far everyone just uses js2-mode and ignores the syntax…
lmjohns3
  • 253
  • 4
  • 11
8
votes
3 answers

How can I make emacs support javascript ES6 template string literals?

I want to use ES6 template string literals e.g.: `string text line 1 string text line 2 string text ${expression}` However emacs doesn't recognize that their contents are a string, so syntax highlighting, indentation, etc. don't work. How can I…
dshepherd
  • 1,281
  • 6
  • 18
7
votes
2 answers

How to indent 4 spaces for case in switch in javascript mode

I'm using default javascript mode and the switch..case look like this: switch (component) { case 'action-message': result = actionMessage(response); break; case 'action-confirmation': result =…
jcubic
  • 691
  • 1
  • 4
  • 16
5
votes
1 answer

Commenting out some JSX code section with Emacs 27 js-mode

When I comment out (M-x comment-dwim) some section of JSX code with the new js-mode in Emacs 27, it gives: // // // // Is there any way to make js-mode behave like it…
cjauvin
  • 594
  • 4
  • 15
5
votes
1 answer

Indent javascript arrow functions like regular anonymous functions

Using Emacs 25.1 and js-mode for javascript editing. Is it possible to change the indention rules in js-mode to customize the indention of arrow functions? Example of anonymous function indention: const x = list.map(function (x) { return…
lookyhooky
  • 949
  • 7
  • 18
5
votes
1 answer

How do I make javascript-mode not turn all 8 spaces into tabs?

This is what javascript-mode generates with standard tabbing (I never hit the space key when making it). I'd like to have the files contain no tab characters. I can't seem to find any option in the Easy Customization mode.
Shelvacu
  • 153
  • 5
5
votes
1 answer

How to set temporary file directory for flycheck eslint (outside of current directory)

flycheck-mode creates temporary files in the current directory. That is annoying. How can I disable/set the default place for these temporary files. I use javascript eslint syntax checker for react jsx files.
eguneys
  • 175
  • 6
4
votes
1 answer

Evaluate JavaScript source block in org-mode

If I attempt to evaluate a JavaScript source block then I have to return a value to get a result. For example: #+begin_src js return 1 + 2; #+end_src #+RESULTS: : 3 That's a bit unusual. I guess that the code block is treated as the body of a…
gburnett
  • 165
  • 7
4
votes
2 answers

Javascript ES6, React, and EMACS

So, I'm finding myself writing React a lot, and not finding myself happy doing so in EMACS. I've been resorting to Visual Studio Code, which is a fine editor but suffers seriously by not being EMACS. There seem to be a whole bunch of bits and pieces…
Charlie Martin
  • 349
  • 1
  • 9
4
votes
1 answer

Make emacs to use only tabs for JS indentation

I've set my tabs to 4 and haven't changed any JS indent settings. All the indents I found in the "JavaScript group" have values either 0 or 4, yet the following code describe('test Info', () => { it("should respond with Info", done => …
maaartinus
  • 235
  • 1
  • 7
1
2 3 4 5 6 7 8