update JSHint to 2.3.0, and only run it on Node.js

This commit is contained in:
Jeff Williams 2013-11-10 23:20:03 -08:00
parent 8f51a6f9a1
commit 3716df0e23
25 changed files with 58812 additions and 4888 deletions

View File

@ -1,5 +1,6 @@
{
"bitwise": true,
"camelcase": false,
"curly": true,
"eqeqeq": false,
"forin": true,
@ -10,8 +11,9 @@
"noempty": false,
"nonew": true,
"plusplus": false,
"regexp": false,
"quotmark": false,
"undef": true,
"unused": false,
"strict": false,
"trailing": false,
@ -19,8 +21,7 @@
"boss": false,
"debug": false,
"eqnull": true,
"es5": true,
"esnext": true,
"esnext": false,
"evil": false,
"expr": false,
"funcscope": false,
@ -30,10 +31,9 @@
"laxbreak": false,
"laxcomma": false,
"loopfunc": true,
"moz": true,
"multistr": false,
"onecase": true,
"proto": false,
"regexdash": false,
"scripturl": true,
"shadow": false,
"smarttabs": false,
@ -49,9 +49,12 @@
"mootools": false,
"node": true,
"nonstandard": false,
"phantom": true,
"prototypejs": false,
"rhino": true,
"worker": false,
"wsh": false,
"yui": false,
"nomen": false,
"onevar": false,

View File

@ -25,7 +25,7 @@
"wrench": "1.3.9"
},
"devDependencies": {
"jshint": "0.9.1"
"jshint": "2.3.0"
},
"engines": {
"node": ">=0.10"

22
node_modules/jshint/data/ascii-identifier-data.js generated vendored Normal file
View File

@ -0,0 +1,22 @@
var identifierStartTable = [];
for (var i = 0; i < 128; i++) {
identifierStartTable[i] =
i === 36 || // $
i >= 65 && i <= 90 || // A-Z
i === 95 || // _
i >= 97 && i <= 122; // a-z
}
var identifierPartTable = [];
for (var i = 0; i < 128; i++) {
identifierPartTable[i] =
identifierStartTable[i] || // $, _, A-Z, a-z
i >= 48 && i <= 57; // 0-9
}
module.exports = {
asciiIdentifierStartTable: identifierStartTable,
asciiIdentifierPartTable: identifierPartTable
};

File diff suppressed because it is too large Load Diff

48477
node_modules/jshint/data/non-ascii-identifier-start.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
Copyright (c) 2012 Raynos.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -0,0 +1,85 @@
/*global window, global*/
var util = require("util")
var assert = require("assert")
var slice = Array.prototype.slice
var console
var times = {}
if (typeof global !== "undefined" && global.console) {
console = global.console
} else if (typeof window !== "undefined" && window.console) {
console = window.console
} else {
console = window.console = {}
}
var functions = [
[log, "log"]
, [info, "info"]
, [warn, "warn"]
, [error, "error"]
, [time, "time"]
, [timeEnd, "timeEnd"]
, [trace, "trace"]
, [dir, "dir"]
, [assert, "assert"]
]
for (var i = 0; i < functions.length; i++) {
var tuple = functions[i]
var f = tuple[0]
var name = tuple[1]
if (!console[name]) {
console[name] = f
}
}
module.exports = console
function log() {}
function info() {
console.log.apply(console, arguments)
}
function warn() {
console.log.apply(console, arguments)
}
function error() {
console.warn.apply(console, arguments)
}
function time(label) {
times[label] = Date.now()
}
function timeEnd(label) {
var time = times[label]
if (!time) {
throw new Error("No such label: " + label)
}
var duration = Date.now() - time
console.log(label + ": " + duration + "ms")
}
function trace() {
var err = new Error()
err.name = "Trace"
err.message = util.format.apply(null, arguments)
console.error(err.stack)
}
function dir(object) {
console.log(util.inspect(object) + "\n")
}
function assert(expression) {
if (!expression) {
var arr = slice.call(arguments, 1)
assert.ok(false, util.format.apply(null, arr))
}
}

View File

@ -0,0 +1,76 @@
{
"name": "console-browserify",
"version": "0.1.6",
"description": "Emulate console for all the browsers",
"keywords": [],
"author": {
"name": "Raynos",
"email": "raynos2@gmail.com"
},
"repository": {
"type": "git",
"url": "git://github.com/Raynos/console-browserify.git"
},
"main": "index",
"homepage": "https://github.com/Raynos/console-browserify",
"contributors": [
{
"name": "Raynos"
}
],
"bugs": {
"url": "https://github.com/Raynos/console-browserify/issues",
"email": "raynos2@gmail.com"
},
"dependencies": {},
"devDependencies": {
"tape": "~0.2.2",
"browserify": "https://github.com/raynos/node-browserify/tarball/master",
"testem": "~0.2.55",
"jsonify": "0.0.0"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/Raynos/console-browserify/raw/master/LICENSE"
}
],
"scripts": {
"test": "node ./test",
"build": "browserify test/index.js -o test/static/bundle.js",
"testem": "testem"
},
"testling": {
"files": "test/index.js",
"browsers": {
"ie": [
"6",
"7",
"8",
"9",
"10"
],
"firefox": [
"16",
"17",
"nightly"
],
"chrome": [
"22",
"23",
"canary"
],
"opera": [
"12",
"next"
],
"safari": [
"5.1"
]
}
},
"readme": "# console-browserify\n\n[![build status][1]][2]\n\n[![browser support][3]][4]\n\nEmulate console for all the browsers\n\n## Example\n\n```js\nvar console = require(\"console-browserify\")\n\nconsole.log(\"hello world!\")\n```\n\n## Installation\n\n`npm install console-browserify`\n\n## Contributors\n\n - Raynos\n\n## MIT Licenced\n\n\n\n [1]: https://secure.travis-ci.org/Raynos/console-browserify.png\n [2]: http://travis-ci.org/Raynos/console-browserify\n [3]: http://ci.testling.com/Raynos/console-browserify.png\n [4]: http://ci.testling.com/Raynos/console-browserify\n",
"readmeFilename": "README.md",
"_id": "console-browserify@0.1.6",
"_from": "console-browserify@0.1.x"
}

95
node_modules/jshint/package.json generated vendored
View File

@ -1,43 +1,78 @@
{
"name": "jshint",
"version": "0.9.1",
"description": "A CLI for JSHint",
"homepage": "http://github.com/jshint/node-jshint",
"version": "2.3.0",
"homepage": "http://jshint.com/",
"description": "Static analysis tool for JavaScript",
"author": {
"name": "Brent Lintner",
"email": "brent.lintner@gmail.com",
"url": "http://github.com/brentlintner"
"name": "Anton Kovalyov",
"email": "anton@kovalyov.net",
"url": "http://anton.kovalyov.net/"
},
"repository": {
"type": "git",
"url": "https://github.com/jshint/jshint.git"
},
"bugs": {
"url": "https://github.com/jshint/jshint/issues"
},
"bin": {
"jshint": "./bin/jshint"
},
"scripts": {
"data": "node scripts/generate-identifier-data",
"build": "node bin/build",
"test": "nodeunit tests tests/regression tests/unit",
"pretest": "jshint src"
},
"main": "./src/jshint.js",
"dependencies": {
"shelljs": "0.1.x",
"underscore": "1.4.x",
"cli": "0.4.x",
"minimatch": "0.x.x",
"console-browserify": "0.1.x"
},
"devDependencies": {
"jshint": "2.3.x",
"shelljs": "0.1.x",
"browserify": "2.12.x",
"coveraje": "0.2.x",
"nodeunit": "0.8.x",
"sinon": "1.7.x",
"unicode-6.3.0": "0.1.x",
"regenerate": "0.5.x"
},
"jshintConfig": {
"boss": true,
"node": true,
"strict": true,
"white": true,
"smarttabs": true,
"maxlen": 100,
"newcap": false,
"undef": true,
"unused": true,
"onecase": true,
"indent": 2
},
"licenses": [
{
"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
"url": "https://github.com/jshint/jshint/blob/master/LICENSE"
}
],
"bin": {
"jshint": "./bin/hint"
},
"main": "packages/jshint/jshint",
"files": [
"packages/jshint/README.markdown",
"packages/jshint/jshint.js",
"README.md",
"LICENSE",
"bin/hint",
"lib"
],
"dependencies": {
"cli": "0.4.3",
"minimatch": "0.0.x"
},
"devDependencies": {
"jasmine-node": "1.0.x"
},
"preferGlobal": true,
"readme": "# node-jshint\n\nA command line interface and npm package for jshint.\n\n## Install\n\nTo use jshint from any location (for npm v1.x) you need to install using the global (-g) flag.\n\n npm install -g jshint\n\n## Usage\n\n jshint -h\n\nYou can also require JSHint itself as a module.\n\n var jshint = require('jshint');\n\nNote: If you are using npm v1.x be sure to install jshint locally (without the -g flag) or link it globally.\n\n## Text Editor Plugins\n\n* [gedit-node-jshint](https://github.com/niftylettuce/gedit-node-jshint) - Simply use CTRL+J in gedit to run JSHint using `node-jshint`.\n* [vim syntastic](https://github.com/scrooloose/syntastic) - Run node-jshint at each file save.\n* [sublime-jshint](https://github.com/uipoet/sublime-jshint) - `F7` or `command-B` on any .js file. `F4` next error line,column. `shift-F4` previous error line,column.\n\n## Custom Reporters\n\nSpecify a custom reporter module (see example/reporter.js).\n\n --reporter path/to/reporter.js\n\nUse a jslint compatible xml reporter.\n\n --jslint-reporter\n\nShow additional non-error data generated by jshint (unused globals etc).\n\n --show-non-errors\n\n## Configuration Options\n\n**Note:** This behavior described below is very different from versions prior to `0.6`.\n\nThe CLI uses the default options that come with JSHint. \n\nOnly one extra option is unique to node-jshint: `globals` \nallows you to define an object of globals that get ignored for every file.\nTo see an example you can look at how whitelisted globals are defined\nin the [jshint code](https://github.com/jshint/jshint/blob/c047ea1b01097fcc220fcd1a55c41f67ae2e6e81/jshint.js#L556)\n\nTo have your own configuration apply, there are several methods you can use:\n\n### Specify Manually\n\nSetting the `--config=/path/to/your/config` command line option to specify your own configuration file outside of the directory tree for your project.\n\n### Within your Project's Directory Tree\n\nWhen the CLI is called, and a configuration file isn't specified already, `node-jshint` will attempt to locate one for you starting in `pwd`. (or \"present working directory\") If this does not yield a `.jshintrc` file, it will move one level up (`..`) the directory tree all the way up to the filesystem root. If a file is found, it stops immediately and uses that set of configuration.\n\nThis setup allows you to set up **one** configuration file for your entire project. (place it in the root folder) As long as you run `jshint` from anywhere within your project directory tree, the same configuration file will be used.\n\n### Home Directory\n\nIf all the methods above do not yield a `.jshintrc` to use, the last place that will be checked is your user's `$HOME` directory.\n\n## File Extensions\n\nDefault extension for files is \".js\". If you want to use JSHint with other file extensions (.json), you need to pass this extra extension as an option :\n\n --extra-ext .json\n\n## Ignoring Files and Directories\n\nIf there is a .jshintignore file in your project's directory tree, (also provided you run `jshint` from within your project's directory) then any directories or files specified will be skipped over. (behaves just like a `.gitignore` file)\n\n**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).\n\n## Installing dependencies for development\n\n ./configure\n\n## Build Commands\n\n jake -T\n\n## Project Guidelines\n\n* All tests are passing.\n* No (new) JSHint errors are introduced.\n",
"_id": "jshint@0.9.1",
"files": [
"bin",
"src",
"data"
],
"readme": "JSHint, A Static Code Analysis Tool for JavaScript\n--------------------------------------------------\n\n\\[ [Use it online](http://jshint.com/) • [About](http://jshint.com/about/) • \n[Docs](http://jshint.com/docs/) • [FAQ](http://jshint.com/docs/faq) • \n[Install](http://jshint.com/install/) • [Hack](http://jshint.com/hack/) • \n[Blog](http://jshint.com/blog/) • [Twitter](https://twitter.com/jshint/) \\]\n\n[![Build Status](https://travis-ci.org/jshint/jshint.png?branch=master)](https://travis-ci.org/jshint/jshint)\n[![NPM version](https://badge.fury.io/js/jshint.png)](http://badge.fury.io/js/jshint)\n\nJSHint is a community-driven tool to detect errors and potential problems\nin JavaScript code and to enforce your teams coding conventions. It is\nvery flexible so you can easily adjust it to your particular coding guidelines\nand the environment you expect your code to execute in.\n\n#### JSHint 2.x versus JSHint 3\n\nThere's an effort going on to release the next major version of JSHint. All\ndevelopment in the `master` branch is for the version 3.0. Current stable\nversion is in the `2.x` branch. Keep that in mind when submitting pull requests.\n\nAlso, before reporting a bug or thinking about hacking on JSHint, read this:\n[JSHint 3 plans](http://www.jshint.com/blog/jshint-3-plans/). TL;DR: we're\nmoving away from style checks within JSHint so no new features around\nstyle checks will be accepted. Bug fixes are fine for the `2.x` branch.\n\n#### Reporting a bug\n\nTo report a bug simply create a\n[new GitHub Issue](https://github.com/jshint/jshint/issues/new) and describe\nyour problem or suggestion. We welcome all kind of feedback regarding\nJSHint including but not limited to:\n\n * When JSHint doesn't work as expected\n * When JSHint complains about valid JavaScript code that works in all browsers\n * When you simply want a new option or feature\n\nBefore reporting a bug look around to see if there are any open or closed tickets\nthat cover your issue. And remember the wisdom: pull request > bug report > tweet.\n\n\n#### License\n\nJSHint is distributed under the MIT License. One file and one file only\n(src/stable/jshint.js) is distributed under the slightly modified MIT License.\n\n\n#### Thank you!\n\nWe really appreciate all kind of feedback and contributions. Thanks for using and supporting JSHint!\n",
"readmeFilename": "README.md",
"_id": "jshint@2.3.0",
"dist": {
"shasum": "ea05fb7d6dae4f2d0d0392ad89b06f7b72eb497e"
"shasum": "7be088feee3b1b44ba69d53c3b5a85dadff63fee"
},
"_from": "jshint"
"_from": "jshint@",
"_resolved": "https://registry.npmjs.org/jshint/-/jshint-2.3.0.tgz"
}

File diff suppressed because it is too large Load Diff

506
node_modules/jshint/src/cli.js generated vendored Normal file
View File

@ -0,0 +1,506 @@
"use strict";
var cli = require("cli");
var path = require("path");
var shjs = require("shelljs");
var minimatch = require("minimatch");
var JSHINT = require("./jshint.js").JSHINT;
var defReporter = require("./reporters/default").reporter;
var OPTIONS = {
"config": ["c", "Custom configuration file", "string", false ],
"reporter": ["reporter", "Custom reporter (<PATH>|jslint|checkstyle)", "string", undefined ],
"exclude": ["exclude",
"Exclude files matching the given filename pattern (same as .jshintignore)", "string", null],
"verbose": ["verbose", "Show message codes"],
"show-non-errors": ["show-non-errors", "Show additional data generated by jshint"],
"extra-ext": ["e",
"Comma-separated list of file extensions to use (default is .js)", "string", ""],
// Deprecated options.
"jslint-reporter": [
"jslint-reporter",
deprecated("Use a jslint compatible reporter", "--reporter=jslint")
],
"checkstyle-reporter": [
"checkstyle-reporter",
deprecated("Use a CheckStyle compatible XML reporter", "--reporter=checkstyle")
]
};
/**
* Returns the same text but with a deprecation notice.
* Useful for options descriptions.
*
* @param {string} text
* @param {string} alt (optional) Alternative command to include in the
* deprecation notice.
*
* @returns {string}
*/
function deprecated(text, alt) {
if (!alt) {
return text + " (DEPRECATED)";
}
return text + " (DEPRECATED, use " + alt + " instead)";
}
/**
* Removes JavaScript comments from a string by replacing
* everything between block comments and everything after
* single-line comments in a non-greedy way.
*
* English version of the regex:
* match '/*'
* then match zero or more instances of any character (incl. \n)
* except for instances of '* /' (without a space, obv.)
* then match '* /' (again, without a space)
*
* @param {string} str a string with potential JavaScript comments.
* @returns {string} a string without JavaScript comments.
*/
function removeComments(str) {
str = str || "";
str = str.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\//g, "");
str = str.replace(/\/\/[^\n\r]*/g, ""); // Everything after '//'
return str;
}
/**
* Tries to find a configuration file in either project directory
* or in the home directory. Configuration files are named
* '.jshintrc'.
*
* @param {string} file path to the file to be linted
* @returns {string} a path to the config file
*/
function findConfig(file) {
var dir = path.dirname(path.resolve(file));
var envs = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
var home = path.normalize(path.join(envs, ".jshintrc"));
var proj = findFile(".jshintrc", dir);
if (proj)
return proj;
if (shjs.test("-e", home))
return home;
return null;
}
/**
* Tries to find JSHint configuration within a package.json file
* (if any). It search in the current directory and then goes up
* all the way to the root just like findFile.
*
* @param {string} file path to the file to be linted
* @returns {object} config object
*/
function loadNpmConfig(file) {
var dir = path.dirname(path.resolve(file));
var fp = findFile("package.json", dir);
if (!fp)
return null;
return require(fp).jshintConfig || null;
}
/**
* Tries to import a reporter file and returns its reference.
*
* @param {string} fp a path to the reporter file
* @returns {object} imported module for the reporter or 'null'
* if a module cannot be imported.
*/
function loadReporter(fp) {
try {
return require(fp).reporter;
} catch (err) {
return null;
}
}
// Storage for memoized results from find file
// Should prevent lots of directory traversal &
// lookups when liniting an entire project
var findFileResults = {};
/**
* Searches for a file with a specified name starting with
* 'dir' and going all the way up either until it finds the file
* or hits the root.
*
* @param {string} name filename to search for (e.g. .jshintrc)
* @param {string} dir directory to start search from (default:
* current working directory)
*
* @returns {string} normalized filename
*/
function findFile(name, dir) {
dir = dir || process.cwd();
var filename = path.normalize(path.join(dir, name));
if (findFileResults[filename] !== undefined) {
return findFileResults[filename];
}
var parent = path.resolve(dir, "../");
if (shjs.test("-e", filename)) {
findFileResults[filename] = filename;
return filename;
}
if (dir === parent) {
findFileResults[filename] = null;
return null;
}
return findFile(name, parent);
}
/**
* Loads a list of files that have to be skipped. JSHint assumes that
* the list is located in a file called '.jshintignore'.
*
* @return {array} a list of files to ignore.
*/
function loadIgnores(exclude) {
var file = findFile(".jshintignore");
if (!file && !exclude) {
return [];
}
var lines = (file ? shjs.cat(file) : "").split("\n");
lines.unshift(exclude || "");
return lines
.filter(function (line) {
return !!line.trim();
})
.map(function (line) {
if (line[0] === "!")
return "!" + path.resolve(path.dirname(file), line.substr(1).trim());
return path.resolve(path.dirname(file), line.trim());
});
}
/**
* Checks whether we should ignore a file or not.
*
* @param {string} fp a path to a file
* @param {array} patterns a list of patterns for files to ignore
*
* @return {boolean} 'true' if file should be ignored, 'false' otherwise.
*/
function isIgnored(fp, patterns) {
return patterns.some(function (ip) {
if (minimatch(path.resolve(fp), ip, { nocase: true })) {
return true;
}
if (path.resolve(fp) === ip) {
return true;
}
if (shjs.test("-d", fp) && ip.match(/^[^\/]*\/?$/) &&
fp.match(new RegExp("^" + ip + ".*"))) {
return true;
}
});
}
/**
* Recursively gather all files that need to be linted,
* excluding those that user asked to ignore.
*
* @param {string} fp a path to a file or directory to lint
* @param {array} files a pointer to an array that stores a list of files
* @param {array} ignores a list of patterns for files to ignore
* @param {array} ext a list of non-dot-js extensions to lint
*/
function collect(fp, files, ignores, ext) {
if (ignores && isIgnored(fp, ignores)) {
return;
}
if (!shjs.test("-e", fp)) {
cli.error("Can't open " + fp);
return;
}
if (shjs.test("-d", fp)) {
shjs.ls(fp).forEach(function (item) {
var itempath = path.join(fp, item);
if (shjs.test("-d", itempath) || item.match(ext)) {
collect(itempath, files, ignores, ext);
}
});
return;
}
files.push(fp);
}
/**
* Runs JSHint against provided file and saves the result
*
* @param {string} code code that needs to be linted
* @param {object} results a pointer to an object with results
* @param {object} config an object with JSHint configuration
* @param {object} data a pointer to an object with extra data
* @param {string} file (optional) file name that is being linted
*/
function lint(code, results, config, data, file) {
var globals;
var lintData;
var buffer = [];
config = config || {};
config = JSON.parse(JSON.stringify(config));
if (config.prereq) {
config.prereq.forEach(function (fp) {
fp = path.join(config.dirname, fp);
if (shjs.test("-e", fp))
buffer.push(shjs.cat(fp));
});
delete config.prereq;
}
if (config.globals) {
globals = config.globals;
delete config.globals;
}
delete config.dirname;
buffer.push(code);
buffer = buffer.join("\n");
buffer = buffer.replace(/^\uFEFF/, ""); // Remove potential Unicode BOM.
if (!JSHINT(buffer, config, globals)) {
JSHINT.errors.forEach(function (err) {
if (err) {
results.push({ file: file || "stdin", error: err });
}
});
}
lintData = JSHINT.data();
if (lintData) {
lintData.file = file || "stdin";
data.push(lintData);
}
}
var exports = {
/**
* Loads and parses a configuration file.
*
* @param {string} fp a path to the config file
* @returns {object} config object
*/
loadConfig: function (fp) {
if (!fp) {
return {};
}
if (!shjs.test("-e", fp)) {
cli.error("Can't find config file: " + fp);
process.exit(1);
}
try {
var config = JSON.parse(removeComments(shjs.cat(fp)));
config.dirname = path.dirname(fp);
return config;
} catch (err) {
cli.error("Can't parse config file: " + fp);
process.exit(1);
}
},
/**
* Gathers all files that need to be linted
*
* @param {object} post-processed options from 'interpret':
* args - CLI arguments
* ignores - A list of files/dirs to ignore (defaults to .jshintignores)
* extensions - A list of non-dot-js extensions to check
*/
gather: function (opts) {
var files = [];
var reg = new RegExp("\\.(js" +
(!opts.extensions ? "" : "|" +
opts.extensions.replace(/,/g, "|").replace(/[\. ]/g, "")) + ")$");
var ignores = !opts.ignores ? loadIgnores() : opts.ignores.map(function (target) {
return path.resolve(target);
});
opts.args.forEach(function (target) {
collect(target, files, ignores, reg);
});
return files;
},
/**
* Gathers all files that need to be linted, lints them, sends them to
* a reporter and returns the overall result.
*
* @param {object} post-processed options from 'interpret':
* args - CLI arguments
* config - Configuration object
* reporter - Reporter function
* ignores - A list of files/dirs to ignore
* extensions - A list of non-dot-js extensions to check
* @param {function} cb a callback to call when function is finished
* asynchronously.
*
* @returns {bool} 'true' if all files passed, 'false' otherwise and 'null'
* when function will be finished asynchronously.
*/
run: function (opts, cb) {
var files = exports.gather(opts);
var results = [];
var data = [];
if (opts.useStdin) {
cli.withStdin(function (code) {
lint(code, results, opts.config || {}, data);
(opts.reporter || defReporter)(results, data, { verbose: opts.verbose });
cb(results.length === 0);
});
return null;
}
files.forEach(function (file) {
var config = opts.config || loadNpmConfig(file) || exports.loadConfig(findConfig(file));
var code;
try {
code = shjs.cat(file);
} catch (err) {
cli.error("Can't open " + file);
process.exit(1);
}
lint(code, results, config, data, file);
});
(opts.reporter || defReporter)(results, data, { verbose: opts.verbose });
return results.length === 0;
},
/**
* Helper exposed for testing.
* Used to determine is stdout has any buffered output before exiting the program
*/
getBufferSize: function () {
return process.stdout.bufferSize;
},
/**
* Main entrance function. Parses arguments and calls 'run' when
* its done. This function is called from bin/jshint file.
*
* @param {object} args, arguments in the process.argv format.
*/
interpret: function (args) {
cli.setArgv(args);
cli.options = {};
cli.enable("version", "glob", "help");
cli.setApp(path.resolve(__dirname + "/../package.json"));
var options = cli.parse(OPTIONS);
// Use config file if specified
var config;
if (options.config) {
config = exports.loadConfig(options.config);
}
switch (true) {
// JSLint reporter
case options.reporter === "jslint":
case options["jslint-reporter"]:
options.reporter = "./reporters/jslint_xml.js";
break;
// CheckStyle (XML) reporter
case options.reporter === "checkstyle":
case options["checkstyle-reporter"]:
options.reporter = "./reporters/checkstyle.js";
break;
// Reporter that displays additional JSHint data
case options["show-non-errors"]:
options.reporter = "./reporters/non_error.js";
break;
// Custom reporter
case options.reporter !== undefined:
options.reporter = path.resolve(process.cwd(), options.reporter);
}
var reporter;
if (options.reporter) {
reporter = loadReporter(options.reporter);
if (reporter === null) {
cli.error("Can't load reporter file: " + options.reporter);
process.exit(1);
}
}
// This is a hack. exports.run is both sync and async function
// because I needed stdin support (and cli.withStdin is async)
// and was too lazy to change tests.
function done(passed) {
/*jshint eqnull:true */
if (passed == null)
return;
// Patch as per https://github.com/visionmedia/mocha/issues/333
// fixes issues with piped output on Windows.
// Root issue is here https://github.com/joyent/node/issues/3584
function exit() { process.exit(passed ? 0 : 2); }
try {
if (exports.getBufferSize()) {
process.stdout.once('drain', exit);
} else {
exit();
}
} catch (err) {
exit();
}
}
done(exports.run({
args: cli.args,
config: config,
reporter: reporter,
ignores: loadIgnores(options.exclude),
extensions: options["extra-ext"],
verbose: options.verbose,
useStdin: {"-": true, "/dev/stdin": true}[args[args.length - 1]]
}, done));
}
};
module.exports = exports;

5002
node_modules/jshint/src/jshint.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1576
node_modules/jshint/src/lex.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

220
node_modules/jshint/src/messages.js generated vendored Normal file
View File

@ -0,0 +1,220 @@
"use strict";
var _ = require("underscore");
var errors = {
// JSHint options
E001: "Bad option: '{a}'.",
E002: "Bad option value.",
// JSHint input
E003: "Expected a JSON value.",
E004: "Input is neither a string nor an array of strings.",
E005: "Input is empty.",
E006: "Unexpected early end of program.",
// Strict mode
E007: "Missing \"use strict\" statement.",
E008: "Strict violation.",
E009: "Option 'validthis' can't be used in a global scope.",
E010: "'with' is not allowed in strict mode.",
// Constants
E011: "const '{a}' has already been declared.",
E012: "const '{a}' is initialized to 'undefined'.",
E013: "Attempting to override '{a}' which is a constant.",
// Regular expressions
E014: "A regular expression literal can be confused with '/='.",
E015: "Unclosed regular expression.",
E016: "Invalid regular expression.",
// Tokens
E017: "Unclosed comment.",
E018: "Unbegun comment.",
E019: "Unmatched '{a}'.",
E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.",
E021: "Expected '{a}' and instead saw '{b}'.",
E022: "Line breaking error '{a}'.",
E023: "Missing '{a}'.",
E024: "Unexpected '{a}'.",
E025: "Missing ':' on a case clause.",
E026: "Missing '}' to match '{' from line {a}.",
E027: "Missing ']' to match '[' form line {a}.",
E028: "Illegal comma.",
E029: "Unclosed string.",
// Everything else
E030: "Expected an identifier and instead saw '{a}'.",
E031: "Bad assignment.", // FIXME: Rephrase
E032: "Expected a small integer or 'false' and instead saw '{a}'.",
E033: "Expected an operator and instead saw '{a}'.",
E034: "get/set are ES5 features.",
E035: "Missing property name.",
E036: "Expected to see a statement and instead saw a block.",
E037: null, // Vacant
E038: null, // Vacant
E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.",
E040: "Each value should have its own case label.",
E041: "Unrecoverable syntax error.",
E042: "Stopping.",
E043: "Too many errors.",
E044: "'{a}' is already defined and can't be redefined.",
E045: "Invalid for each loop.",
E046: "A yield statement shall be within a generator function (with syntax: `function*`)",
E047: "A generator function shall contain a yield statement.",
E048: "Let declaration not directly within block.",
E049: "A {a} cannot be named '{b}'.",
E050: "Mozilla requires the yield expression to be parenthesized here.",
E051: "Regular parameters cannot come after default parameters."
};
var warnings = {
W001: "'hasOwnProperty' is a really bad name.",
W002: "Value of '{a}' may be overwritten in IE 8 and earlier.",
W003: "'{a}' was used before it was defined.",
W004: "'{a}' is already defined.",
W005: "A dot following a number can be confused with a decimal point.",
W006: "Confusing minuses.",
W007: "Confusing pluses.",
W008: "A leading decimal point can be confused with a dot: '{a}'.",
W009: "The array literal notation [] is preferrable.",
W010: "The object literal notation {} is preferrable.",
W011: "Unexpected space after '{a}'.",
W012: "Unexpected space before '{a}'.",
W013: "Missing space after '{a}'.",
W014: "Bad line breaking before '{a}'.",
W015: "Expected '{a}' to have an indentation at {b} instead at {c}.",
W016: "Unexpected use of '{a}'.",
W017: "Bad operand.",
W018: "Confusing use of '{a}'.",
W019: "Use the isNaN function to compare with NaN.",
W020: "Read only.",
W021: "'{a}' is a function.",
W022: "Do not assign to the exception parameter.",
W023: "Expected an identifier in an assignment and instead saw a function invocation.",
W024: "Expected an identifier and instead saw '{a}' (a reserved word).",
W025: "Missing name in function declaration.",
W026: "Inner functions should be listed at the top of the outer function.",
W027: "Unreachable '{a}' after '{b}'.",
W028: "Label '{a}' on {b} statement.",
W030: "Expected an assignment or function call and instead saw an expression.",
W031: "Do not use 'new' for side effects.",
W032: "Unnecessary semicolon.",
W033: "Missing semicolon.",
W034: "Unnecessary directive \"{a}\".",
W035: "Empty block.",
W036: "Unexpected /*member '{a}'.",
W037: "'{a}' is a statement label.",
W038: "'{a}' used out of scope.",
W039: "'{a}' is not allowed.",
W040: "Possible strict violation.",
W041: "Use '{a}' to compare with '{b}'.",
W042: "Avoid EOL escaping.",
W043: "Bad escaping of EOL. Use option multistr if needed.",
W044: "Bad or unnecessary escaping.",
W045: "Bad number '{a}'.",
W046: "Don't use extra leading zeros '{a}'.",
W047: "A trailing decimal point can be confused with a dot: '{a}'.",
W048: "Unexpected control character in regular expression.",
W049: "Unexpected escaped character '{a}' in regular expression.",
W050: "JavaScript URL.",
W051: "Variables should not be deleted.",
W052: "Unexpected '{a}'.",
W053: "Do not use {a} as a constructor.",
W054: "The Function constructor is a form of eval.",
W055: "A constructor name should start with an uppercase letter.",
W056: "Bad constructor.",
W057: "Weird construction. Is 'new' unnecessary?",
W058: "Missing '()' invoking a constructor.",
W059: "Avoid arguments.{a}.",
W060: "document.write can be a form of eval.",
W061: "eval can be harmful.",
W062: "Wrap an immediate function invocation in parens " +
"to assist the reader in understanding that the expression " +
"is the result of a function, and not the function itself.",
W063: "Math is not a function.",
W064: "Missing 'new' prefix when invoking a constructor.",
W065: "Missing radix parameter.",
W066: "Implied eval. Consider passing a function instead of a string.",
W067: "Bad invocation.",
W068: "Wrapping non-IIFE function literals in parens is unnecessary.",
W069: "['{a}'] is better written in dot notation.",
W070: "Extra comma. (it breaks older versions of IE)",
W071: "This function has too many statements. ({a})",
W072: "This function has too many parameters. ({a})",
W073: "Blocks are nested too deeply. ({a})",
W074: "This function's cyclomatic complexity is too high. ({a})",
W075: "Duplicate key '{a}'.",
W076: "Unexpected parameter '{a}' in get {b} function.",
W077: "Expected a single parameter in set {a} function.",
W078: "Setter is defined without getter.",
W079: "Redefinition of '{a}'.",
W080: "It's not necessary to initialize '{a}' to 'undefined'.",
W081: "Too many var statements.",
W082: "Function declarations should not be placed in blocks. " +
"Use a function expression or move the statement to the top of " +
"the outer function.",
W083: "Don't make functions within a loop.",
W084: "Expected a conditional expression and instead saw an assignment.",
W085: "Don't use 'with'.",
W086: "Expected a 'break' statement before '{a}'.",
W087: "Forgotten 'debugger' statement?",
W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.",
W089: "The body of a for in should be wrapped in an if statement to filter " +
"unwanted properties from the prototype.",
W090: "'{a}' is not a statement label.",
W091: "'{a}' is out of scope.",
W092: "Wrap the /regexp/ literal in parens to disambiguate the slash operator.",
W093: "Did you mean to return a conditional instead of an assignment?",
W094: "Unexpected comma.",
W095: "Expected a string and instead saw {a}.",
W096: "The '{a}' key may produce unexpected results.",
W097: "Use the function form of \"use strict\".",
W098: "'{a}' is defined but never used.",
W099: "Mixed spaces and tabs.",
W100: "This character may get silently deleted by one or more browsers.",
W101: "Line is too long.",
W102: "Trailing whitespace.",
W103: "The '{a}' property is deprecated.",
W104: "'{a}' is only available in JavaScript 1.7.",
W105: "Unexpected {a} in '{b}'.",
W106: "Identifier '{a}' is not in camel case.",
W107: "Script URL.",
W108: "Strings must use doublequote.",
W109: "Strings must use singlequote.",
W110: "Mixed double and single quotes.",
W112: "Unclosed string.",
W113: "Control character in string: {a}.",
W114: "Avoid {a}.",
W115: "Octal literals are not allowed in strict mode.",
W116: "Expected '{a}' and instead saw '{b}'.",
W117: "'{a}' is not defined.",
W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).",
W119: "'{a}' is only available in ES6 (use esnext option).",
W120: "You might be leaking a variable ({a}) here.",
W121: "Extending prototype of native object: '{a}'.",
W122: "Invalid typeof value '{a}'"
};
var info = {
I001: "Comma warnings can be turned off with 'laxcomma'.",
I002: "Reserved words as properties can be used under the 'es5' option.",
I003: "ES5 option is now set per default"
};
exports.errors = {};
exports.warnings = {};
exports.info = {};
_.each(errors, function (desc, code) {
exports.errors[code] = { code: code, desc: desc };
});
_.each(warnings, function (desc, code) {
exports.warnings[code] = { code: code, desc: desc };
});
_.each(info, function (desc, code) {
exports.info[code] = { code: code, desc: desc };
});

113
node_modules/jshint/src/platforms/rhino.js generated vendored Normal file
View File

@ -0,0 +1,113 @@
/*jshint boss: true, rhino: true, unused: true, undef: true, white: true, quotmark: double */
/*global JSHINT */
(function (args) {
"use strict";
var filenames = [];
var flags = {};
var optstr; // arg1=val1,arg2=val2,...
var predef; // global1=true,global2,global3,...
var opts = {};
var globals = {};
var retval = 0;
args.forEach(function (arg) {
if (arg.indexOf("--") === 0) {
// Configuration Flags might be boolean or will be split into name and value
if (arg.indexOf("=") > -1) {
var o = arg.split("=");
flags[o[0].slice(2)] = o[1];
} else {
flags[arg.slice(2)] = true;
}
return;
} else if (arg.indexOf("=") > -1) {
// usual rhino configuration, like "boss=true,browser=true"
if (!optstr) {
// First time it's the options.
optstr = arg;
} else {
predef = arg;
}
return;
}
if (optstr) {
predef = arg;
return;
}
filenames.push(arg);
});
if (filenames.length === 0) {
print("Usage: jshint.js file.js");
quit(1);
}
// If a config flag has been provided, try and load that
if ("config" in flags) {
var cfgFileContent;
try {
cfgFileContent = readFile(flags.config);
} catch (e) {
print("Could not read config file " + flags.config);
quit(1);
}
opts = JSON.parse(cfgFileContent);
}
if (optstr) {
optstr.split(",").forEach(function (arg) {
var o = arg.split("=");
if (o[0] === "indent") {
opts[o[0]] = parseInt(o[1], 10);
} else {
opts[o[0]] = (function (ov) {
switch (ov) {
case "true":
return true;
case "false":
return false;
default:
return ov;
}
}(o[1]));
}
});
}
globals = opts.globals || {};
delete(opts.globals);
if (predef) {
predef.split(",").forEach(function (arg) {
var global = arg.split("=");
globals[global[0]] = global[1] === "true" ? true : false;
});
}
filenames.forEach(function (name) {
var input = readFile(name);
if (!input) {
print("jshint: Couldn't open file " + name);
quit(1);
}
if (!JSHINT(input, opts, globals)) {
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 = 2;
}
});
quit(retval);
}(arguments));

34
node_modules/jshint/src/reg.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
/*
* Regular expressions. Some of these are stupidly long.
*/
/*jshint maxlen:1000 */
"use string";
// Unsafe comment or string (ax)
exports.unsafeString =
/@cc|<\/?|script|\]\s*\]|<\s*!|&lt/i;
// Unsafe characters that are silently deleted by one or more browsers (cx)
exports.unsafeChars =
/[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
// Characters in strings that need escaping (nx and nxg)
exports.needEsc =
/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/;
exports.needEscGlobal =
/[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
// Star slash (lx)
exports.starSlash = /\*\//;
// Identifier (ix)
exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/;
// JavaScript URL (jx)
exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
// Catches /* falls through */ comments (ft)
exports.fallsThrough = /^\s*\/\*\s*falls?\sthrough\s*\*\/\s*$/;

81
node_modules/jshint/src/reporters/checkstyle.js generated vendored Normal file
View File

@ -0,0 +1,81 @@
// Author: Boy Baukema
// http://github.com/relaxnow
module.exports =
{
reporter: function (results, data, opts)
{
"use strict";
var files = {},
out = [],
pairs = {
"&": "&amp;",
'"': "&quot;",
"'": "&apos;",
"<": "&lt;",
">": "&gt;"
},
fileName, i, issue, errorMessage;
opts = opts || {};
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) {
// Register the file
result.file = result.file.replace(/^\.\//, '');
if (!files[result.file]) {
files[result.file] = [];
}
// Create the error message
errorMessage = result.error.reason;
if (opts.verbose) {
errorMessage += ' (' + result.error.code + ')';
}
// Add the error
files[result.file].push({
severity: 'error',
line: result.error.line,
column: result.error.character,
message: errorMessage,
source: 'jshint.' + result.error.code
});
});
out.push("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
out.push("<checkstyle version=\"4.3\">");
for (fileName in files) {
if (files.hasOwnProperty(fileName)) {
out.push("\t<file name=\"" + fileName + "\">");
for (i = 0; i < files[fileName].length; i++) {
issue = files[fileName][i];
out.push(
"\t\t<error " +
"line=\"" + issue.line + "\" " +
"column=\"" + issue.column + "\" " +
"severity=\"" + issue.severity + "\" " +
"message=\"" + encode(issue.message) + "\" " +
"source=\"" + encode(issue.source) + "\" " +
"/>"
);
}
out.push("\t</file>");
}
}
out.push("</checkstyle>");
process.stdout.write(out.join("\n") + "\n");
}
};

34
node_modules/jshint/src/reporters/default.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
"use strict";
module.exports = {
reporter: function (results, data, opts) {
var len = results.length;
var str = '';
var prevfile;
opts = opts || {};
results.forEach(function (result) {
var file = result.file;
var error = result.error;
if (prevfile && prevfile !== file) {
str += "\n";
}
prevfile = file;
str += file + ': line ' + error.line + ', col ' +
error.character + ', ' + error.reason;
if (opts.verbose) {
str += ' (' + error.code + ')';
}
str += '\n';
});
if (str) {
process.stdout.write(str + "\n" + len + ' error' + ((len === 1) ? '' : 's') + "\n");
}
}
};

57
node_modules/jshint/src/reporters/jslint_xml.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
module.exports =
{
reporter: function (results)
{
"use strict";
var files = {},
out = [],
pairs = {
"&": "&amp;",
'"': "&quot;",
"'": "&apos;",
"<": "&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) +
(issue.code ? "\" severity=\"" + encode(issue.code.charAt(0)) : "") +
"\" />");
}
out.push("\t</file>");
}
out.push("</jslint>");
process.stdout.write(out.join("\n") + "\n");
}
};

52
node_modules/jshint/src/reporters/non_error.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
"use strict";
module.exports = {
reporter: function (results, data, opts) {
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;
// Add the error code if the --verbose option is set
if (opts.verbose) {
str += ' (' + error.code + ')';
}
str += '\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");
}
}
};

26
node_modules/jshint/src/state.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
"use strict";
var state = {
syntax: {},
reset: function () {
this.tokens = {
prev: null,
next: null,
curr: null
};
this.option = {};
this.ignored = {};
this.directive = {};
this.jsonMode = false;
this.jsonWarnings = [];
this.lines = [];
this.tab = "";
this.cache = {}; // Node.JS doesn't have Map. Sniff.
this.ignoreLinterErrors = false; // Blank out non-multi-line-commented
// lines when ignoring linter errors
}
};
exports.state = state;

171
node_modules/jshint/src/style.js generated vendored Normal file
View File

@ -0,0 +1,171 @@
"use strict";
exports.register = function (linter) {
// Check for properties named __proto__. This special property was
// deprecated and then re-introduced for ES6.
linter.on("Identifier", function style_scanProto(data) {
if (linter.getOption("proto")) {
return;
}
if (data.name === "__proto__") {
linter.warn("W103", {
line: data.line,
char: data.char,
data: [ data.name ]
});
}
});
// Check for properties named __iterator__. This is a special property
// available only in browsers with JavaScript 1.7 implementation.
linter.on("Identifier", function style_scanIterator(data) {
if (linter.getOption("iterator")) {
return;
}
if (data.name === "__iterator__") {
linter.warn("W104", {
line: data.line,
char: data.char,
data: [ data.name ]
});
}
});
// Check for dangling underscores.
linter.on("Identifier", function style_scanDangling(data) {
if (!linter.getOption("nomen")) {
return;
}
// Underscore.js
if (data.name === "_") {
return;
}
// In Node, __dirname and __filename should be ignored.
if (linter.getOption("node")) {
if (/^(__dirname|__filename)$/.test(data.name) && !data.isProperty) {
return;
}
}
if (/^(_+.*|.*_+)$/.test(data.name)) {
linter.warn("W105", {
line: data.line,
char: data.from,
data: [ "dangling '_'", data.name ]
});
}
});
// Check that all identifiers are using camelCase notation.
// Exceptions: names like MY_VAR and _myVar.
linter.on("Identifier", function style_scanCamelCase(data) {
if (!linter.getOption("camelcase")) {
return;
}
if (data.name.replace(/^_+|_+$/g, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) {
linter.warn("W106", {
line: data.line,
char: data.from,
data: [ data.name ]
});
}
});
// Enforce consistency in style of quoting.
linter.on("String", function style_scanQuotes(data) {
var quotmark = linter.getOption("quotmark");
var code;
if (!quotmark) {
return;
}
// If quotmark is set to 'single' warn about all double-quotes.
if (quotmark === "single" && data.quote !== "'") {
code = "W109";
}
// If quotmark is set to 'double' warn about all single-quotes.
if (quotmark === "double" && data.quote !== "\"") {
code = "W108";
}
// If quotmark is set to true, remember the first quotation style
// and then warn about all others.
if (quotmark === true) {
if (!linter.getCache("quotmark")) {
linter.setCache("quotmark", data.quote);
}
if (linter.getCache("quotmark") !== data.quote) {
code = "W110";
}
}
if (code) {
linter.warn(code, {
line: data.line,
char: data.char,
});
}
});
linter.on("Number", function style_scanNumbers(data) {
if (data.value.charAt(0) === ".") {
// Warn about a leading decimal point.
linter.warn("W008", {
line: data.line,
char: data.char,
data: [ data.value ]
});
}
if (data.value.substr(data.value.length - 1) === ".") {
// Warn about a trailing decimal point.
linter.warn("W047", {
line: data.line,
char: data.char,
data: [ data.value ]
});
}
if (/^00+/.test(data.value)) {
// Multiple leading zeroes.
linter.warn("W046", {
line: data.line,
char: data.char,
data: [ data.value ]
});
}
});
// Warn about script URLs.
linter.on("String", function style_scanJavaScriptURLs(data) {
var re = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i;
if (linter.getOption("scripturl")) {
return;
}
if (re.test(data.value)) {
linter.warn("W107", {
line: data.line,
char: data.char
});
}
});
};

589
node_modules/jshint/src/vars.js generated vendored Normal file
View File

@ -0,0 +1,589 @@
// jshint -W001
"use strict";
// Identifiers provided by the ECMAScript standard.
exports.reservedVars = {
arguments : false,
NaN : false
};
exports.ecmaIdentifiers = {
Array : false,
Boolean : false,
Date : false,
decodeURI : false,
decodeURIComponent : false,
encodeURI : false,
encodeURIComponent : false,
Error : false,
"eval" : false,
EvalError : false,
Function : false,
hasOwnProperty : false,
isFinite : false,
isNaN : false,
JSON : false,
Math : false,
Map : false,
Number : false,
Object : false,
parseInt : false,
parseFloat : false,
RangeError : false,
ReferenceError : false,
RegExp : false,
Set : false,
String : false,
SyntaxError : false,
TypeError : false,
URIError : false,
WeakMap : false
};
// Global variables commonly provided by a web browser environment.
exports.browser = {
Audio : false,
Blob : false,
addEventListener : false,
applicationCache : false,
atob : false,
blur : false,
btoa : false,
clearInterval : false,
clearTimeout : false,
close : false,
closed : false,
CustomEvent : false,
DOMParser : false,
defaultStatus : false,
document : false,
Element : false,
ElementTimeControl : false,
event : false,
FileReader : false,
FormData : false,
focus : false,
frames : false,
getComputedStyle : false,
HTMLElement : false,
HTMLAnchorElement : false,
HTMLBaseElement : false,
HTMLBlockquoteElement: false,
HTMLBodyElement : false,
HTMLBRElement : false,
HTMLButtonElement : false,
HTMLCanvasElement : false,
HTMLDirectoryElement : false,
HTMLDivElement : false,
HTMLDListElement : false,
HTMLFieldSetElement : false,
HTMLFontElement : false,
HTMLFormElement : false,
HTMLFrameElement : false,
HTMLFrameSetElement : false,
HTMLHeadElement : false,
HTMLHeadingElement : false,
HTMLHRElement : false,
HTMLHtmlElement : false,
HTMLIFrameElement : false,
HTMLImageElement : false,
HTMLInputElement : false,
HTMLIsIndexElement : false,
HTMLLabelElement : false,
HTMLLayerElement : false,
HTMLLegendElement : false,
HTMLLIElement : false,
HTMLLinkElement : false,
HTMLMapElement : false,
HTMLMenuElement : false,
HTMLMetaElement : false,
HTMLModElement : false,
HTMLObjectElement : false,
HTMLOListElement : false,
HTMLOptGroupElement : false,
HTMLOptionElement : false,
HTMLParagraphElement : false,
HTMLParamElement : false,
HTMLPreElement : false,
HTMLQuoteElement : false,
HTMLScriptElement : false,
HTMLSelectElement : false,
HTMLStyleElement : false,
HTMLTableCaptionElement: false,
HTMLTableCellElement : false,
HTMLTableColElement : false,
HTMLTableElement : false,
HTMLTableRowElement : false,
HTMLTableSectionElement: false,
HTMLTextAreaElement : false,
HTMLTitleElement : false,
HTMLUListElement : false,
HTMLVideoElement : false,
history : false,
Image : false,
length : false,
localStorage : false,
location : false,
MessageChannel : false,
MessageEvent : false,
MessagePort : false,
MouseEvent : false,
moveBy : false,
moveTo : false,
MutationObserver : false,
name : false,
Node : false,
NodeFilter : false,
navigator : false,
onbeforeunload : true,
onblur : true,
onerror : true,
onfocus : true,
onload : true,
onresize : true,
onunload : true,
open : false,
openDatabase : false,
opener : false,
Option : false,
parent : false,
print : false,
removeEventListener : false,
resizeBy : false,
resizeTo : false,
screen : false,
scroll : false,
scrollBy : false,
scrollTo : false,
sessionStorage : false,
setInterval : false,
setTimeout : false,
SharedWorker : false,
status : false,
SVGAElement : false,
SVGAltGlyphDefElement: false,
SVGAltGlyphElement : false,
SVGAltGlyphItemElement: false,
SVGAngle : false,
SVGAnimateColorElement: false,
SVGAnimateElement : false,
SVGAnimateMotionElement: false,
SVGAnimateTransformElement: false,
SVGAnimatedAngle : false,
SVGAnimatedBoolean : false,
SVGAnimatedEnumeration: false,
SVGAnimatedInteger : false,
SVGAnimatedLength : false,
SVGAnimatedLengthList: false,
SVGAnimatedNumber : false,
SVGAnimatedNumberList: false,
SVGAnimatedPathData : false,
SVGAnimatedPoints : false,
SVGAnimatedPreserveAspectRatio: false,
SVGAnimatedRect : false,
SVGAnimatedString : false,
SVGAnimatedTransformList: false,
SVGAnimationElement : false,
SVGCSSRule : false,
SVGCircleElement : false,
SVGClipPathElement : false,
SVGColor : false,
SVGColorProfileElement: false,
SVGColorProfileRule : false,
SVGComponentTransferFunctionElement: false,
SVGCursorElement : false,
SVGDefsElement : false,
SVGDescElement : false,
SVGDocument : false,
SVGElement : false,
SVGElementInstance : false,
SVGElementInstanceList: false,
SVGEllipseElement : false,
SVGExternalResourcesRequired: false,
SVGFEBlendElement : false,
SVGFEColorMatrixElement: false,
SVGFEComponentTransferElement: false,
SVGFECompositeElement: false,
SVGFEConvolveMatrixElement: false,
SVGFEDiffuseLightingElement: false,
SVGFEDisplacementMapElement: false,
SVGFEDistantLightElement: false,
SVGFEFloodElement : false,
SVGFEFuncAElement : false,
SVGFEFuncBElement : false,
SVGFEFuncGElement : false,
SVGFEFuncRElement : false,
SVGFEGaussianBlurElement: false,
SVGFEImageElement : false,
SVGFEMergeElement : false,
SVGFEMergeNodeElement: false,
SVGFEMorphologyElement: false,
SVGFEOffsetElement : false,
SVGFEPointLightElement: false,
SVGFESpecularLightingElement: false,
SVGFESpotLightElement: false,
SVGFETileElement : false,
SVGFETurbulenceElement: false,
SVGFilterElement : false,
SVGFilterPrimitiveStandardAttributes: false,
SVGFitToViewBox : false,
SVGFontElement : false,
SVGFontFaceElement : false,
SVGFontFaceFormatElement: false,
SVGFontFaceNameElement: false,
SVGFontFaceSrcElement: false,
SVGFontFaceUriElement: false,
SVGForeignObjectElement: false,
SVGGElement : false,
SVGGlyphElement : false,
SVGGlyphRefElement : false,
SVGGradientElement : false,
SVGHKernElement : false,
SVGICCColor : false,
SVGImageElement : false,
SVGLangSpace : false,
SVGLength : false,
SVGLengthList : false,
SVGLineElement : false,
SVGLinearGradientElement: false,
SVGLocatable : false,
SVGMPathElement : false,
SVGMarkerElement : false,
SVGMaskElement : false,
SVGMatrix : false,
SVGMetadataElement : false,
SVGMissingGlyphElement: false,
SVGNumber : false,
SVGNumberList : false,
SVGPaint : false,
SVGPathElement : false,
SVGPathSeg : false,
SVGPathSegArcAbs : false,
SVGPathSegArcRel : false,
SVGPathSegClosePath : false,
SVGPathSegCurvetoCubicAbs: false,
SVGPathSegCurvetoCubicRel: false,
SVGPathSegCurvetoCubicSmoothAbs: false,
SVGPathSegCurvetoCubicSmoothRel: false,
SVGPathSegCurvetoQuadraticAbs: false,
SVGPathSegCurvetoQuadraticRel: false,
SVGPathSegCurvetoQuadraticSmoothAbs: false,
SVGPathSegCurvetoQuadraticSmoothRel: false,
SVGPathSegLinetoAbs : false,
SVGPathSegLinetoHorizontalAbs: false,
SVGPathSegLinetoHorizontalRel: false,
SVGPathSegLinetoRel : false,
SVGPathSegLinetoVerticalAbs: false,
SVGPathSegLinetoVerticalRel: false,
SVGPathSegList : false,
SVGPathSegMovetoAbs : false,
SVGPathSegMovetoRel : false,
SVGPatternElement : false,
SVGPoint : false,
SVGPointList : false,
SVGPolygonElement : false,
SVGPolylineElement : false,
SVGPreserveAspectRatio: false,
SVGRadialGradientElement: false,
SVGRect : false,
SVGRectElement : false,
SVGRenderingIntent : false,
SVGSVGElement : false,
SVGScriptElement : false,
SVGSetElement : false,
SVGStopElement : false,
SVGStringList : false,
SVGStylable : false,
SVGStyleElement : false,
SVGSwitchElement : false,
SVGSymbolElement : false,
SVGTRefElement : false,
SVGTSpanElement : false,
SVGTests : false,
SVGTextContentElement: false,
SVGTextElement : false,
SVGTextPathElement : false,
SVGTextPositioningElement: false,
SVGTitleElement : false,
SVGTransform : false,
SVGTransformList : false,
SVGTransformable : false,
SVGURIReference : false,
SVGUnitTypes : false,
SVGUseElement : false,
SVGVKernElement : false,
SVGViewElement : false,
SVGViewSpec : false,
SVGZoomAndPan : false,
TimeEvent : false,
top : false,
URL : false,
WebSocket : false,
window : false,
Worker : false,
XMLHttpRequest : false,
XMLSerializer : false,
XPathEvaluator : false,
XPathException : false,
XPathExpression : false,
XPathNamespace : false,
XPathNSResolver : false,
XPathResult : false
};
exports.devel = {
alert : false,
confirm: false,
console: false,
Debug : false,
opera : false,
prompt : false
};
exports.worker = {
importScripts: true,
postMessage : true,
self : true
};
// Widely adopted global names that are not part of ECMAScript standard
exports.nonstandard = {
escape : false,
unescape: false
};
// Globals provided by popular JavaScript environments.
exports.couch = {
"require" : false,
respond : false,
getRow : false,
emit : false,
send : false,
start : false,
sum : false,
log : false,
exports : false,
module : false,
provides : false
};
exports.node = {
__filename : false,
__dirname : false,
Buffer : false,
console : false,
exports : true, // In Node it is ok to exports = module.exports = foo();
GLOBAL : false,
global : false,
module : false,
process : false,
require : false,
setTimeout : false,
clearTimeout : false,
setInterval : false,
clearInterval : false,
setImmediate : false, // v0.9.1+
clearImmediate: false // v0.9.1+
};
exports.phantom = {
phantom : true,
require : true,
WebPage : true,
console : true, // in examples, but undocumented
exports : true // v1.7+
};
exports.rhino = {
defineClass : false,
deserialize : false,
gc : false,
help : false,
importPackage: false,
"java" : false,
load : false,
loadClass : false,
print : false,
quit : false,
readFile : false,
readUrl : false,
runCommand : false,
seal : false,
serialize : false,
spawn : false,
sync : false,
toint32 : false,
version : false
};
exports.shelljs = {
target : false,
echo : false,
exit : false,
cd : false,
pwd : false,
ls : false,
find : false,
cp : false,
rm : false,
mv : false,
mkdir : false,
test : false,
cat : false,
sed : false,
grep : false,
which : false,
dirs : false,
pushd : false,
popd : false,
env : false,
exec : false,
chmod : false,
config : false,
error : false,
tempdir : false
};
exports.typed = {
ArrayBuffer : false,
ArrayBufferView : false,
DataView : false,
Float32Array : false,
Float64Array : false,
Int16Array : false,
Int32Array : false,
Int8Array : false,
Uint16Array : false,
Uint32Array : false,
Uint8Array : false,
Uint8ClampedArray : false
};
exports.wsh = {
ActiveXObject : true,
Enumerator : true,
GetObject : true,
ScriptEngine : true,
ScriptEngineBuildVersion : true,
ScriptEngineMajorVersion : true,
ScriptEngineMinorVersion : true,
VBArray : true,
WSH : true,
WScript : true,
XDomainRequest : true
};
// Globals provided by popular JavaScript libraries.
exports.dojo = {
dojo : false,
dijit : false,
dojox : false,
define : false,
"require": false
};
exports.jquery = {
"$" : false,
jQuery : false
};
exports.mootools = {
"$" : false,
"$$" : false,
Asset : false,
Browser : false,
Chain : false,
Class : false,
Color : false,
Cookie : false,
Core : false,
Document : false,
DomReady : false,
DOMEvent : false,
DOMReady : false,
Drag : false,
Element : false,
Elements : false,
Event : false,
Events : false,
Fx : false,
Group : false,
Hash : false,
HtmlTable : false,
Iframe : false,
IframeShim : false,
InputValidator: false,
instanceOf : false,
Keyboard : false,
Locale : false,
Mask : false,
MooTools : false,
Native : false,
Options : false,
OverText : false,
Request : false,
Scroller : false,
Slick : false,
Slider : false,
Sortables : false,
Spinner : false,
Swiff : false,
Tips : false,
Type : false,
typeOf : false,
URI : false,
Window : false
};
exports.prototypejs = {
"$" : false,
"$$" : false,
"$A" : false,
"$F" : false,
"$H" : false,
"$R" : false,
"$break" : false,
"$continue" : false,
"$w" : false,
Abstract : false,
Ajax : false,
Class : false,
Enumerable : false,
Element : false,
Event : false,
Field : false,
Form : false,
Hash : false,
Insertion : false,
ObjectRange : false,
PeriodicalExecuter: false,
Position : false,
Prototype : false,
Selector : false,
Template : false,
Toggle : false,
Try : false,
Autocompleter : false,
Builder : false,
Control : false,
Draggable : false,
Draggables : false,
Droppables : false,
Effect : false,
Sortable : false,
SortableObserver : false,
Sound : false,
Scriptaculous : false
};
exports.yui = {
YUI : false,
Y : false,
YUI_config: false
};

View File

@ -1,7 +1,7 @@
{
"name": "jsdoc",
"version": "3.3.0-dev",
"revision": "1383629688815",
"revision": "1384153751573",
"description": "An API documentation generator for JavaScript.",
"keywords": [ "documentation", "javascript" ],
"licenses": [
@ -25,7 +25,7 @@
"wrench": "1.3.9"
},
"devDependencies": {
"jshint": "0.9.1"
"jshint": "2.3.0"
},
"engines": {
"node": ">=0.10"

View File

@ -5,25 +5,33 @@ var path = require('jsdoc/path');
var config = JSON.parse( fs.readFileSync( path.join(env.dirname, '.jshintrc'), 'utf8' ) );
function jsHintCheck(filename, callback) {
var JSHINT = require('jshint').JSHINT;
var jsHintErrors;
fs.readFile(filename, 'utf8', function(err, data) {
if (err) {
callback(err);
} else {
JSHINT(data, config);
if (JSHINT.errors.length) {
jsHintErrors = filename + ' is not JSHint clean: ' + JSON.stringify(JSHINT.errors);
}
callback(null, jsHintErrors);
}
});
}
var jsHintCheck;
describe('jshint-clean', function() {
// Only run JSHint on Node.js, because a) we only need to lint everything once and b) the
// current version of JSHint is really slow on Rhino
if ( !require('jsdoc/util/runtime').isNode() ) {
return;
}
jsHintCheck = function(filename, callback) {
var JSHINT = require('jshint').JSHINT;
var jsHintErrors;
fs.readFile(filename, 'utf8', function(err, data) {
if (err) {
callback(err);
} else {
JSHINT(data, config);
if (JSHINT.errors.length) {
jsHintErrors = filename + ' is not JSHint clean: ' + JSON.stringify(JSHINT.errors);
}
callback(null, jsHintErrors);
}
});
};
it('should generate JSHint errors for bad code', function(done) {
var file = path.join(env.dirname, 'test', 'fixtures', 'jshint', 'badfile.js');
@ -69,4 +77,4 @@ describe('jshint-clean', function() {
done();
});
});
});
});