Questions tagged [javascript]

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

Filter by
Sorted by
Tagged with
19
votes
4answers
5k views

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 ...
19
votes
3answers
5k views

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 ...
11
votes
1answer
5k views

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 ...
9
votes
1answer
3k views

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 ...
9
votes
1answer
3k views

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] = ...
7
votes
3answers
2k views

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 ...
7
votes
2answers
3k views

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 ...
6
votes
2answers
1k views

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-...
5
votes
1answer
456 views

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 ...
5
votes
1answer
692 views

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 ...
5
votes
1answer
623 views

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: ...
4
votes
1answer
454 views

What's the relationship between js-mode and js2-mode?

I saw there is a js-mode bundled in Emacs. I've also seen a js2-mode. However, I have also seen Emacs git log on js-mode refers to js2-mode bug reports. What is the relationship between them?
4
votes
0answers
364 views

Web mode -indentation is misaligned on skipping semicolons

When i indent javascript code (inside html - web mode) that has no semicolons in it, the next statements are indented right with two extra spaces, <script> function processTemplates(){ ...
3
votes
2answers
1k views

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. ...
3
votes
2answers
579 views

Stop javascript-mode from lining up function parameters after newline

Using javascript-mode, functions are indented like this: console.log('Example', var1, var2); test('Example2', var1, var2); I'd like to change this so that ...
3
votes
1answer
3k views

Cannot jump to definition in js2-mode or Tern

I am performing Nodejs development in emacs, but my environment seems incorrect. For example, when I run ac-js2-jump-to-definition, I get "no jump location found" in the minibuffer. Also when I run '...
3
votes
1answer
1k views

Receive error when trying to use tern mode

I have installed tern use npm and install tern.el from melpa. I put the path of tern.el in my init file as per instructions on the emacs section of the tern homepage. However when I enable tern mode ...
3
votes
1answer
215 views

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', () => { ...
3
votes
1answer
1k views

Emacs as JavaScript IDE. What is the best package for this?

Windows 10, Emacs 25.1 I want to write many JavaScript files on Emacs. And as result I need comfortable mode to work with javascript. So as result I want to use Emacs as JavaScript IDE. The ...
3
votes
0answers
192 views

How to generate TAGS tables for JavaScript with React?

I'd like to create TAGS tables for JavaScript ES6 code using React like the following: import React from 'react' import { observer } from 'mobx-react' import { Formik, Form, Field } from 'formik' ...
3
votes
0answers
1k views

flycheck eslint for javascript

I'm trying to setup a lint for javascript files. Here's the relevant setup I have. (use-package js2-mode :ensure t :init (progn (add-to-list 'auto-mode-alist '("\\.js?\\'" . js2-jsx-...
2
votes
2answers
391 views

Define key to toggle between javascript implementation and test file

I have been trying to set up a shortcut for jumping between a JavaScript implementation and test. I have particular requirements that are making examples I see harder to apply. I currently work with ...
2
votes
1answer
1k views

Javascript not autocompleting with Yasnippet and Auto-complete

I really want to use emacs as a Javascript IDE. I have followed all the directions I can, includings Yasnippets and Autocomplete, but I still have some issues. If you look at the differences, in ...
2
votes
2answers
2k views

How to display the list of functions in iMenu and collapse/uncollapse functions in angular js file

I use js2-mode with emacs-prelude, imenu displays the list of functions and I can collapse and uncollapse the functions defined in a regular js file like this function testFunction1(){ console....
2
votes
1answer
81 views

How to prevent Emacs from converting JavaScript symbols to HTML code?

When I insert a portion of JavaScript code within an HTML file, Emacs convert some basic JS symbols to their HTML code. For example when I type >, Emacs convert it automatically to &gt; which ...
2
votes
1answer
245 views

Fixing wrong-type-argument to looking-at in Emacs 25 js-mode on large files

When using js-mode (or js2-mode) on Emacs 25.1 (in Debian 9) to edit some large files, any attempt to insert text after some "random" point in the file fails with an elisp stack trace: Debugger ...
2
votes
2answers
291 views

Changing how argument lists are indented in JavaScript

Right now, my argument lists are indented by js-mode like this: some_long_function_name( one_argument, another_argument ); How can I get them to look like this: ...
2
votes
2answers
128 views

How to show all functions in a javascript file?

How to show all functions in a js file? I am using js2, but any solution will do. Additional info: I am expecting an occur style buffer. This can persist and be edited if necessary. Or searched. This ...
2
votes
1answer
60 views

Align the values of a JavaScript map

Say that you have the following JavaScript map literal {a: 1, aoeu: 2} and want the values aligned for readability like {a: 1, aoeu: 2} Is this possible to do with emacs? I'm currently using ...
2
votes
1answer
1k views

How to enable type-check rules with flycheck-tslint

I want flycheck to use the tslint's --type-check flag to compile my typescript files. In order to see unused imports on the fly inside emacs. By tslint docs --type-check Enables the type ...
2
votes
1answer
234 views

How to detect and match indentation size of current buffer

I'm working on a javascript project that has inconsistent tab sizes 2spaces vs 4spaces on the server and client. I'm using web-mode for javascript editing. I'm looking for a feature like SublimeTexts ...
2
votes
2answers
393 views

Can't get a Node REPL with swank-js

I have followed the instructions on Github for setting up swank-js. I installed slime and slime-js from github and have the following in my .emacs file: (add-to-list 'load-path "~/slime/") (...
2
votes
1answer
86 views

How to control JavaScript indentation?

I am coding in Node.js, each time I want to write something that looks like this: const product = Factory .model('App/Models/Product') .create() I get this as an output: const product = Factory ...
1
vote
3answers
3k views

Flycheck with eslint doesn't use ~/.eslintrc

I'm having trouble getting flycheck to use the .eslintrc file in the root of the current project, and I'm struggling to find any documentation that will tell me how to configure it to use the ...
1
vote
1answer
198 views

Syntax highlighting inside HTML5 <script> tags

I was curious if there was a way to get highlighting/indentation for any JavaScript that's inside of HTML5 tags? I don't frequently use JavaScript but for a class I'm in we're working with it. I ...
1
vote
1answer
403 views

Unable to Set Javascript Indent on Spacemacs

I have a vanilla Spacemacs setup, and in my .spacemacs file, the dotspacemacs/user-config definition I have added (setq js2-basic-offset 2) which should be sufficient to set the indent length as 2. I ...
1
vote
1answer
71 views

How can I modify a variable in a javascript file that meets specific conditions?

Lets say I'm editing a javascript file in emacs that has objects as such scattered through out the file: foo: [1], foo: [2], foo: [3], foo: [4], foo: [5], foo: [6], foo: [7] obo: [1], obo: [2], obo: [...
1
vote
1answer
656 views

js2-mode customizations not applying

No matter what I do, the customizations I apply to js2-mode are not going into effect. The mode is on and working, but with default settings. I've tried changing the default-tab-width to 2 and ...
1
vote
1answer
60 views

ES6 imports auto suggestion

I'm new to emacs and trying to setup emacs for ES6/React developement. I would like to have auto suggestions for es6 imports like lodash similar to vscode (as shown in screenshot). Is there a way to ...
1
vote
1answer
215 views

ELDoc and company-tern are not working properly in JS2-mode (.js buffer in node) and Javascript, in Emacs

In my Emacs configuration for JavaScript/ JS2-mode, specifically .js buffer in node: (1) company-tern and ELDoc are NOT working properly. For eg. when I type 'console.l', 'log' does not pop up, ...
1
vote
1answer
37 views

How to make RET insert a blank line and indent and put point on this line when point between `{}`?

In most JavaScript IDEs, there is a feature that pressing RET when point is between {}, results in an indented blank line with point on the end of this blank line, as shown in the following two ...
1
vote
1answer
327 views

Web-mode uses 1 space indent instead of 2

I have this config in my init.el: (setq-default indent-tabs-mode nil) (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) (defun my-web-mode-hook () "Hooks for Web mode." (setq web-mode-...
1
vote
1answer
517 views

web-mode for .js suffixed files

I have (somewhat) successfully installed and configured web-mode. But one thing doesn't work /w (react.js) JSX: I'm doing a project that requires the files to have the suffix '.js' and I'm trying to ...
1
vote
1answer
346 views

Emacs indent AngularJS code to wrong level

It's really sad not to write well formatted angularJs code inside emacs, the image below shows what I am saying. What is happening inside the photo is that the code is already well formatted as it is,...
1
vote
2answers
184 views

js-comint mode (node) returning too many undefined responses?

I am using js2-mode and comint-mode to run the Node REPL in emacs. For some reason the prompt is returning a lot of undefined and ...undefined responses, which it wouldn't do normally. for instance, ...
1
vote
1answer
94 views

Cannot add general block header arguments in org mode

While I'm learning javascript following a book, I Like to take notes with org-mode. I use Indium and followed this instructions to handle it working It works well, and I get my work done, interacting ...
1
vote
0answers
17 views

tide-mode in org-edit-src-code

I want to activate tide-mode when using Javascript soruce code blocks, following this it works well with indium: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-js.html But I want to use ...
1
vote
0answers
24 views

Migrate Webstorm Code Highlighting

I am currently using Webstorm as my daily driver but I am trying to look into Emacs and possibly transition. One of the most important things to me that I have spent the last 3 years on was to ...
1
vote
1answer
82 views

set js-indent-level from .eslintrc?

when I edit javascript, I'm usually actually editing someone else's code. Is there a way to dynamically set the value of js-indent-level from a .eslintrc file?
0
votes
1answer
276 views

smartparens with strict mode in javascript

I am trying to configure smartparens to work with javascript, my config looks like this: (use-package smartparens :ensure t :diminish smartparens-mode :commands (smartparens-mode ...