How do I install JSLint on Ubuntu? [closed] How do I install JSLint on Ubuntu? [closed] javascript javascript

How do I install JSLint on Ubuntu? [closed]


How to install JSLint on Ubuntu:

  1. Install nodejs (includes npm, the Node Package Manager):

    sudo apt-get install nodejs
  2. Install node-jslint. either globally:

    sudo npm install -g jslint

    or locally, and include it in $PATH:

    npm install jslint

    and add this line to your.bashrc (adjust version number as appropriate)

    alias jslint='~/.npm/jslint/0.1.8/package/bin/jslint.js'


Here are the instructions I followed to have jslint working on Ubuntu 10.10/Vim 7.3 (and Mac OS X).

EDIT

So, I've just spotted a mistake in the given link. Here are the correct steps (assuming you have already downloaded and unpacked the archive to your desktop:

$ cd /path/to/jsl-0.3.0/src$ make -f Makefile.ref$ cp Linux_All_DBG.OBJ/jsl /usr/local/bin/jsl

At that point you can open a new terminal window and type $ jsl to display a quick help or invoke it from Vim or directly on a file in the terminal.

END EDIT

  • /usr/local/bin is not your "PATH", it's only one of the many directories that can be part your PATH environment variable. $ echo $PATH will tell you what these directories are and thus where you can put the jsl executable. You can also put it in another place and add an alias to your .bashrc.

  • Why do you expect to be able to run jslint from rhino?


You said you just copied the source to /usr/local/bin. You need to compile it. Follow the build instructions in the README.html

Unix

  • Use 'gmake -f Makefile.ref' to build. To compile optimized code, pass BUILD_OPT=1 on the gmake command line or preset it in the environment or Makefile.ref. NOTE: Do not attempt to use Makefile to build the standalone JavaScript engine. This file is used only for building the JS-engine in the Mozilla browser.
  • Each platform on which JS is built must have a *.mk configuration file in the js/src/config directory. The configuration file specifies the compiler/linker to be used and allows for customization of command-line options. To date, the build system has been tested on Solaris, AIX, HP/UX, OSF, IRIX, x86 Linux and Windows NT.
  • Most platforms will work with either the vendor compiler or gcc. (Except that HP builds only work using the native compiler. gcc won't link correctly with shared libraries on that platform. If someone knows a way to fix this, let us know.)
  • If you define JS_LIVECONNECT, gmake will descend into the liveconnect directory and build LiveConnect after building the JS engine.
  • To build a binary drop (a zip'ed up file of headers, libraries, binaries), check out mozilla/config and mozilla/nsprpub/config. Use 'gmake -f Makefile.ref nsinstall-target all export ship'

As for your question about the difference. It says on the download page that one is written in JavaScript itself.

We all stand on the shoulders of giants. I would like to especially acknowledge Douglas > Crockford's work on JSLint. This lint is itself written in JavaScript and is an interesting and rather sophisticated script. Crockford's ideas about good coding practices served as a springboard for many of these lint rules.