diff --git a/jshint.json b/jshint.json new file mode 100644 index 0000000..fd18098 --- /dev/null +++ b/jshint.json @@ -0,0 +1,15 @@ +{ + "maxerr" : 100, + "node" : true, + "curly" : true, + "eqeqeq" : true, + "latedef" : false, + "undef" : true, + "newcap" : true, + "nonew" : true, + "onevar" : false, + "trailing" : true, + "white" : false, + "sub" : true +} + diff --git a/lint.sh b/lint.sh new file mode 100755 index 0000000..8e7cf64 --- /dev/null +++ b/lint.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +./node_modules/.bin/jshint $(find ./lib -type f -name "*.js") --config jshint.json diff --git a/node_modules/.bin/jshint b/node_modules/.bin/jshint new file mode 120000 index 0000000..fca005f --- /dev/null +++ b/node_modules/.bin/jshint @@ -0,0 +1 @@ +../jshint/bin/hint \ No newline at end of file diff --git a/node_modules/jshint/.gitignore b/node_modules/jshint/.gitignore new file mode 100644 index 0000000..779f45c --- /dev/null +++ b/node_modules/jshint/.gitignore @@ -0,0 +1,3 @@ +tags +node_modules +test/system/.files diff --git a/node_modules/jshint/.gitmodules b/node_modules/jshint/.gitmodules new file mode 100644 index 0000000..e88ce8c --- /dev/null +++ b/node_modules/jshint/.gitmodules @@ -0,0 +1,3 @@ +[submodule "packages/jshint"] + path = packages/jshint + url = git://github.com/jshint/jshint.git diff --git a/node_modules/jshint/.jshintignore b/node_modules/jshint/.jshintignore new file mode 100644 index 0000000..96cb28b --- /dev/null +++ b/node_modules/jshint/.jshintignore @@ -0,0 +1,3 @@ +node_modules +packages +.git diff --git a/node_modules/jshint/.jshintrc b/node_modules/jshint/.jshintrc new file mode 100644 index 0000000..6246b8b --- /dev/null +++ b/node_modules/jshint/.jshintrc @@ -0,0 +1,40 @@ +{ + "predef": [ + "jasmine", + "spyOn", + "it", + "console", + "describe", + "expect", + "beforeEach", + "waits", + "waitsFor", + "runs" + ], + + "node" : true, + "es5" : true, + "browser" : true, + + "boss" : false, + "curly": false, + "debug": false, + "devel": false, + "eqeqeq": true, + "evil": true, + "forin": false, + "immed": true, + "laxbreak": false, + "newcap": true, + "noarg": true, + "noempty": false, + "nonew": false, + "nomen": false, + "onevar": true, + "plusplus": false, + "regexp": false, + "undef": true, + "sub": true, + "strict": false, + "white": true +} diff --git a/node_modules/jshint/HELP b/node_modules/jshint/HELP new file mode 100644 index 0000000..e5738de --- /dev/null +++ b/node_modules/jshint/HELP @@ -0,0 +1,9 @@ +Usage: jshint path path2 [options] + +Options: + + --version display package version + --config custom config file + --reporter custom reporter + --jslint-reporter use a jslint compatible xml reporter + --show-non-errors show additional data generated by jshint diff --git a/node_modules/jshint/LICENSE b/node_modules/jshint/LICENSE new file mode 100644 index 0000000..0b310fe --- /dev/null +++ b/node_modules/jshint/LICENSE @@ -0,0 +1,4 @@ +** Licensed Under ** + + The MIT License + http://www.opensource.org/licenses/mit-license.php diff --git a/node_modules/jshint/README.md b/node_modules/jshint/README.md new file mode 100644 index 0000000..4f52a77 --- /dev/null +++ b/node_modules/jshint/README.md @@ -0,0 +1,70 @@ +# node-jshint + +A command line interface and npm package for jshint. + +## Install + +To use jshint from any location (for npm v1.x) you need to install using the global (-g) flag. + + npm install -g jshint + +## Usage + +The command line interface looks like this. + + jshint path path2 [options] + +You can also require JSHint itself as a module. + + var jshint = require('jshint'); + +Note: If you are using npm v1.x be sure to install jshint locally (without the -g flag) or link it globally. + +## Text Editor Plugins + +* [gedit-node-jshint](https://github.com/niftylettuce/gedit-node-jshint) - Simply use CTRL+J in gedit to run JSHint using `node-jshint`. +* [vim syntastic](https://github.com/scrooloose/syntastic) - Run node-jshint at each file save. + +## Custom Reporters + +Specify a custom reporter module (see example/reporter.js). + + --reporter path/to/reporter.js + +Use a jslint compatible xml reporter. + + --jslint-reporter + +Show additional non-error data generated by jshint (unused globals etc). + + --show-non-errors + +## Custom Options + +Specify custom lint options (see [example/config.json](https://github.com/jshint/node-jshint/blob/master/example/config.json)). + + --config path/to/config.json + +Note: This bypasses any .jshintrc files. + +## Default Options + +The CLI uses the default options that come with JSHint. However, if it locates a .jshintrc file in your home directory (~/) it will use those options first. + +## Per Directory Options + +If there is a .jshintrc file in the current working directory, any of those options will take precedence over (or be merged with) any options found in the ~/.jshintrc file (if it exists). + +## Ignoring Files and Directories + +If there is a .jshintignore file in the current working directory, then any directories or files will be skipped over. + +Note: Pattern matching uses minimatch, with the nocase [option](https://github.com/isaacs/minimatch). When there is no match, it performs a left side match (when no forward slashes present and path is a directory). + +## Installing dependencies for development + + ./configure + +## Build Commands + + jake -T diff --git a/node_modules/jshint/bin/hint b/node_modules/jshint/bin/hint new file mode 100755 index 0000000..2b11eec --- /dev/null +++ b/node_modules/jshint/bin/hint @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./../lib/cli').interpret(process.argv); diff --git a/node_modules/jshint/example/config.json b/node_modules/jshint/example/config.json new file mode 100644 index 0000000..c417ad0 --- /dev/null +++ b/node_modules/jshint/example/config.json @@ -0,0 +1,73 @@ +{ + // Settings + "passfail" : false, // Stop on first error. + "maxerr" : 100, // Maximum error before stopping. + + + // Predefined globals whom JSHint will ignore. + "browser" : true, // Standard browser globals e.g. `window`, `document`. + + "node" : false, + "rhino" : false, + "couch" : false, + "wsh" : true, // Windows Scripting Host. + + "jquery" : true, + "prototypejs" : false, + "mootools" : false, + "dojo" : false, + + "predef" : [ // Custom globals. + //"exampleVar", + //"anotherCoolGlobal", + //"iLoveDouglas" + ], + + + // Development. + "debug" : false, // Allow debugger statements e.g. browser breakpoints. + "devel" : true, // Allow developments statements e.g. `console.log();`. + + + // ECMAScript 5. + "es5" : true, // Allow ECMAScript 5 syntax. + "strict" : false, // Require `use strict` pragma in every file. + "globalstrict" : false, // Allow global "use strict" (also enables 'strict'). + + + // The Good Parts. + "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons). + "laxbreak" : true, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. + "bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.). + "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. + "curly" : true, // Require {} for every new block or scope. + "eqeqeq" : true, // Require triple equals i.e. `===`. + "eqnull" : false, // Tolerate use of `== null`. + "evil" : false, // Tolerate use of `eval`. + "expr" : false, // Tolerate `ExpressionStatement` as Programs. + "forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`. + "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` + "latedef" : true, // Prohipit variable use before definition. + "loopfunc" : false, // Allow functions to be defined within loops. + "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. + "regexp" : true, // Prohibit `.` and `[^...]` in regular expressions. + "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. + "scripturl" : true, // Tolerate script-targeted URLs. + "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. + "supernew" : false, // Tolerate `new function () { ... };` and `new Object;`. + "undef" : true, // Require all non-global variables be declared before they are used. + + + // Personal styling preferences. + "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. + "noempty" : true, // Prohibit use of empty blocks. + "nonew" : true, // Prohibit use of constructors for side-effects. + "nomen" : true, // Prohibit use of initial or trailing underbars in names. + "onevar" : false, // Allow only one `var` statement per function. + "plusplus" : false, // Prohibit use of `++` & `--`. + "sub" : false, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. + "trailing" : true, // Prohibit trailing whitespaces. + "white" : true, // Check against strict whitespace and indentation rules. + "indent" : 4 // Specify indentation spacing +} + diff --git a/node_modules/jshint/example/reporter.js b/node_modules/jshint/example/reporter.js new file mode 100644 index 0000000..8839853 --- /dev/null +++ b/node_modules/jshint/example/reporter.js @@ -0,0 +1,18 @@ +module.exports = { + reporter: function reporter(results) { + var len = results.length, + str = '', + file, error; + + results.forEach(function (result) { + file = result.file; + error = result.error; + str += file + ': line ' + error.line + ', col ' + + error.character + ', ' + error.reason + '\n'; + }); + + if (str) { + process.stdout.write(str + "\n" + len + ' error' + ((len === 1) ? '' : 's') + "\n"); + } + } +}; diff --git a/node_modules/jshint/lib/cli.js b/node_modules/jshint/lib/cli.js new file mode 100644 index 0000000..80a2f23 --- /dev/null +++ b/node_modules/jshint/lib/cli.js @@ -0,0 +1,135 @@ +var fs = require('fs'), + path = require('path'), + argsparser = require('argsparser'), + hint = require('./hint'); + +function _help() { + process.stdout.write(fs.readFileSync(__dirname + "/../HELP", "utf-8")); +} + +function _version() { + process.stdout.write(JSON.parse(fs.readFileSync(__dirname + "/../package.json", "utf-8")).version + "\n"); +} + +function _removeJsComments(str) { + str = str || ''; + str = str.replace(/\/\*[\s\S]*(?:\*\/)/g, ''); //everything between "/* */" + str = str.replace(/\/\/[^\n\r]*/g, ''); //everything after "//" + return str; +} + +function _loadAndParseConfig(filePath) { + return path.existsSync(filePath) ? + JSON.parse(_removeJsComments(fs.readFileSync(filePath, "utf-8"))) : {}; +} + +function _mergeConfigs(homerc, cwdrc) { + var homeConfig = _loadAndParseConfig(homerc), + cwdConfig = _loadAndParseConfig(cwdrc), + prop; + + for (prop in cwdConfig) { + if (typeof prop === 'string') { + if (prop === 'predef') { + homeConfig.predef = (homeConfig.predef || []).concat(cwdConfig.predef); + } else { + homeConfig[prop] = cwdConfig[prop]; + } + } + } + + return homeConfig; +} + +function _print(results) { + function exit() { + process.exit(results.length > 0 ? 1 : 0); + } + + // avoid stdout cutoff in node 0.4.x, also supports 0.5.x + // see https://github.com/joyent/node/issues/1669 + try { + if (!process.stdout.flush()) { + process.stdout.once("drain", exit); + } else { + exit(); + } + } catch (e) { + exit(); + } +} + +module.exports = { + interpret: function (args) { + var config, reporter, ignore, + options = argsparser.parse(args), + pathsToIgnore = path.join(process.cwd(), '.jshintignore'), + defaultConfig = path.join(process.env.HOME, '.jshintrc'), + projectConfig = path.join(process.cwd(), '.jshintrc'), + customConfig = options["--config"], + customReporter = options["--reporter"] ? path.resolve(process.cwd(), options["--reporter"]) : null, + targets = options.node; + + //could be on Windows which we are looking for an attribute ending in 'node.exe' + if (targets === undefined) { + (function () { + var arg; + + for (arg in options) { + if (path.basename(arg) === 'node.exe') { + targets = options[arg]; + break; + } + } + }()); + } + + targets = typeof targets === "string" ? null : targets.slice(1); + + + if (options["--version"]) { + _version(); + return; + } + + if (!targets || options["--help"]) { + _help(); + return; + } + + if (options["--jslint-reporter"]) { + customReporter = "./reporters/jslint_xml.js"; + } + + if (options["--show-non-errors"]) { + customReporter = "./reporters/non_error.js"; + } + + if (customConfig) { + config = _loadAndParseConfig(customConfig); + } else { + config = _mergeConfigs(defaultConfig, projectConfig); + } + + if (customReporter) { + try { + reporter = require(customReporter).reporter; + } catch (r) { + process.stdout.write("Error opening reporter file: " + customReporter); + process.stdout.write(r + "\n"); + process.exit(1); + } + } + + if (path.existsSync(pathsToIgnore)) { + ignore = fs.readFileSync(pathsToIgnore, "utf-8").split("\n").map(function (line) { + return line.trim(); + }).filter(function (line) { + return !!line; + }); + } + + _print(hint.hint(targets, config, reporter, ignore)); + } +}; + diff --git a/node_modules/jshint/lib/hint.js b/node_modules/jshint/lib/hint.js new file mode 100644 index 0000000..5e4861b --- /dev/null +++ b/node_modules/jshint/lib/hint.js @@ -0,0 +1,108 @@ +var fs = require('fs'), + minimatch = require('minimatch'), + path = require('path'), + jshint = require('./../packages/jshint/jshint.js'), + _reporter = require('./reporters/default').reporter, + _cache = { + directories: {} + }; + +function _lint(file, results, config, data) { + var buffer, + lintdata; + + try { + buffer = fs.readFileSync(file, 'utf-8'); + } catch (e) { + process.stdout.write("Error: Cant open: " + file); + process.stdout.write(e + '\n'); + } + + // Remove potential Unicode Byte Order Mark. + buffer = buffer.replace(/^\uFEFF/, ''); + + if (!jshint.JSHINT(buffer, config)) { + jshint.JSHINT.errors.forEach(function (error) { + if (error) { + results.push({file: file, error: error}); + } + }); + } + + lintdata = jshint.JSHINT.data(); + + if (lintdata) { + lintdata.file = file; + data.push(lintdata); + } +} + +function isDirectory(aPath) { + var isDir; + + try { + if (_cache.directories.hasOwnProperty(aPath)) { + isDir = _cache.directories[aPath]; + } else { + isDir = fs.statSync(aPath).isDirectory(); + _cache.directories[aPath] = isDir; + } + } catch (e) { + isDir = false; + } + + return isDir; +} + + +function _shouldIgnore(somePath, ignore) { + function isIgnored(p) { + var fnmatch = minimatch(somePath, p, {nocase: true}), + lsmatch = isDirectory(p) && p.match(/^[^\/]*\/?$/) && + somePath.match(new RegExp("^" + p + ".*")); + + return !!(fnmatch || lsmatch); + } + + return ignore.some(function (ignorePath) { + return isIgnored(ignorePath); + }); +} + +function _collect(filePath, files, ignore) { + if (ignore && _shouldIgnore(filePath, ignore)) { + return; + } + + if (fs.statSync(filePath).isDirectory()) { + fs.readdirSync(filePath).forEach(function (item) { + _collect(path.join(filePath, item), files, ignore); + }); + } else if (filePath.match(/\.js$/)) { + files.push(filePath); + } +} + +module.exports = { + hint: function (targets, config, reporter, ignore) { + var files = [], + results = [], + data = []; + + targets.forEach(function (target) { + _collect(target, files, ignore); + }); + + files.forEach(function (file) { + _lint(file, results, config, data); + }); + + _cache = { + directories: {} + }; + + (reporter || _reporter)(results, data); + + return results; + } +}; diff --git a/node_modules/jshint/lib/reporters/default.js b/node_modules/jshint/lib/reporters/default.js new file mode 100644 index 0000000..92f9902 --- /dev/null +++ b/node_modules/jshint/lib/reporters/default.js @@ -0,0 +1,18 @@ +module.exports = { + reporter: function (results, data) { + var len = results.length, + str = '', + file, error; + + results.forEach(function (result) { + file = result.file; + error = result.error; + str += file + ': line ' + error.line + ', col ' + + error.character + ', ' + error.reason + '\n'; + }); + + if (str) { + process.stdout.write(str + "\n" + len + ' error' + ((len === 1) ? '' : 's') + "\n"); + } + } +}; diff --git a/node_modules/jshint/lib/reporters/jslint_xml.js b/node_modules/jshint/lib/reporters/jslint_xml.js new file mode 100644 index 0000000..eca2327 --- /dev/null +++ b/node_modules/jshint/lib/reporters/jslint_xml.js @@ -0,0 +1,54 @@ +// Author: Vasili Sviridov +// http://github.com/vsviridov +module.exports = +{ + reporter: function (results) + { + "use strict"; + + var files = {}, + out = [], + pairs = { + "&": "&", + '"': """, + "'": "'", + "<": "<", + ">": ">" + }, + file, i, issue; + + function encode(s) { + for (var r in pairs) { + if (typeof(s) !== "undefined") { + s = s.replace(new RegExp(r, "g"), pairs[r]); + } + } + return s || ""; + } + + + results.forEach(function (result) { + result.file = result.file.replace(/^\.\//, ''); + if (!files[result.file]) { + files[result.file] = []; + } + files[result.file].push(result.error); + }); + + out.push(""); + out.push(""); + + for (file in files) { + out.push("\t"); + for (i = 0; i < files[file].length; i++) { + issue = files[file][i]; + out.push("\t\t"); + } + out.push("\t"); + } + + out.push(""); + + process.stdout.write(out.join("\n") + "\n"); + } +}; diff --git a/node_modules/jshint/lib/reporters/non_error.js b/node_modules/jshint/lib/reporters/non_error.js new file mode 100644 index 0000000..d8c3243 --- /dev/null +++ b/node_modules/jshint/lib/reporters/non_error.js @@ -0,0 +1,45 @@ +/*jshint node: true */ +module.exports = +{ + reporter: function (results, data, done) { + var len = results.length, + str = '', + file, error, globals, unuseds; + + results.forEach(function (result) { + file = result.file; + error = result.error; + str += file + ': line ' + error.line + ', col ' + + error.character + ', ' + error.reason + '\n'; + }); + + str += len > 0 ? ("\n" + len + ' error' + ((len === 1) ? '' : 's')) : ""; + + data.forEach(function (data) { + file = data.file; + globals = data.implieds; + unuseds = data.unused; + + if (globals || unuseds) { + str += '\n\n' + file + ' :\n'; + } + + if (globals) { + str += '\tImplied globals:\n'; + globals.forEach(function (global) { + str += '\t\t' + global.name + ': ' + global.line + '\n'; + }); + } + if (unuseds) { + str += '\tUnused Variables:\n\t\t'; + unuseds.forEach(function (unused) { + str += unused.name + '(' + unused.line + '), '; + }); + } + }); + + if (str) { + process.stdout.write(str + "\n"); + } + } +}; diff --git a/node_modules/jshint/package.json b/node_modules/jshint/package.json new file mode 100644 index 0000000..be075d6 --- /dev/null +++ b/node_modules/jshint/package.json @@ -0,0 +1,34 @@ +{ + "name": "jshint", + "version": "0.5.5", + "description": "A CLI for JSHint", + "homepage": "http://github.com/jshint/node-jshint", + "author": { + "name": "Brent Lintner", + "email": "brent.lintner@gmail.com", + "url": "http://github.com/brentlintner" + }, + "licenses": [{ + "type": "MIT", + "url": "http://www.opensource.org/licenses/mit-license.php" + }], + "bin": { "jshint": "./bin/hint" }, + "main": "packages/jshint/jshint", + "files": [ + "packages/jshint/README.markdown", + "packages/jshint/jshint.js", + "README.md", + "LICENSE", + "HELP", + "bin/hint", + "lib" + ], + "dependencies": { + "argsparser": ">=0.0.3", + "minimatch": ">=0.0.4" + }, + "devDependencies": { + "jasmine-node": "1.0.7" + }, + "preferGlobal" : true +} diff --git a/node_modules/jshint/packages/jshint/.gitignore b/node_modules/jshint/packages/jshint/.gitignore new file mode 100644 index 0000000..4199381 --- /dev/null +++ b/node_modules/jshint/packages/jshint/.gitignore @@ -0,0 +1 @@ +build/*.js diff --git a/node_modules/jshint/packages/jshint/CHANGELOG b/node_modules/jshint/packages/jshint/CHANGELOG new file mode 100644 index 0000000..695f0ad --- /dev/null +++ b/node_modules/jshint/packages/jshint/CHANGELOG @@ -0,0 +1,63 @@ +April 16, 2011 + * New edition: 2011-04-16 + + * Unit tests for all options and some core functions + * A number of small typo and message fixes + * JSHint is now a JavaScript/JSON parser only + (ADSafe, HTML, CSS related code was removed) + * JSHint now supports function-scoped options + * JSHint now supports both /*jshint and /*jslint + + * JSHint now supports shebangs (#!) + * Added support for typed array globals + * Allowed the use of variables/functions before definition. + (option 'latedef' to disallow) + * Fixed a bug with 'forin' option + * Fixed Rhino wrapper's CLI options support + * Fixed a bug with JSHint leaking internal variables + * Added option 'expr' to allow ExpressionStatement as valid Program + * Added an option 'prototypejs' to pre-define Prototype globals + * Added XPathResult et al. to the 'browser' option + * Added support for 'undefined' as a function parameter + * Option 'boss' has now precedence over 'eqeqeq' when it comes to '== null' + * Fixed a bug with JSHint parsing getters/setters as function statements + * Added an option 'mootools' to pre-define MooTools globals + * Added an option 'globalstrict' to allow the use of global strict mode + * Added HTMLElement to the browser environment + * Added support for the void operator + * Fixed a bug with 'new Array' + * Added option 'white' to check for trailing whitespaces + +March 01, 2011 + * New edition: 2011-03-02 + + * When library is used from Rhino, you can provide options via command line arguments + + * Added new HTML5 globals to the 'browser' option + * Tolerate == null when boss:true + * Tolerate undefined variables in the typeof and delete + * Tolerate undefined as a formal parameter + * Recognize new Array() as a valid expression + * Added support for explicit case statement fallthroughs (using special comments) + * Added third formal parameter to JSHINT for specifying pre-defined globals + + * New option 'asi' to tolerate the use of automatic semicolon insertion + * New option 'jquery' to assume jQuery environment + * New option 'couch' to assume CouchDB environment + +February 19, 2011 + * New edition: 2011-02-19 + + * Library can act as a Node.js module and a Rhino program + + * Tolerate single statements in if/for/while constructions ('curly' to disallow) + * Tolerate arguments.callee and arguments.caller ('noarg' to disallow) + * Tolerate empty blocks ('noempty' to disallow) + * Tolerate the use of `new` for side-effects ('nonew' to disallow) + * Less strict styling check by default ('white' to revert) + + * New option 'boss' to tolerate assignments inside if/for/while + * New option 'node' to assume Node environment + +January 19, 2011 + * Forked JSLint from the edition 2010-12-16 \ No newline at end of file diff --git a/node_modules/jshint/packages/jshint/Makefile b/node_modules/jshint/packages/jshint/Makefile new file mode 100644 index 0000000..512ca3b --- /dev/null +++ b/node_modules/jshint/packages/jshint/Makefile @@ -0,0 +1,16 @@ +build_dir: + @mkdir -p "build" + +rhino: build_dir + @echo "Building JSHint for Rhino" + @cat "jshint.js" > "build/jshint-rhino.js" && \ + cat "env/rhino.js" >> "build/jshint-rhino.js" && \ + echo "Done" + +test: + @echo "Running all tests" + @expresso tests/*.js + +clean: + @echo "Cleaning" + @rm -f build/*.js && echo "Done" diff --git a/node_modules/jshint/packages/jshint/README.markdown b/node_modules/jshint/packages/jshint/README.markdown new file mode 100755 index 0000000..d8e6713 --- /dev/null +++ b/node_modules/jshint/packages/jshint/README.markdown @@ -0,0 +1,71 @@ +JSHint, A Static Code Analysis Tool for JavaScript +================================================== + +JSHint is a community-driven tool to detect errors and potential problems in +JavaScript code and to enforce your team's coding conventions. + +**IMPORTANT**: + + * This README is for people who are thinking about contributing to JSHint. For general usage + please refer to [our website](http://jshint.com/). + * If you want to report a bug about the website, please go to the + [jshint/site](https://github.com/jshint/site/) repository. + * If you want to report a bug or contribute to our NPM package, please go to the + [jshint/node-jshint](https://github.com/jshint/node-jshint/) repository. + +Reporting a bug +--------------- + +To report a bug simply create a [new GitHub Issue](https://github.com/jshint/jshint/issues/new) and +describe your problem or suggestion. We welcome all kind of feedback regarding JSHint including but +not limited to: + + * When JSHint doesn't work as expected + * When JSHint complains about valid JavaScript code that works in all browsers + * When you simply want a new option or feature + +Please, before reporting a bug look around to see if there are any open or closed tickets that +cover your issue. And remember the wisdom: pull request > bug report > tweet. + +Submitting patches +------------------ + +The best way to make sure your issue is addressed is to submit a patch. GitHub provides a very +nice interface--pull requests--for that but we accept patches through all mediums: email, issue +comment, tweet with a link to a snippet, etc. + +Before submitting a patch make sure that you comply to our style. We don't have specific style +guide so just look around the code you are changing. + +Also, make sure that you write tests for new features and make sure that all tests pass before +submitting a patch. Patches that break the build will be rejected. + +**FEATURE FREEZE**: Please note that we currently have a feature freeze on new environments and +styling options. The only patches we accept at this time are for bug fixes. + +Tests +----- + +To run tests you will need to install [node.js](http://nodejs.org/) and +expresso. You can install the latter with npm: + + npm install expresso + +After that, running tests is as easy as: + + expresso tests/*.js + +Attribution +----------- + +Maintainer: [Anton Kovalyov](http://anton.kovalyov.net/) ([@valueof](http://twitter.com/valueof)) + +Distinguished Contributors: + + * [Wolfgang Kluge](http://klugesoftware.de/) ([blog](http://gehirnwindung.de/)) + * [Josh Perez](http://www.goatslacker.com/) + +Thank you! +---------- + +We really appreciate all kind of feedback and contributions. Thanks for using and supporing JSHint! \ No newline at end of file diff --git a/node_modules/jshint/packages/jshint/env/jsc.js b/node_modules/jshint/packages/jshint/env/jsc.js new file mode 100644 index 0000000..f28937d --- /dev/null +++ b/node_modules/jshint/packages/jshint/env/jsc.js @@ -0,0 +1,57 @@ +/*jshint boss:true, evil:true */ + +// usage: +// jsc ${env_home}/jsc.js -- ${file} "$(cat ${file})" "{option1:true,option2:false} ${env_home}" +var env_home = ''; +if (arguments.length > 3) { + env_home = arguments[3].toString().replace(/\/env$/, '/'); +} +load(env_home + "jshint.js"); + +if (typeof(JSHINT) === 'undefined') { + print('jshint: Could not load jshint.js, tried "' + env_home + 'jshint.js".'); + quit(); +} + +(function(args){ + var home = args[3], + name = args[0], + input = args[1], + opts = (function(arg){ + var opts = {}; + var item; + + switch (arg) { + case undefined: + case '': + return opts; + default: + arg = arg.split(','); + for (var i = 0, ii = arg.length; i < ii; i++) { + item = arg[i].split(':'); + opts[item[0]] = eval(item[1]); + } + return opts; + } + })(args[2]); + + if (!name) { + print('jshint: No file name was provided.'); + quit(); + } + + if (!input) { + print('jshint: ' + name + ' contents were not provided to jshint.'); + quit(); + } + + if (!JSHINT(input, opts)) { + for (var i = 0, err; err = JSHINT.errors[i]; i++) { + print(err.reason + ' (line: ' + err.line + ', character: ' + err.character + ')'); + print('> ' + (err.evidence || '').replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); + print(''); + } + } + + quit(); +})(arguments); \ No newline at end of file diff --git a/node_modules/jshint/packages/jshint/env/jsc.sh b/node_modules/jshint/packages/jshint/env/jsc.sh new file mode 100755 index 0000000..6d6652b --- /dev/null +++ b/node_modules/jshint/packages/jshint/env/jsc.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# usage (run from any directory) : +# env/jsc.sh /path/to/script.js +# or with jshint options: +# env/jsc.sh /path/to/script.js "{option1:true,option2:false,option3:25}" + +alias jsc="/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc" +FILE="${1}" +OPTS="${2}" + +FILE_CONTENT=$(cat "${FILE}") + +if [ -L $BASH_SOURCE ]; then + ENV_HOME="$( cd "$( dirname "$(readlink "$BASH_SOURCE")" )" && pwd )" +else + ENV_HOME="$( cd "$( dirname "$BASH_SOURCE" )" && pwd )" +fi + +LINT_RESULT=$(jsc "${ENV_HOME}"/jsc.js -- "${FILE}" "${FILE_CONTENT}" "${OPTS}" "${ENV_HOME}") +ERRORS=$(echo ${LINT_RESULT} | egrep [^\s] -c) + +if [[ ${ERRORS} -ne 0 ]]; then + echo "[jshint] Error(s) in ${FILE}:" + printf "%s\n" "${LINT_RESULT}" +else + echo "[jshint] ${FILE} passed!" +fi + +exit $((0 + ${ERRORS})) \ No newline at end of file diff --git a/node_modules/jshint/packages/jshint/env/rhino.js b/node_modules/jshint/packages/jshint/env/rhino.js new file mode 100644 index 0000000..f0529cd --- /dev/null +++ b/node_modules/jshint/packages/jshint/env/rhino.js @@ -0,0 +1,75 @@ +/*jshint boss: true, rhino: true */ +/*globals JSHINT*/ + +(function (args) { + var filenames = [], + optstr, // arg1=val1,arg2=val2,... + predef, // global1=override,global2,global3,... + opts = { rhino: true }, + retval = 0; + + args.forEach(function (arg) { + if (arg.indexOf("=") > -1) { + //first time it's the options + if (!optstr) { + optstr = arg; + } else if (!predef) { + predef = arg; + } + } else { + filenames.push(arg); + } + }); + + if (filenames.length === 0) { + print('Usage: jshint.js file.js'); + quit(1); + } + + if (optstr) { + optstr.split(',').forEach(function (arg) { + var o = arg.split('='); + opts[o[0]] = (function (ov) { + switch (ov) { + case 'true': + return true; + case 'false': + return false; + default: + return ov; + } + }(o[1])); + }); + } + + if (predef) { + opts.predef = {}; + predef.split(',').forEach(function (arg) { + var global = arg.split('='); + opts.predef[global[0]] = (function (override) { + return (override === 'false') ? false : true; + }(global[1])); + }); + } + + filenames.forEach(function (name) { + + var input = readFile(name); + + if (!input) { + print('jshint: Couldn\'t open file ' + name); + quit(1); + } + + if (!JSHINT(input, opts)) { + for (var i = 0, err; err = JSHINT.errors[i]; i += 1) { + print(err.reason + ' (' + name + ':' + err.line + ':' + err.character + ')'); + print('> ' + (err.evidence || '').replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1")); + print(''); + } + retval = 1; + } + }); + + quit(retval); +}(arguments)); diff --git a/node_modules/jshint/packages/jshint/env/wsh.js b/node_modules/jshint/packages/jshint/env/wsh.js new file mode 100644 index 0000000..e6c0054 --- /dev/null +++ b/node_modules/jshint/packages/jshint/env/wsh.js @@ -0,0 +1,168 @@ +/*jshint evil: true, shadow: true, wsh: true */ +/*global JSHINT: false */ + +(function() { + function readFile(path) { + try { + return new ActiveXObject("Scripting.FileSystemObject").OpenTextFile(path, 1).ReadAll(); + } catch (ex) { + return null; + } + } + + var formatters = { + errors: function(errors, lines) { + for (var i = 0; i < errors.length; i++) { + var error = errors[i]; + + if (!error) continue; + + if (i) lines.push(""); + + lines.push("Line " + error.line + " character " + error.character + ": " + error.reason); + + if (error.evidence) lines.push(" " + error.evidence.replace(/^\s*((?:[\S\s]*\S)?)\s*$/, "$1")); + } + }, + + implieds: function(implieds, lines) { + lines.push("Implied globals:"); + + var globals = {}; + + for (var i = 0; i < implieds.length; i++) { + var item = implieds[i]; + + if (!(item.name in globals)) globals[item.name] = []; + + globals[item.name].push(item.line); + } + + for (var name in globals) { + lines.push(" " + name + ": " + globals[name].join(", ")); + } + }, + + unused: function(unused, lines) { + lines.push("Unused variables:"); + + var func, names = {}; + + for (var i = 0; i < unused.length; i++) { + var item = unused[i]; + + func = item["function"]; + + if (!(func in names)) names[func] = []; + + names[func].push(item.name + " (" + item.line + ")"); + } + + for (func in names) { + lines.push(" " + func + ": " + names[func].join(", ")); + } + } + }; + + var scriptName = WScript.ScriptName; + var scriptPath = WScript.ScriptFullName; + + scriptPath = scriptPath.substr(0, scriptPath.length - scriptName.length); + + // load JSHint if the two scripts have not been concatenated + if (typeof JSHINT === "undefined") { + eval(readFile(scriptPath + "..\\jshint.js")); + + if (typeof JSHINT === "undefined") { + WScript.StdOut.WriteLine("ERROR: Could not find 'jshint.js'."); + + WScript.Quit(-2); + } + } + + var globals = {}; + var options = {}; + var named = WScript.Arguments.Named; + var unnamed = WScript.Arguments.Unnamed; + + if (unnamed.length !== 1) { + WScript.StdOut.WriteLine(" usage: cscript " + scriptName + " [options]