Adding GJSLinter to WebStorm – Google-Closure-JSLinter JetBrains WebStorm Integration

1. install Python and GJSLinter.

(as explained here)

2. apply the patch, or download the already patched version of GJSLint

(as explained here)

3. install WebStorm6, open it, close any opened projects.

4. follow the images:

2013-04-01_202923

2013-04-01_203126

2013-04-01_203301

prepare an empty file name it config.ini

here is a sample content (values are “new line”-separated)

--strict
--ignore_errors=1,2,6,110,131,233
--jsdoc
--summary
--beep
--check_html
--nomultiprocess
--debug_indentation
--time

 

place the path for gjslint.exe, it will most probably be something like:  C:\Python27\Scripts\gjslint.exe
set the placement of the configuration file, and press OK.

2013-04-01_203910

you can run those scripts in command-line too,
but then it will be one line, and “=” will be replaced with one space.

you can change the config.ini while working in WebStorm, and the changes will be effective immediately.

 

you can also change the color of the GJSLinter notifications:
2013-04-01_204445

Latest Google-Closure-JSLinter (GJSLint) – Download and Extract

set sUserAgent="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1456.0 Safari/537.36"
set sURL=http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz
set sDownloadfile=closure_linter-latest.tar.gz

::rename existing to old_*
if exist %sDownloadfile% (
    ren %sDownloadfile% old_%sDownloadfile% >nul
)

::download new version
.\_res\wget.exe --continue --server-response --directory-prefix=. --user-agent=%sUserAgent% %sURL%

::extract
if exist %sDownloadfile% (
    ::extract archive  -- x=eXtract, z=filter through gZip, v=be Verbose(show activity), f=filename.
   .\_res\tar xzvf %sDownloadfile%

   ::remove archive file
   del /f /q %sDownloadfile% >nul
)

pause

You can download the entire script with resources (wget to download and tar to extract the “closure_linter-latest.tar.gz” file into a folder (plain easy tar xzvf closure_linter-latest.tar.gz where x=eXtract, z=filter through gZip, v=be Verbose(show activity), f=filename).

latest_linter_with_wget_and_tar.rar

Closure Compiler by Google

Closure Products Logo (including Closure Compiler) Google Code Lab Logo

Google’s Closure Compiler Service is basically a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.

tools that are recommended to be used along with it are:
Closure Inspector Add-On for firefox.
Firebug JavaScript debugger.

there are two ways using the Closure Compiler through command-line, and the online service,

first one, is by using the recent build, that can be download from this URL: http://closure-compiler.googlecode.com/files/compiler-latest.zip.
to use the advance attribute of the compiler you might want to use the following command:

 
java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --warning_level VERBOSE  --js 1.js --js_output_file 2.js

rem where 1.js is the original javascript file.
rem and 2.js is the name for the output file.

second way is using the online service at http://closure-compiler.appspot.com/home
closure-compiler screen example by Elad Karako

Once the compiler has been rendered a fixed, more compact code (but not exactly readable), you can use it as it is (highly compressed), or another good option is to run it through the Javascript unpacker and beautifier by Einar Lielmanis, to make it more readable, or, “human-friendly”.