Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [js2-mode]

An improved JavaScript mode for GNU Emacs that emulates many desirable features of IDEs.

1
vote
1answer
32 views

use js2-mode instead of js-mode in org babel source

I want to use js2-mode instead of js-mode inside org-babel sources. Is there a way to define a mode for JavaScript inside those chunks? #+begin_src js console.log(1+1) #+end_src
1
vote
1answer
108 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
36 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
31 views

Toggle major mode with a custom key binding

I currently have 2 key bindings for switching between two major modes: (global-set-key (kbd "<f12>") 'js2-jsx-mode) (global-set-key (kbd "<f13>") 'web-mode) How would I reduce that to a ...
0
votes
0answers
54 views

how to get tern-mode to show documentation in the mini-buffer when autocompleting?

For my javascript setup within emacs, I am using tern-mode with company, using the following config. when auto-completing, I only get an 'usage example at dot', and the 'method signature in the mini-...
0
votes
0answers
48 views

js2-mode imenu-list - problem listing functions

export default { someMethod: function() { // will show in imenu-list }; someOtherMethod() { // will not show in imenu-list }; } However, if I change the export to export default someThing = {}...
3
votes
1answer
158 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 ...
3
votes
2answers
207 views

Refactoring javascript

How can I rename functions project wide? I am using spacemacs and also with tern, and it look like tern can only rename variables.
5
votes
0answers
272 views

How to highlight graphql template literals (gql) in js(x) files?

Inside of a jsx file, I want to use a gql template literal to define GraphQL queries. Could I in emacs make that section of the jsx file highlight graphql syntax, instead of just showing it as a ...
0
votes
2answers
77 views

Adding global variable on flycheck

I tried to add this to my eslint global variable "globals": { "document": false, "navigator": false, "window": false, "rndr": false, "shrd": false, "path": true, "$": ...
1
vote
1answer
923 views

Autocompletion with tide or tern

Autocompletion doesn't work with tide or Tern, I have to M-x company-complete-common. I would like for it to keep suggesting with a dropdown menu as I type, but I can't manage to. It works just fine ...
5
votes
1answer
341 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?
0
votes
1answer
136 views

How to allow trailing comma in function param list?

I have the following valid javascript with trailing comma in function parameters: const a = (...params) => console.log(params); a( 1, 2, 3, ); But in js2-mode I see the error missing ) ...
0
votes
2answers
488 views

Can't get prettier-js working

Am about to give up on getting this package working have tried the following options: From the prettier docs, installed the package from melpa and added the following to init.el: (require 'prettier-...
1
vote
0answers
282 views

activate prettier-js-mode after every save

I am using prettier-js-mode which is great and here is my configuration: (use-package prettier-js :commands (prettier-js-mode prettier) :init (add-hook 'js2-mode-hook 'prettier-js-mode) :bind (:...
1
vote
2answers
130 views

why is add-hook in use-package not erroring for function that does not exist

I have added a (add-hook 'js2-mode-hook 'my-js2-mode-setup) the following hook to a use-package init section: (use-package js2-mode :ensure t :interpreter (("node" . js2-mode)) :mode "\\.\\(js\\...
1
vote
1answer
231 views

How to set globals for js2-mode?

Js2-mode is showing error when there are not registered globals. I've try this code: (defun js2-hook () ;; setting symbols instead of strings also don't work (dolist (global '("angular" "$" "...
0
votes
1answer
231 views

How to disable warning in js2-mode: function does not always return a value?

Is it possible to disable warning for functions that not always return value in js2-mode?
0
votes
1answer
808 views

Autocomplete not working for JavaScript

So I can't get Auto-Complete to work for JavaScript. I've tried a variety of solutions but nothing seems to be working. Here is the relevant code snippet: ;; ;;adds js2-mode for javascript ...
0
votes
1answer
57 views

js2 mode doesn't recognize variable in “for in” statement

When I use a for in statement, js2 mode doesn't recognize the new variable: let foo = {bar: 1}; for(key in foo) { console.log(key); } It prints: Undeclared variable or function 'key'
10
votes
2answers
2k views

Can I turn off or switch the syntax checker for js2-mode?

I have a default setup of js2-mode. This provides nice syntax highlighting and checking but I am now working on a project with a different set of styles (specifically this new project does not use ...
1
vote
1answer
229 views

Adding eldoc support to js2-mode

Since js2-mode does not have eldoc-mode support, I was wondering if I could get some similar functionality to js2-mode with the help of tern-mode. tern-mode has a command tern-get-type which will ...
1
vote
0answers
38 views

How to mark / cursor inside of curly braces when opening set of curly braces

I am using js2-mode as well as electric-pair-mode and autocomplete. When I create a function using function () { and press enter the second curly brace is made on the next line but my cursor is ...
0
votes
1answer
185 views

Does Flycheck interfere with JS-2 Mode?

I realize that flycheck is a syntax checker that can be used with nearly every language's major mode. My question is how (if at all) it can interact with modes such as (specifically) js2-mode which ...
1
vote
1answer
212 views

How to set project-specific javscript indentation using js2-mode

I have several Javascript projects, where some projects use 2 spaces for indentation and other projects use 4 spaces for indentation. Is there a project-specific way to set the indentation? I am able ...
1
vote
1answer
72 views

What is causing my javascript files to auto-format?

If I have a long line in a javascript file such as: let args = [options.loadRaw ? buffer : path.resolve(filePath)].concat(options.commands); At some point when I keep adding to that line, it auto-...
1
vote
1answer
181 views

use-package and js2-mode: setting fill-column

I'm using use-package and I want my fill-column to be set to 100 for files edited with js2-mode. I tried to do so in the :config part, like: (use-package js2-mode :config (setq fill-column 100)) ...
1
vote
2answers
232 views

package listed in `list-packages' but get `Error during download request: Not Found` [closed]

This is the value of my package-archives variable: C-h v package-archives package-archives's value is (("melpa" . "http://melpa.org/packages/") ("gnu" . "http://elpa.gnu.org/...
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 '...
0
votes
1answer
57 views

Why do my js2-mode hooks work on Mac but not Fedora Linux?

I am getting very inconsistent behavior with js-mode and js2-mode hooks and I am not sure why. I have three "hooks": (add-hook 'js2-mode-hook (lambda () (setq mode-name "Zono-mode"))) (add-hook '...
0
votes
0answers
88 views

Need help with a snippet

Can someone help me with this snippet? I found it here # -*- mode: snippet -*- # name: jsdoc comment # key: doc # -- /** * $0 `(save-excursion (let* ((pos-fun (re-search-forward "\\<function\\s-*(...
1
vote
0answers
48 views

js2-mode: How to avoid automatically inserting space after a function call

For example, in js2-mode, when I type the following: console.log( the editor outputs this (assuming the | is my cursor): console.log (|) Why is there a space inserted between the function and the ...
1
vote
2answers
176 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, ...
0
votes
1answer
527 views

js2-mode: Highlighting and syntax checks only update when the buffer or mode is refreshed

As I'm typing into my buffer in js2-mode, the syntax is not being updated and all my new code is plain white. Additionally, existing text keeps its original color. For example, when I uncomment some ...
0
votes
2answers
2k views

js2-mode with flycheck and jshint

(require 'flycheck) (add-hook 'js2-mode-hook (lambda () (flycheck-mode t))) Used this, to setup flycheck for javascript development. However, i noticed config changes in .jshintrc is not ...
4
votes
1answer
2k views

js2-mode on, still emacs hunts for javascript-mode

I enabled js2-mode in emacs by adding this snippet in .emacs, (add-to-list 'auto-mode-alist '("\\.js$'" . js2-mode)) But still for .js files, emacs tries to load javascript-mode alias js-mode as ...
1
vote
1answer
625 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 ...
2
votes
2answers
1k 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....