Questions tagged [js2-mode]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
14 views

How to display js2-mode warnings

I am running Emacs 26.1 on Ubuntu 16.4. I am writing Javascript using js2-mode. When the linter underlines a line of code, I want to know what error or warning it has detected. For example, in this ...
2
votes
2answers
74 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 ...
0
votes
0answers
26 views

Annoying indentation bug with ES6 multiline string using js-mode or js2-mode

I am using js2-mode right now. I am working on a .js file that contain a ES6 multi like string like this: Vue.component("comment", { props: { comment: { type: Object, ...
0
votes
0answers
41 views

What is a good setup for programming with Vue.js?

I'm trying to set up a good and powerful Emacs for Vue.js, but no setup worked well for me. I tried: vue-mode with lsp-mode and lsp-vue web-mode with indirect-buffer and js2-mode and tern in the ...
1
vote
1answer
79 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
170 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
74 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
60 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 ...
2
votes
1answer
231 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
259 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.
6
votes
1answer
375 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
103 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
1k 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 ...
4
votes
1answer
411 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
149 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 ) ...
1
vote
2answers
679 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
402 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
142 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
275 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
271 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
948 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
71 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'
12
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
264 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
41 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
200 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
235 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
73 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
206 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
244 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
59 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
104 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
55 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
181 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
566 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
647 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....