1. Linux
1.1. Installation
-
Install Node.js.
sudo npm install -g jslint sudo npm update -g jslint which jslint jslint
1.2. Update
npm -v sudo npm install -g npm sudo npm update -g npm npm -v ls -al `which jslint` ls -al /usr/lib/node_modules/jslint/bin/jslint.js sudo npm install -g jslint sudo npm update -g jslint ls -al `which jslint` ls -al /usr/lib/node_modules/jslint/bin/jslint.js
1.3. Configuration
-
Append the following lines to the /etc/bash.bashrc file.
# JSLint customization. # Note: Options give problems when added alphabetically. alias jslint='jslint --todo --nomen --white --windows --browser --indent=2 --unparam --maxerr=999'
-
Append the following lines to the ~<user>/.bashrc_aliases file.
# Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries.
alias jsdiff='diff --exclude=.git --exclude=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js'
alias jsgrep='grep --exclude-dir=.git --exclude-dir=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js'
alias jslint='jslint --browser --indent=2 --maxerr=999 --nomen --unparam --white --todo --windows'
alias jshint-all='find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jshint {} \;'
alias jslint-all='find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jslint --browser --indent=2 --maxerr=999 --nomen --unparam --white --todo --windows {} \;'
1.4. Usage
jslint --color <file> jslint --nomen <file> # Allow dangling _ in identifiers jslint --sloppy <file> # Allow missing 'use strict' pragma jslint --white <file> jslint <file> jslint-all
2. macOS
2.1. Installation
-
Install Node.js.
sudo npm install -g jslint sudo npm update -g jslint which jslint jslint
2.2. Configuration
-
Append the following lines to the ~<user>/.bashrc file.
# Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries.
alias jsdiff='diff --exclude=.git --exclude=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js'
alias jsgrep='grep --exclude-dir=.git --exclude-dir=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js'
alias jslint='jslint --browser --indent=2 --maxerr=999 --nomen --white --windows'
alias jshint-all='find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jshint {} \;'
alias jslint-all='find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jslint --browser --indent=2 --maxerr=999 --nomen --white --windows {} \;'
2.3. Usage
jslint --color <file> jslint --nomen <file> # Allow dangling _ in identifiers jslint --sloppy <file> # Allow missing 'use strict' pragma jslint --white <file> jslint <file> jslint-all
3. Windows
3.1. Installation
-
Configure Command Prompt.
-
Install Git.
-
Install Node.js.
npm install -g jslint npm update -g jslint jslint
-
Open Control Panel > User Accounts.
-
Click Change my environment variables.
-
Click New.
Variable name: PATH Variable value: C:\Users\<User>\AppData\Roaming\npm\
-
Click OK.
-
Click OK.
-
Close User Accounts.
3.2. Configuration
-
Contents of the C:\Program Files\Git\bin\jsdiff.bat file.
@echo off :: Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries. diff -x=.git -x=node_modules -x=bootstrap* -x=bootbox* -x=cordova* -x=*jquery* -x=*.min.css -x=*.min.js %*
-
Contents of the C:\Program Files\Git\bin\jsgrep.bat file.
@echo off :: Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries. :: Todo: Fix issue that git grep does not recognize --exclude option. grep --exclude-dir=.git --exclude-dir=node_modules --exclude=bootstrap* --exclude=bootbox* --exclude=cordova* --exclude=*jquery* --exclude=*.min.css --exclude=*.min.js %*
-
Contents of the C:\Program Files\Git\bin\jshint-all.bat file.
@echo off
:: Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries.
find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jshint {} ;
-
Contents of the C:\Program Files\Git\bin\jslint-all.bat file.
@echo off
:: Exclude Git repository, Node.js modules, Bootstrap, Bootbox, Cordova and jQuery libraries.
find . -path "*node_modules*" -prune -o ! -iname "*.min.js" ! -iname "bootstrap*" ! -iname "bootbox*" ! -iname "cordova*" ! -iname "*jquery*" ! -size 0 -iname "*.js" -exec jslint --browser --indent=2 --maxerr=999 --nomen --white --windows {} ;
-
Contents of the C:\Program Files\Git\bin\jslint-one.bat file.
@echo off jslint --browser --indent=2 --maxerr=999 --nomen --white --windows %*
3.3. Usage
jslint --color <file> jslint --nomen <file> # Allow dangling _ in identifiers jslint --sloppy <file> # Allow missing 'use strict' pragma jslint --white <file> jslint <file> jslint-all