Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

add jshint

  • Loading branch information...
commit 6a62f56b2ca9480078b982ca8f5fdfcf843a7255 1 parent 00f3167
@russellhaering russellhaering authored
Showing with 25,608 additions and 0 deletions.
  1. +15 −0 jshint.json
  2. +3 −0  lint.sh
  3. +1 −0  node_modules/.bin/jshint
  4. +3 −0  node_modules/jshint/.gitignore
  5. +3 −0  node_modules/jshint/.gitmodules
  6. +3 −0  node_modules/jshint/.jshintignore
  7. +40 −0 node_modules/jshint/.jshintrc
  8. +9 −0 node_modules/jshint/HELP
  9. +4 −0 node_modules/jshint/LICENSE
  10. +70 −0 node_modules/jshint/README.md
  11. +2 −0  node_modules/jshint/bin/hint
  12. +73 −0 node_modules/jshint/example/config.json
  13. +18 −0 node_modules/jshint/example/reporter.js
  14. +135 −0 node_modules/jshint/lib/cli.js
  15. +108 −0 node_modules/jshint/lib/hint.js
  16. +18 −0 node_modules/jshint/lib/reporters/default.js
  17. +54 −0 node_modules/jshint/lib/reporters/jslint_xml.js
  18. +45 −0 node_modules/jshint/lib/reporters/non_error.js
  19. +34 −0 node_modules/jshint/package.json
  20. +1 −0  node_modules/jshint/packages/jshint/.gitignore
  21. +63 −0 node_modules/jshint/packages/jshint/CHANGELOG
  22. +16 −0 node_modules/jshint/packages/jshint/Makefile
  23. +71 −0 node_modules/jshint/packages/jshint/README.markdown
  24. +57 −0 node_modules/jshint/packages/jshint/env/jsc.js
  25. +29 −0 node_modules/jshint/packages/jshint/env/jsc.sh
  26. +75 −0 node_modules/jshint/packages/jshint/env/rhino.js
  27. +168 −0 node_modules/jshint/packages/jshint/env/wsh.js
  28. +4,311 −0 node_modules/jshint/packages/jshint/jshint.js
  29. +401 −0 node_modules/jshint/packages/jshint/tests/core.js
  30. +514 −0 node_modules/jshint/packages/jshint/tests/envs.js
  31. +28 −0 node_modules/jshint/packages/jshint/tests/fixtures/asi.js
  32. +1,158 −0 node_modules/jshint/packages/jshint/tests/fixtures/backbone.js
  33. +12 −0 node_modules/jshint/packages/jshint/tests/fixtures/boss.js
  34. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/caseExpressions.js
  35. +72 −0 node_modules/jshint/packages/jshint/tests/fixtures/const.js
  36. +8 −0 node_modules/jshint/packages/jshint/tests/fixtures/curly.js
  37. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/curly2.js
  38. +23 −0 node_modules/jshint/packages/jshint/tests/fixtures/emptystmt.js
  39. +10 −0 node_modules/jshint/packages/jshint/tests/fixtures/eqeqeq.js
  40. +15 −0 node_modules/jshint/packages/jshint/tests/fixtures/es5.funcexpr.js
  41. +38 −0 node_modules/jshint/packages/jshint/tests/fixtures/es5.js
  42. +15 −0 node_modules/jshint/packages/jshint/tests/fixtures/forin.js
  43. +8 −0 node_modules/jshint/packages/jshint/tests/fixtures/functionScopedOptions.js
  44. +15 −0 node_modules/jshint/packages/jshint/tests/fixtures/immed.js
  45. +8 −0 node_modules/jshint/packages/jshint/tests/fixtures/indent.js
  46. +9,304 −0 node_modules/jshint/packages/jshint/tests/fixtures/jquery-1.7.js
  47. +9 −0 node_modules/jshint/packages/jshint/tests/fixtures/jslintOptions.js
  48. +6 −0 node_modules/jshint/packages/jshint/tests/fixtures/lastsemic.js
  49. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/latedef.js
  50. +46 −0 node_modules/jshint/packages/jshint/tests/fixtures/latedefundef.js
  51. +19 −0 node_modules/jshint/packages/jshint/tests/fixtures/laxbreak.js
  52. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/loopfunc.js
  53. +3 −0  node_modules/jshint/packages/jshint/tests/fixtures/maxlen.js
  54. +8 −0 node_modules/jshint/packages/jshint/tests/fixtures/missingspaces.js
  55. +5 −0 node_modules/jshint/packages/jshint/tests/fixtures/newcap.js
  56. +7 −0 node_modules/jshint/packages/jshint/tests/fixtures/noarg.js
  57. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/onevar.js
  58. +37 −0 node_modules/jshint/packages/jshint/tests/fixtures/protoiterator.js
  59. +6,082 −0 node_modules/jshint/packages/jshint/tests/fixtures/prototype-17.js
  60. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/redef.js
  61. +40 −0 node_modules/jshint/packages/jshint/tests/fixtures/return.js
  62. +43 −0 node_modules/jshint/packages/jshint/tests/fixtures/scope.js
  63. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/scripturl.js
  64. +7 −0 node_modules/jshint/packages/jshint/tests/fixtures/smarttabs.js
  65. +59 −0 node_modules/jshint/packages/jshint/tests/fixtures/strict_incorrect.js
  66. +17 −0 node_modules/jshint/packages/jshint/tests/fixtures/strict_this.js
  67. +18 −0 node_modules/jshint/packages/jshint/tests/fixtures/strict_this2.js
  68. +9 −0 node_modules/jshint/packages/jshint/tests/fixtures/strict_violations.js
  69. +16 −0 node_modules/jshint/packages/jshint/tests/fixtures/strings.js
  70. +11 −0 node_modules/jshint/packages/jshint/tests/fixtures/supernew.js
  71. +40 −0 node_modules/jshint/packages/jshint/tests/fixtures/switchFallThrough.js
  72. +24 −0 node_modules/jshint/packages/jshint/tests/fixtures/trycatch.js
  73. +10 −0 node_modules/jshint/packages/jshint/tests/fixtures/undef.js
  74. +6 −0 node_modules/jshint/packages/jshint/tests/fixtures/undefstrict.js
  75. +66 −0 node_modules/jshint/packages/jshint/tests/fixtures/white.js
  76. +1,007 −0 node_modules/jshint/packages/jshint/tests/options.js
  77. +318 −0 node_modules/jshint/packages/jshint/tests/parser.js
  78. +147 −0 node_modules/jshint/packages/jshint/tests/testhelper
  79. +20 −0 node_modules/jshint/test/system/genfiles
  80. +34 −0 node_modules/jshint/test/system/perf.js
  81. +185 −0 node_modules/jshint/test/unit/cli.js
  82. +174 −0 node_modules/jshint/test/unit/hint.js
View
15 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
+}
+
View
3  lint.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+./node_modules/.bin/jshint $(find ./lib -type f -name "*.js") --config jshint.json
View
1  node_modules/.bin/jshint
View
3  node_modules/jshint/.gitignore
@@ -0,0 +1,3 @@
+tags
+node_modules
+test/system/.files
View
3  node_modules/jshint/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "packages/jshint"]
+ path = packages/jshint
+ url = git://github.com/jshint/jshint.git
View
3  node_modules/jshint/.jshintignore
@@ -0,0 +1,3 @@
+node_modules
+packages
+.git
View
40 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
+}
View
9 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
View
4 node_modules/jshint/LICENSE
@@ -0,0 +1,4 @@
+** Licensed Under **
+
+ The MIT License
+ http://www.opensource.org/licenses/mit-license.php
View
70 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
View
2  node_modules/jshint/bin/hint
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+require('./../lib/cli').interpret(process.argv);
View
73 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
+}
+
View
18 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");
+ }
+ }
+};
View
135 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));
+ }
+};
+
View
108 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;
+ }
+};
View
18 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");
+ }
+ }
+};
View
54 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 = {
+ "&": "&",
+ '"': """,
+ "'": "'",
+ "<": "&lt;",
+ ">": "&gt;"
+ },
+ 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("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+ out.push("<jslint>");
+
+ for (file in files) {
+ out.push("\t<file name=\"" + file + "\">");
+ for (i = 0; i < files[file].length; i++) {
+ issue = files[file][i];
+ out.push("\t\t<issue line=\"" + issue.line + "\" char=\"" + issue.character + "\" reason=\"" + encode(issue.reason) + "\" evidence=\"" + encode(issue.evidence) + "\" />");
+ }
+ out.push("\t</file>");
+ }
+
+ out.push("</jslint>");
+
+ process.stdout.write(out.join("\n") + "\n");
+ }
+};
View
45 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");
+ }
+ }
+};
View
34 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
+}
View
1  node_modules/jshint/packages/jshint/.gitignore
@@ -0,0 +1 @@
+build/*.js
View
63 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(<expr>) 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
View
16 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"
View
71 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!
View
57 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);
View
29 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}))
View
75 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));
View
168 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] <script>");
+ WScript.StdOut.WriteLine("");
+ WScript.StdOut.WriteLine("Scans the specified script with JSHint and reports any errors encountered. If");
+ WScript.StdOut.WriteLine("the script name is \"-\", it will be read from standard input instead.");
+ WScript.StdOut.WriteLine("");
+ WScript.StdOut.WriteLine("JSHint configuration options can be passed in via optional, Windows-style");
+ WScript.StdOut.WriteLine("arguments. For example:");
+ WScript.StdOut.WriteLine(" cscript " + scriptName + " /jquery:true myscript.js");
+ WScript.StdOut.WriteLine(" cscript " + scriptName + " /global:QUnit:false,_:false,foo:true foo.js");
+
+ WScript.Quit(-1);
+ }
+
+ var script = unnamed(0);
+
+ if (script === "-") {
+ try {
+ script = WScript.StdIn.ReadAll();
+ } catch (ex) {
+ script = null;
+ }
+ } else {
+ script = readFile(script);
+ }
+
+ if (script === null) {
+ WScript.StdOut.WriteLine("ERROR: Could not read target script.");
+
+ WScript.Quit(2);
+ }
+
+ for (var etor = new Enumerator(named); !etor.atEnd(); etor.moveNext()) {
+ var option = etor.item();
+ var value = named(option);
+
+ if (option === "global") {
+ value = value.split(",");
+
+ for (var i = 0; i < value.length; i++) {
+ var name = value[i].split(":");
+
+ if (name.length === 1 || name[1] === "false") {
+ globals[name[0]] = false;
+ } else if (name[1] === "true") {
+ globals[name[0]] = true;
+ } else {
+ WScript.StdOut.WriteLine("Unrecognized value for global: " + name[0]);
+ WScript.StdOut.WriteLine("Must be \"true\", \"false\", or omitted.");
+
+ WScript.Quit(-1);
+ }
+ }
+ } else {
+ options[option] = value === "true" ? true : value === "false" ? false : value;
+ }
+ }
+
+ JSHINT(script, options, globals);
+
+ var data = JSHINT.data();
+ var lines = [];
+
+ for (var formatter in formatters) {
+ if (data[formatter]) {
+ if (lines.length) lines.push("");
+
+ formatters[formatter](data[formatter], lines);
+ }
+ }
+
+ if (lines.length) {
+ for (var i = 0; i < lines.length; i++) {
+ WScript.StdOut.WriteLine(lines[i]);
+ }
+
+ WScript.Quit(1);
+ } else {
+ WScript.Quit(0);
+ }
+}());
View
4,311 node_modules/jshint/packages/jshint/jshint.js
4,311 additions, 0 deletions not shown
View
401 node_modules/jshint/packages/jshint/tests/core.js
@@ -0,0 +1,401 @@
+/*jshint boss: true, laxbreak: true, node: true, devel: true */
+
+var JSHINT = require('../jshint.js').JSHINT,
+ assert = require('assert'),
+ fs = require('fs'),
+ TestRun = require("./testhelper").setup.testRun;
+
+/** JSHint must pass its own check */
+exports.checkJSHint = function () {
+ var res = JSHINT(fs.readFileSync(__dirname + "/../jshint.js", "utf8"), {
+ bitwise: true,
+ eqeqeq: true,
+ forin: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ noempty: true,
+ nonew: true,
+ plusplus: true,
+ regexp: true,
+ undef: true,
+ strict: true,
+ trailing: true,
+ white: true
+ });
+
+ if (!res) {
+ console.log("file: jshint.js");
+ console.log(JSHINT.errors);
+ }
+
+ assert.ok(res);
+ assert.isUndefined(JSHINT.data().implieds);
+};
+
+/** Rhino wrapper must pass JSHint check */
+exports.checkRhino = function () {
+ var src = fs.readFileSync(__dirname + "/../env/rhino.js", "utf8");
+ TestRun("jshint-rhino").test(src, {
+ bitwise: true,
+ eqeqeq: true,
+ forin: true,
+ immed: true,
+ latedef: true,
+ newcap: true,
+ noarg: true,
+ noempty: true,
+ nonew: true,
+ plusplus: true,
+ regexp: true,
+ undef: true,
+ strict: false,
+ trailing: true,
+ white: true
+ });
+};
+
+/* JavaScriptCore wrapper must pass JSHint check */
+exports.checkJSC = function () {
+ var src = fs.readFileSync(__dirname + "/../env/jsc.js", "utf8");
+ TestRun().test(src);
+};
+
+/** All test files must pass JSHint check */
+exports.checkTestFiles = function () {
+ var files = fs.readdirSync(__dirname + '/../tests/').filter(function (e) {
+ return e.length > 2 && e.substr(e.length - 3, 3) === '.js';
+ });
+
+ for (var i = 0, name; name = files[i]; i += 1) {
+ var src = fs.readFileSync(__dirname + '/../tests/' + name, 'utf8'),
+ res = JSHINT(src, {
+ bitwise: true,
+ eqeqeq: true,
+ forin: true,
+ immed: true,
+ latedef: true,
+ newcap: false,
+ noarg: true,
+ noempty: true,
+ nonew: true,
+ plusplus: true,
+ regexp: true,
+ undef: true,
+ strict: false,
+ trailing: true,
+ white: true
+ });
+
+ if (!res) {
+ console.log("file: " + name);
+ console.log(JSHINT.errors);
+ }
+
+ assert.ok(res);
+ assert.isUndefined(JSHINT.data().implieds);
+ }
+};
+
+/**
+ * JSHint allows you to specify custom globals as a parameter to the JSHINT
+ * function so it is not necessary to spam code with jshint-related comments
+ */
+exports.testCustomGlobals = function () {
+ var code = '(function () { return [ fooGlobal, barGlobal ]; }());',
+ custom = { fooGlobal: false, barGlobal: false };
+
+ assert.ok(JSHINT(code, {}, custom));
+
+ var report = JSHINT.data();
+ assert.isUndefined(report.implieds);
+ assert.eql(report.globals.length, 2);
+
+ var dict = {};
+ for (var i = 0, g; g = report.globals[i]; i += 1)
+ dict[g] = true;
+
+ for (i = 0, g = null; g = custom[i]; i += 1)
+ assert.ok(g in dict);
+};
+
+/** Test that JSHint recognizes `new Array(<expr>)` as a valid expression */
+exports.testNewArray = function () {
+ var code = 'new Array(1);',
+ code1 = 'new Array(v + 1);',
+ code2 = 'new Array("hello", "there", "chaps");';
+
+ TestRun().test(code);
+ TestRun().test(code1);
+ TestRun().test(code2);
+
+ TestRun()
+ .addError(1, "Use the array literal notation [].")
+ .test('new Array();');
+};
+
+/**
+ * Test that JSHint allows `undefined` to be a function parameter.
+ * It is a common pattern to protect against the case when somebody
+ * overwrites undefined. It also helps with minification.
+ *
+ * More info: https://gist.github.com/315916
+ */
+exports.testUndefinedAsParam = function () {
+ var code = '(function (undefined) {}());',
+ code1 = 'var undefined = 1;';
+
+ TestRun().test(code);
+ // But it must never tolerate reassigning of undefined
+ TestRun()
+ .addError(1, "Expected an identifier and instead saw 'undefined' (a reserved word).")
+ .test(code1);
+};
+
+/** Tests that JSHint accepts new line after a dot (.) operator */
+exports.newLineAfterDot = function () {
+ TestRun().test([ "chain().chain().", "chain();" ]);
+};
+
+/**
+ * JSHint does not tolerate deleting variables.
+ * More info: http://perfectionkills.com/understanding-delete/
+ */
+exports.noDelete = function () {
+ TestRun()
+ .addError(1, 'Variables should not be deleted.')
+ .test('delete NullReference;');
+};
+
+/**
+ * JSHint allows case statement fall through only when it is made explicit
+ * using special comments.
+ */
+exports.switchFallThrough = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/switchFallThrough.js', 'utf8');
+ TestRun()
+ .addError(3, "Expected a 'break' statement before 'case'.")
+ .addError(18, "Expected a 'break' statement before 'default'.")
+ .addError(36, "Unexpected ':'.")
+ .test(src);
+};
+
+exports.testVoid = function () {
+ var code = [
+ "void(0);"
+ , "void 0;"
+ , "var a = void(1);"
+ ];
+ TestRun().test(code);
+};
+
+exports.testMissingSpaces = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/missingspaces.js', 'utf8');
+ TestRun()
+ .addError(1, "Missing space after 'function'.", { character: 17 })
+ .addError(2, "Missing space after 'b'.", { character: 6 })
+ .addError(2, "Missing space after '='.", { character: 7 })
+ .addError(2, "Missing space after ')'.", { character: 18 })
+ .addError(3, "Missing space after 'd'.", { character: 6 })
+ .addError(4, "Missing space after ')'.", { character: 13 })
+ .addError(5, "Missing space after '1'.", { character: 13 })
+ .addError(7, "Missing space after '2'.", { character: 10 })
+ .addError(7, "Missing space after '+'.", { character: 11 })
+ .addError(8, "Missing space after '/'.", { character: 14 })
+ .addError(8, "Missing space after '+'.", { character: 15 })
+ .addError(8, "Missing space after 'uid'.", { character: 20 })
+ .addError(8, "Missing space after '+'.", { character: 21 })
+ .addError(8, "Missing space after '/likes?access_token='.", { character: 43 })
+ .addError(8, "Missing space after '+'.", { character: 44 })
+ .test(src, { white: true });
+};
+
+exports.functionScopedOptions = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/functionScopedOptions.js', 'utf8');
+ TestRun()
+ .addError(1, "eval is evil.")
+ .addError(8, "eval is evil.")
+ .test(src);
+};
+
+/** JSHint should not only read jshint, but also jslint options */
+exports.jslintOptions = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/jslintOptions.js', 'utf8');
+ TestRun().test(src);
+};
+
+exports.caseExpressions = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/caseExpressions.js', 'utf8');
+ TestRun()
+ .addError(2, "This 'switch' should be an 'if'.")
+ .test(src);
+};
+
+exports.returnStatement = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/return.js', 'utf8');
+
+ TestRun()
+ .addError(3, "Did you mean to return a conditional instead of an assignment?")
+ .addError(38, "Line breaking error 'return'.")
+ .test(src, { maxerr: 2 });
+};
+
+exports.globalDeclarations = function () {
+ var src = 'exports = module.exports = function () {};';
+
+ // Test should pass
+ TestRun().test(src, { node: true }, { exports: true });
+
+ // Test should pass as well
+ src = [
+ '/*jshint node:true */',
+ '/*global exports:true */',
+ 'exports = module.exports = function () {};'
+ ];
+
+ TestRun().test(src.join('\n'));
+};
+
+exports.testJQuery = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/jquery-1.7.js', 'utf8');
+
+ TestRun()
+ .addError(2818, "Expected an assignment or function call and instead saw an expression.")
+ .addError(2822, "Expected an assignment or function call and instead saw an expression.")
+ .addError(4560, "Expected an assignment or function call and instead saw an expression.")
+ .addError(4702, "Mixed spaces and tabs.")
+ .addError(4712, "Expected a 'break' statement before 'case'.")
+ .addError(4715, "Mixed spaces and tabs.")
+ .addError(4843, "Expected an assignment or function call and instead saw an expression.")
+ .addError(6912, "Mixed spaces and tabs.")
+ .addError(6913, "Mixed spaces and tabs.")
+ .addError(6914, "Mixed spaces and tabs.")
+ .addError(6915, "Mixed spaces and tabs.")
+ .addError(6916, "Mixed spaces and tabs.")
+ .addError(6917, "Mixed spaces and tabs.")
+ .addError(6918, "Mixed spaces and tabs.")
+ .addError(6919, "Mixed spaces and tabs.")
+ .addError(6923, "Mixed spaces and tabs.")
+ .addError(6924, "Mixed spaces and tabs.")
+ .addError(6925, "Mixed spaces and tabs.")
+ .addError(6926, "Mixed spaces and tabs.")
+ .addError(8086, "Mixed spaces and tabs.")
+ .addError(8087, "Mixed spaces and tabs.")
+ .addError(8088, "Mixed spaces and tabs.")
+ .addError(8089, "Mixed spaces and tabs.")
+ .addError(8090, "Mixed spaces and tabs.")
+ .addError(9209, "Mixed spaces and tabs.")
+ .test(src);
+};
+
+exports.testPrototype = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/prototype-17.js', 'utf8');
+
+ TestRun()
+ .addError(22, "Missing semicolon.")
+ .addError(94, "Unnecessary semicolon.")
+ .addError(110, "Missing '()' invoking a constructor.")
+ .addError(253, "'i' is already defined.")
+ .addError(253, "'length' is already defined.")
+ .addError(260, "'i' is already defined.")
+ .addError(260, "'length' is already defined.")
+ .addError(261, "'key' is already defined.")
+ .addError(261, "'str' is already defined.")
+ .addError(319, "'isArray' is a function.")
+ .addError(392, "Missing semicolon.")
+ .addError(400, "Missing semicolon.")
+ .addError(409, "Missing semicolon.")
+ .addError(430, "Missing semicolon.")
+ .addError(451, "Missing semicolon.")
+ .addError(482, "Unescaped '^'.")
+ .addError(482, "Unescaped '['.")
+ .addError(563, "Missing semicolon.")
+ .addError(563, "Expected an identifier and instead saw ','.")
+ .addError(563, "Missing semicolon.")
+ .addError(633, "Use '!==' to compare with 'undefined'.")
+ .addError(737, "Use '===' to compare with ''.")
+ .addError(741, "Wrap the /regexp/ literal in parens to disambiguate the slash operator.")
+ .addError(799, "Unescaped '['.")
+ .addError(805, "Unescaped ']'.")
+ .addError(807, "Use '===' to compare with ''.")
+ .addError(1137, "Use '===' to compare with '0'.")
+ .addError(1215, "Missing semicolon.")
+ .addError(1224, "Unnecessary semicolon.")
+ .addError(1916, "Missing semicolon.")
+ .addError(2034, "Missing semicolon.")
+ .addError(2210, "Missing semicolon.")
+ .addError(2210, "Expected an identifier and instead saw ','.")
+ .addError(2210, "Missing semicolon.")
+ .addError(2222, "Missing semicolon.")
+ .addError(2222, "Expected an identifier and instead saw ','.")
+ .addError(2222, "Missing semicolon.")
+ .addError(2345, "Missing semicolon.")
+ .addError(2345, "Expected an identifier and instead saw ','.")
+ .addError(2345, "Missing semicolon.")
+ .addError(2662, "Missing semicolon.")
+ .addError(2735, "Missing semicolon.")
+ .addError(2924, "Missing semicolon.")
+ .addError(2987, "'tagName' used out of scope.")
+ .addError(2989, "'tagName' used out of scope.")
+ .addError(2989, "'tagName' used out of scope.")
+ .addError(2990, "'tagName' used out of scope.")
+ .addError(3844, "'positionedOffset' is a function.")
+ .addError(3860, "'cumulativeOffset' is a function.")
+ .addError(3974, "Unescaped '['.")
+ .test(src, {
+ sub: true,
+ lastsemic: true,
+ loopfunc: true,
+ evil: true,
+ eqnull: true,
+ laxbreak: true,
+ boss: true,
+ expr: true
+ });
+};
+
+exports.backbone = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/backbone.js', 'utf8');
+
+ TestRun()
+ .addError(669, "Unescaped '['.")
+ .addError(669, "Unescaped '^'.")
+ .addError(685, "Missing '()' invoking a constructor.")
+ .addError(764, "Use '===' to compare with '0'.")
+ .addError(859, "Use '!==' to compare with '0'.")
+ .test(src, { expr: true, eqnull: true, boss: true, regexdash: true });
+};
+
+exports.argsInCatchReused = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/trycatch.js', 'utf8');
+ TestRun()
+ .addError(6, "'e' is already defined.")
+ .addError(12, "Do not assign to the exception parameter.")
+ .addError(23, "'e' is not defined.")
+ .test(src, { undef: true });
+};
+
+exports.testRawOnError = function () {
+ JSHINT(';', { maxerr: 1 });
+ assert.equal(JSHINT.errors[0].raw, 'Unnecessary semicolon.');
+ assert.equal(JSHINT.errors[1].raw, 'Too many errors.');
+ assert.equal(JSHINT.errors[2], null);
+};
+
+exports.yesEmptyStmt = function () {
+ var src = fs.readFileSync(__dirname + '/fixtures/emptystmt.js', 'utf8');
+
+ TestRun()
+ .addError(1, "Expected an identifier and instead saw ';'.")
+ .addError(6, "Expected an assignment or function call and instead saw an expression.")
+ .addError(10, "Unnecessary semicolon.")
+ .addError(17, "Unnecessary semicolon.")
+ .test(src, { curly: false });
+
+ TestRun()
+ .addError(1, "Expected an identifier and instead saw ';'.")
+ .addError(10, "Unnecessary semicolon.")
+ .addError(17, "Unnecessary semicolon.")
+ .test(src, { curly: false, expr: true });
+};
View
514 node_modules/jshint/packages/jshint/tests/envs.js
@@ -0,0 +1,514 @@
+/**
+ * Tests for the environmental (browser, jquery, etc.) options
+ */
+
+/*jshint boss: true, laxbreak: true, node: true */
+/*global wrap: true */
+
+var JSHINT = require('../jshint.js').JSHINT,
+ assert = require('assert'),
+ fs = require('fs'),
+ TestRun = require("./testhelper").setup.testRun;
+
+function wrap(globals) {
+ return '(function () { return [ ' + globals.join(',') + ' ]; }());';
+}
+
+assert.globalsKnown = function (globals, options) {
+ JSHINT(wrap(globals), options || {});
+ var report = JSHINT.data();
+
+ assert.isUndefined(report.implieds);
+ assert.eql(report.globals.length, globals.length);
+
+ var dict = {};
+ for (var i = 0, g; g = report.globals[i]; i += 1)
+ globals[g] = true;
+
+ for (i = 0, g = null; g = globals[i]; i += 1)
+ assert.ok(g in globals);
+};
+
+assert.globalsImplied = function (globals, options) {
+ JSHINT(wrap(globals), options || {});
+ var report = JSHINT.data();
+
+ assert.isDefined(report.implieds);
+ assert.isUndefined(report.globals, 0);
+
+ var implieds = [];
+ for (var i = 0, warn; warn = report.implieds[i]; i += 1)
+ implieds.push(warn.name);
+
+ assert.eql(implieds.length, globals.length);
+};
+
+/*
+ * Option `node` predefines Node.js (v 0.5.9) globals
+ *
+ * More info:
+ * + http://nodejs.org/docs/v0.5.9/api/globals.html
+ */
+exports.node = function () {
+ var globals = [
+ "__filename"
+ , "__dirname"
+ , "Buffer"
+ , "GLOBAL"
+ , "global"
+ , "module"
+ , "process"
+ , "require"
+ , "exports"
+ , "console"
+ , "setTimeout"
+ , "clearTimeout"
+ , "setInterval"
+ , "clearInterval"
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { node: true });
+
+ // Make sure that the `node` option doesn't conflict with `nomen`
+ var asGlobals = [
+ 'console.log(__dirname);',
+ 'console.log(__filename);'
+ ];
+
+ var asProps = [
+ 'console.log(a.__dirname);',
+ 'console.log(a.__filename);',
+ 'console.log(__hello);'
+ ];
+
+ TestRun().test(asGlobals, { node: true, nomen: true });
+ TestRun()
+ .addError(1, "Unexpected dangling '_' in '__dirname'.")
+ .addError(2, "Unexpected dangling '_' in '__filename'.")
+ .addError(3, "Unexpected dangling '_' in '__hello'.")
+ .test(asProps, { node: true, nomen: true });
+};
+
+/** Option `jquery` predefines jQuery globals */
+exports.jquery = function () {
+ var globals = [ 'jQuery', '$' ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { jquery: true });
+};
+
+/** Option `couch` predefines CouchDB globals */
+exports.couch = function () {
+ var globals = [
+ "require"
+ , "respond"
+ , "getRow"
+ , "emit"
+ , "send"
+ , "start"
+ , "sum"
+ , "log"
+ , "exports"
+ , "module"
+ , "provides"
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { couch: true });
+};
+
+/** Option `prototypejs` predefines Prototype.js and Scriptaculous globals */
+exports.prototypejs = function () {
+ var globals = [
+ "$"
+ , "$$"
+ , "$A"
+ , "$F"
+ , "$H"
+ , "$R"
+ , "$break"
+ , "$continue"
+ , "$w"
+ , "Abstract"
+ , "Ajax"
+ , "Class"
+ , "Enumerable"
+ , "Element"
+ , "Event"
+ , "Field"
+ , "Form"
+ , "Hash"
+ , "Insertion"
+ , "ObjectRange"
+ , "PeriodicalExecuter"
+ , "Position"
+ , "Prototype"
+ , "Selector"
+ , "Template"
+ , "Toggle"
+ , "Try"
+ , "Autocompleter"
+ , "Builder"
+ , "Control"
+ , "Draggable"
+ , "Draggables"
+ , "Droppables"
+ , "Effect"
+ , "Sortable"
+ , "SortableObserver"
+ , "Sound"
+ , "Scriptaculous"
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { prototypejs: true });
+};
+
+/**
+ * Option `devel` predefines global functions used for development
+ * (console, alert, etc.)
+ */
+exports.devel = function () {
+ var globals = [
+ "alert"
+ , "confirm"
+ , "console"
+ , "Debug"
+ , "opera"
+ , "prompt"
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { devel: true });
+};
+
+/*
+ * Option `browser` predefines globals usually found in browser environments.
+ * In addition to stuff like window, setInterval,.. it also supports some
+ * more or less stable HTML5 variables like FileReader, localStorage,..
+ * and typed arrays like Int32Array, Uint32Array, etc.
+ *
+ * More info:
+ * + HTML5: http://www.html5rocks.com/
+ * + Typed arrays: https://developer.mozilla.org/en/JavaScript_typed_arrays
+ */
+exports.browser = function () {
+ var globals = [
+ 'ArrayBuffer'
+ , 'ArrayBufferView'
+ , 'Audio'
+ , 'addEventListener'
+ , 'applicationCache'
+ , 'blur'
+ , 'clearInterval'
+ , 'clearTimeout'
+ , 'close'
+ , 'closed'
+ , 'DataView'
+ , 'defaultStatus'
+ , 'document'
+ , 'event'
+ , 'FileReader'
+ , 'Float32Array'
+ , 'Float64Array'
+ , 'FormData'
+ , 'focus'
+ , 'frames'
+ , 'getComputedStyle'
+ , 'history'
+ , 'HTMLElement'
+ , 'HTMLAnchorElement'
+ , 'HTMLBaseElement'
+ , 'HTMLBlockquoteElement'
+ , 'HTMLBodyElement'
+ , 'HTMLBRElement'
+ , 'HTMLButtonElement'
+ , 'HTMLCanvasElement'
+ , 'HTMLDirectoryElement'
+ , 'HTMLDivElement'
+ , 'HTMLDListElement'
+ , 'HTMLFieldSetElement'
+ , 'HTMLFontElement'
+ , 'HTMLFormElement'
+ , 'HTMLFrameElement'
+ , 'HTMLFrameSetElement'
+ , 'HTMLHeadElement'
+ , 'HTMLHeadingElement'
+ , 'HTMLHRElement'
+ , 'HTMLHtmlElement'
+ , 'HTMLIFrameElement'
+ , 'HTMLImageElement'
+ , 'HTMLInputElement'
+ , 'HTMLIsIndexElement'
+ , 'HTMLLabelElement'
+ , 'HTMLLayerElement'
+ , 'HTMLLegendElement'
+ , 'HTMLLIElement'
+ , 'HTMLLinkElement'
+ , 'HTMLMapElement'
+ , 'HTMLMenuElement'
+ , 'HTMLMetaElement'
+ , 'HTMLModElement'
+ , 'HTMLObjectElement'
+ , 'HTMLOListElement'
+ , 'HTMLOptGroupElement'
+ , 'HTMLOptionElement'
+ , 'HTMLParagraphElement'
+ , 'HTMLParamElement'
+ , 'HTMLPreElement'
+ , 'HTMLQuoteElement'
+ , 'HTMLScriptElement'
+ , 'HTMLSelectElement'
+ , 'HTMLStyleElement'
+ , 'HTMLTableCaptionElement'
+ , 'HTMLTableCellElement'
+ , 'HTMLTableColElement'
+ , 'HTMLTableElement'
+ , 'HTMLTableRowElement'
+ , 'HTMLTableSectionElement'
+ , 'HTMLTextAreaElement'
+ , 'HTMLTitleElement'
+ , 'HTMLUListElement'
+ , 'HTMLVideoElement'
+ , 'Int16Array'
+ , 'Int32Array'
+ , 'Int8Array'
+ , 'Image'
+ , 'length'
+ , 'localStorage'
+ , 'location'
+ , 'moveBy'
+ , 'moveTo'
+ , 'name'
+ , 'navigator'
+ , 'onbeforeunload'
+ , 'onblur'
+ , 'onerror'
+ , 'onfocus'
+ , 'onload'
+ , 'onresize'
+ , 'onunload'
+ , 'open'
+ , 'openDatabase'
+ , 'opener'
+ , 'Option'
+ , 'parent'
+ , 'print'
+ , 'removeEventListener'
+ , 'resizeBy'
+ , 'resizeTo'
+ , 'screen'
+ , 'scroll'
+ , 'scrollBy'
+ , 'scrollTo'
+ , 'SharedWorker'
+ , 'sessionStorage'
+ , 'setInterval'
+ , 'setTimeout'
+ , 'status'
+ , 'top'
+ , 'Uint16Array'
+ , 'Uint32Array'
+ , 'Uint8Array'
+ , 'WebSocket'
+ , 'window'
+ , 'Worker'
+ , 'XMLHttpRequest'
+ , 'XPathEvaluator'
+ , 'XPathException'
+ , 'XPathExpression'
+ , 'XPathNamespace'
+ , 'XPathNSResolver'
+ , 'XPathResult'
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { browser: true });
+};
+
+exports.rhino = function () {
+ var globals = [
+ 'defineClass'
+ , 'deserialize'
+ , 'gc'
+ , 'help'
+ , 'importPackage'
+ , 'java'
+ , 'load'
+ , 'loadClass'
+ , 'print'
+ , 'quit'
+ , 'readFile'
+ , 'readUrl'
+ , 'runCommand'
+ , 'seal'
+ , 'serialize'
+ , 'spawn'
+ , 'sync'
+ , 'toint32'
+ , 'version'
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { rhino: true });
+};
+
+exports.wsh = function () {
+ var globals = [
+ 'ActiveXObject'
+ , 'Enumerator'
+ , 'GetObject'
+ , 'ScriptEngine'
+ , 'ScriptEngineBuildVersion'
+ , 'ScriptEngineMajorVersion'
+ , 'ScriptEngineMinorVersion'
+ , 'VBArray'
+ , 'WSH'
+ , 'WScript'
+ , 'XDomainRequest'
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { wsh: true });
+};
+
+exports.es5 = function () {
+ var src = fs.readFileSync(__dirname + "/fixtures/es5.js", "utf8");
+
+ TestRun()
+ .addError(3, "Extra comma.")
+ .addError(8, "Extra comma.")
+ .addError(15, "get/set are ES5 features.")
+ .addError(16, "get/set are ES5 features.")
+ .addError(20, "get/set are ES5 features.")
+ .addError(22, "get/set are ES5 features.")
+ .addError(26, "get/set are ES5 features.")
+ .addError(30, "get/set are ES5 features.")
+ .addError(31, "get/set are ES5 features.")
+ .addError(36, "get/set are ES5 features.")
+ .test(src);
+
+ TestRun()
+ .addError(36, "Setter is defined without getter.")
+ .test(src, { es5: true });
+
+ // Make sure that JSHint parses getters/setters as function expressions
+ // (https://github.com/jshint/jshint/issues/96)
+ src = fs.readFileSync(__dirname + "/fixtures/es5.funcexpr.js", "utf8");
+ TestRun().test(src, { es5: true });
+};
+
+exports.mootools = function () {
+ var globals = [
+ '$'
+ , '$$'
+ , 'Assets'
+ , 'Browser'
+ , 'Chain'
+ , 'Class'
+ , 'Color'
+ , 'Cookie'
+ , 'Core'
+ , 'Document'
+ , 'DomReady'
+ , 'DOMReady'
+ , 'Drag'
+ , 'Element'
+ , 'Elements'
+ , 'Event'
+ , 'Events'
+ , 'Fx'
+ , 'Group'
+ , 'Hash'
+ , 'HtmlTable'
+ , 'Iframe'
+ , 'IframeShim'
+ , 'InputValidator'
+ , 'instanceOf'
+ , 'Keyboard'
+ , 'Locale'
+ , 'Mask'
+ , 'MooTools'
+ , 'Native'
+ , 'Options'
+ , 'OverText'
+ , 'Request'
+ , 'Scroller'
+ , 'Slick'
+ , 'Slider'
+ , 'Sortables'
+ , 'Spinner'
+ , 'Swiff'
+ , 'Tips'
+ , 'Type'
+ , 'typeOf'
+ , 'URI'
+ , 'Window'
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { mootools: true });
+};
+
+exports.dojo = function () {
+ var globals = [
+ 'dojo'
+ , 'dijit'
+ , 'dojox'
+ , 'define'
+ , 'require'
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { dojo: true });
+};
+
+exports.nonstandard = function () {
+ var globals = [
+ 'escape'
+ , 'unescape'
+ ];
+
+ assert.globalsImplied(globals);
+ assert.globalsKnown(globals, { nonstandard: true });
+};
+
+/*
+ * By default JSHint supports all globals provided by the ECMAScript 5.1 specification.
+ *
+ * More info:
+ * + http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
+ */
+exports.standard = function () {
+ var globals = [
+ 'Array'
+ , 'Boolean'
+ , 'Date'
+ , 'decodeURI'
+ , 'decodeURIComponent'
+ , 'encodeURI'
+ , 'encodeURIComponent'
+ , 'Error'
+ , 'EvalError'
+ , 'Function'
+ , 'hasOwnProperty'
+ , 'isFinite'
+ , 'isNaN'
+ , 'JSON'
+ , 'Math'
+ , 'Number'
+ , 'Object'
+ , 'parseInt'
+ , 'parseFloat'
+ , 'RangeError'
+ , 'ReferenceError'
+ , 'RegExp'
+ , 'String'
+ , 'SyntaxError'
+ , 'TypeError'
+ , 'URIError'
+ ];
+
+ assert.globalsKnown(globals); // You don't need any option to recognize standard globals
+};
View
28 node_modules/jshint/packages/jshint/tests/fixtures/asi.js
@@ -0,0 +1,28 @@
+/*jshint undef: true, globalstrict: true*/
+"use strict"
+function foo () {
+ if (true) return
+ var x = 1
+}
+
+for (var i = 0; i < 10; i++) {
+ if (i === 0) continue
+ var y = 2
+ if (i === 1) break
+ var z = 3
+
+ switch (z) {
+ case 3:
+ var m = ""
+ return
+ case 2:
+ break
+ default:
+ break
+ }
+}
+
+foo()
+var a = 1
+var b = '1'
+var c = "1"
View
1,158 node_modules/jshint/packages/jshint/tests/fixtures/backbone.js
@@ -0,0 +1,1158 @@
+// Backbone.js 0.5.3
+// (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
+// Backbone may be freely distributed under the MIT license.
+// For all details and documentation:
+// http://documentcloud.github.com/backbone
+
+(function(){
+
+ // Initial Setup
+ // -------------
+
+ // Save a reference to the global object.
+ var root = this;
+
+ // Save the previous value of the `Backbone` variable.
+ var previousBackbone = root.Backbone;
+
+ // The top-level namespace. All public Backbone classes and modules will
+ // be attached to this. Exported for both CommonJS and the browser.
+ var Backbone;
+ if (typeof exports !== 'undefined') {
+ Backbone = exports;
+ } else {
+ Backbone = root.Backbone = {};