Emacs minor mode for auto-formatting JavaScript code.
By default, this package uses ESLint as formatter.
For details, please see --fix
option of ESLint command line.
Optional (if you use a different formatter than the default one):
Install eslint command:
npm install --global eslintCreate ~/.eslintrc file:
{
"extends": "eslint:recommended"
}For details, please see ESLint official site.
Install from MELPA.
M-x package-install RET js-auto-format-mode RET
Recommended configuration:
(add-hook 'js-mode-hook #'js-auto-format-mode)NOTE: In a Node.js project, it's recommended to install
also add-node-modules-path,
which puts project local eslint (node_modules/.bin/eslint) before global eslint.
If you use use-package,
installation and configuration are easier:
(use-package js-auto-format-mode
:config
(add-hook 'js-mode-hook #'js-auto-format-mode))
(use-package add-node-modules-path
:config
(add-hook 'js-mode-hook #'add-node-modules-path))M-x js-auto-format-execute
(or M-x j-a-f-e)
M-x customize-group RET js-auto-format RET
(or M-x cus-g RET j-a-f RET)
For example, in case of using Prettier.
First, install prettier command.
npm install --global prettierThen, customize js-auto-format-mode.
(custom-set-variables
'(js-auto-format-command "prettier")
'(js-auto-format-command-args "--write --single-quote --no-semi"))M-x add-dir-local-variable RET js-mode RET js-auto-format-disabled RET t
(defun my/enable-auto-format-on-css ()
(setq-local js-auto-format-command "prettier")
(setq-local js-auto-format-command-args "--write --no-color")
(js-auto-format-mode))
(add-hook 'css-mode-hook #'my/enable-auto-format-on-css)For each release, please see here.
git clone git@github.com:ybiquitous/js-auto-format-mode.ginpm ci
git checkout mastergit pullnpm run release:dry-runnpm run releasegit push --follow-tags
GPLv3 Β© Masafumi Koba
