vim
Update at 2015-9-12:
(Optional) Install node.js and jshint (with npm install -g jshint
).
Now you can check syntax with jshint myfile.js
.
Then install lint plugin scrooloose/syntastic for vim:
-
add
Plugin 'scrooloose/syntastic'
into ~/.vimrc; -
Run
vim +PluginInstall
, there are totally 6.0MB for its repo, so you have to wait quite a while;
Now open a js file, and do some editing. When file saved, syntastic will mark the lines with errors.
To verify which checker is enabled when editing, run :SyntasticInfo
in vim.
Check "2.1. Requirements" in syntastic page above for details.
google/closure-linter
To install google/closure-linter as the checker:
git clone https://github.com/google/closure-linter.git
cd closure-linter
sudo python ./setup.py install
cd ..
sudo rm -rf closure-linter
Now you can use gjslint myfile.js
as the checker in terminal.
To make syntastic use gjslint,
add let g:syntastic_javascript_checkers = ['gjslint']
into ~/.vimrc.
jshint
Ref:
Update at 2015-5-11:
See Equipping Vim for JavaScript.
The plugin YouCompleteMe is very big (about 200MB for now). You have to wait quite a while when install this plugin using Vundle.
When install plugin with Vundle, you have to save .vimrc and quit,
then run PluginInstall
or PluginClean
in a new vim window.
Note: To remove a plugin managed by Vundle in vim, remove declaration in .vimrc, then run PluginClean
in vim.
--- Old Post ---
-
Install nvm;
-
Install node with nvm;
-
Install jshint with npm, which is a tool in node:
npm install -g jshint
; -
Check syntax with
jshint myfile.js
; -
Check html syntax with Tidy, which is installed on Ubuntu with
apt-get install tidy
;
Ref: VIM + JSLint?
Eclipse
Eclipse's javascript development tools JSDT is part of WTP (web tools platform), which is a built-in plugin of "Eclipse JEE" (Eclipse for Java EE Developers).
Its editor has auto syntax checker. Config it in [Window -> Preferences -> JavaScript -> Editor]. Config its code style (tab size, for example) at [Window -> Preferences -> JavaScript -> Code Style -> Formatter].