update Espree and LICENSE file

This commit is contained in:
Jeff Williams 2015-02-26 14:59:05 -08:00
parent 65f307322a
commit cc4ffc762e
11 changed files with 731 additions and 231 deletions

View File

@ -116,9 +116,9 @@ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com>.
The source code for escape-string-regexp is available at: The source code for escape-string-regexp is available at:
https://github.com/sindresorhus/escape-string-regexp https://github.com/sindresorhus/escape-string-regexp
## Esprima ## ## Espree ##
Esprima is distributed under the BSD 2-clause license: Espree is distributed under the BSD 2-clause license:
> Redistribution and use in source and binary forms, with or without > Redistribution and use in source and binary forms, with or without
> modification, are permitted provided that the following conditions are met: > modification, are permitted provided that the following conditions are met:
@ -140,10 +140,10 @@ Esprima is distributed under the BSD 2-clause license:
> (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF > (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
> THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. > THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Copyright (c) 2011-2013 Ariya Hidayat and other Esprima contributors. Copyright (c) 2011-2015 by the Espree contributors.
The source code for Esprima is available at: The source code for Esprima is available at:
https://github.com/ariya/esprima https://github.com/eslint/espree
## events ## ## events ##

View File

@ -53,6 +53,35 @@ var acceptsLeadingComments = (function() {
return accepts; return accepts;
})(); })();
var espreeOpts = {
comment: true,
loc: true,
range: true,
tokens: true,
ecmaFeatures: {
arrowFunctions: true,
binaryLiterals: true,
blockBindings: true,
defaultParams: true,
destructuring: true,
forOf: true,
generators: true,
globalReturn: true,
jsx: false,
objectLiteralComputedProperties: true,
objectLiteralDuplicateProperties: true,
objectLiteralShorthandMethods: true,
objectLiteralShorthandProperties: true,
octalLiterals: true,
regexUFlag: true,
regexYFlag: true,
restParams: true,
spread: true,
superInFunctions: true,
templateStrings: true,
unicodeCodePointEscapes: true
}
};
// TODO: docs // TODO: docs
function canAcceptComment(node) { function canAcceptComment(node) {
@ -119,7 +148,7 @@ function scrubComments(comments) {
// TODO: docs // TODO: docs
var AstBuilder = exports.AstBuilder = function() {}; var AstBuilder = exports.AstBuilder = function() {};
function parse(source, filename, espreeOpts) { function parse(source, filename) {
var ast; var ast;
try { try {
@ -134,33 +163,7 @@ function parse(source, filename, espreeOpts) {
// TODO: docs // TODO: docs
AstBuilder.prototype.build = function(source, filename) { AstBuilder.prototype.build = function(source, filename) {
var ast; var ast = parse(source, filename);
var espreeOpts = {
comment: true,
loc: true,
range: true,
tokens: true,
ecmaFeatures: {
binaryLiterals: true,
blockBindings: true,
defaultParams: true,
forOf: true,
generators: true,
jsx: false,
objectLiteralComputedProperties: true,
objectLiteralDuplicateProperties: true,
objectLiteralShorthandMethods: true,
objectLiteralShorthandProperties: true,
octalLiterals: true,
regexUFlag: true,
regexYFlag: true,
templateStrings: true,
unicodeCodePointEscapes: true
}
};
ast = parse(source, filename, espreeOpts);
if (ast) { if (ast) {
this._postProcess(filename, ast); this._postProcess(filename, ast);

648
node_modules/espree/espree.js generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -51,6 +51,30 @@ module.exports = {
}; };
}, },
/**
* Create an Arrow Function Expression ASTNode
* @param {ASTNode} params The function arguments
* @param {ASTNode} defaults Any default arguments
* @param {ASTNode} body The function body
* @param {ASTNode} rest The rest parameter
* @param {boolean} expression True if the arrow function is created via an expression.
* Always false for declarations, but kept here to be in sync with
* FunctionExpression objects.
* @returns {ASTNode} An ASTNode representing the entire arrow function expression
*/
createArrowFunctionExpression: function (params, defaults, body, rest, expression) {
return {
type: astNodeTypes.ArrowFunctionExpression,
id: null,
params: params,
defaults: defaults,
body: body,
rest: rest,
generator: false,
expression: expression
};
},
/** /**
* Create an ASTNode representation of an assignment expression * Create an ASTNode representation of an assignment expression
* @param {ASTNode} operator The assignment operator * @param {ASTNode} operator The assignment operator
@ -419,6 +443,18 @@ module.exports = {
}; };
}, },
/**
* Create an ASTNode representation of a spread element
* @param {ASTNode} argument The array being spread
* @returns {ASTNode} An ASTNode representing a spread element
*/
createSpreadElement: function (argument) {
return {
type: astNodeTypes.SpreadElement,
argument: argument
};
},
/** /**
* Create an ASTNode tagged template expression * Create an ASTNode tagged template expression
* @param {ASTNode} tag The tag expression * @param {ASTNode} tag The tag expression

View File

@ -40,6 +40,8 @@
module.exports = { module.exports = {
AssignmentExpression: "AssignmentExpression", AssignmentExpression: "AssignmentExpression",
ArrayExpression: "ArrayExpression", ArrayExpression: "ArrayExpression",
ArrayPattern: "ArrayPattern",
ArrowFunctionExpression: "ArrowFunctionExpression",
BlockStatement: "BlockStatement", BlockStatement: "BlockStatement",
BinaryExpression: "BinaryExpression", BinaryExpression: "BinaryExpression",
BreakStatement: "BreakStatement", BreakStatement: "BreakStatement",
@ -64,10 +66,12 @@ module.exports = {
MemberExpression: "MemberExpression", MemberExpression: "MemberExpression",
NewExpression: "NewExpression", NewExpression: "NewExpression",
ObjectExpression: "ObjectExpression", ObjectExpression: "ObjectExpression",
ObjectPattern: "ObjectPattern",
Program: "Program", Program: "Program",
Property: "Property", Property: "Property",
ReturnStatement: "ReturnStatement", ReturnStatement: "ReturnStatement",
SequenceExpression: "SequenceExpression", SequenceExpression: "SequenceExpression",
SpreadElement: "SpreadElement",
SwitchCase: "SwitchCase", SwitchCase: "SwitchCase",
SwitchStatement: "SwitchStatement", SwitchStatement: "SwitchStatement",
TaggedTemplateExpression: "TaggedTemplateExpression", TaggedTemplateExpression: "TaggedTemplateExpression",

20
node_modules/espree/lib/features.js generated vendored
View File

@ -40,9 +40,15 @@
module.exports = { module.exports = {
// enable parsing of arrow functions
arrowFunctions: false,
// enable parsing of let and const // enable parsing of let and const
blockBindings: true, blockBindings: true,
// enable parsing of destructured arrays and objects
destructuring: false,
// enable parsing of regex u flag // enable parsing of regex u flag
regexUFlag: false, regexUFlag: false,
@ -64,6 +70,9 @@ module.exports = {
// enable parsing of default parameters // enable parsing of default parameters
defaultParams: false, defaultParams: false,
// enable parsing of rest parameters
restParams: false,
// enable parsing of for-of statements // enable parsing of for-of statements
forOf: false, forOf: false,
@ -82,6 +91,15 @@ module.exports = {
// enable parsing of generators/yield // enable parsing of generators/yield
generators: false, generators: false,
// support the spread operator
spread: false,
// enable super in functions
superInFunctions: false,
// React JSX parsing // React JSX parsing
jsx: false jsx: false,
// allow return statement in global scope
globalReturn: false
}; };

View File

@ -51,20 +51,28 @@ module.exports = {
InvalidRegExpFlag: "Invalid regular expression flag", InvalidRegExpFlag: "Invalid regular expression flag",
UnterminatedRegExp: "Invalid regular expression: missing /", UnterminatedRegExp: "Invalid regular expression: missing /",
InvalidLHSInAssignment: "Invalid left-hand side in assignment", InvalidLHSInAssignment: "Invalid left-hand side in assignment",
InvalidLHSInFormalsList: "Invalid left-hand side in formals list",
InvalidLHSInForIn: "Invalid left-hand side in for-in", InvalidLHSInForIn: "Invalid left-hand side in for-in",
MultipleDefaultsInSwitch: "More than one default clause in switch statement", MultipleDefaultsInSwitch: "More than one default clause in switch statement",
NoCatchOrFinally: "Missing catch or finally after try", NoCatchOrFinally: "Missing catch or finally after try",
NoUnintializedConst: "Const must be initialized",
UnknownLabel: "Undefined label '%0'", UnknownLabel: "Undefined label '%0'",
Redeclaration: "%0 '%1' has already been declared", Redeclaration: "%0 '%1' has already been declared",
IllegalContinue: "Illegal continue statement", IllegalContinue: "Illegal continue statement",
IllegalBreak: "Illegal break statement", IllegalBreak: "Illegal break statement",
IllegalReturn: "Illegal return statement", IllegalReturn: "Illegal return statement",
IllegalYield: "Illegal yield expression", IllegalYield: "Illegal yield expression",
IllegalSpread: "Illegal spread element",
StrictModeWith: "Strict mode code may not include a with statement", StrictModeWith: "Strict mode code may not include a with statement",
StrictCatchVariable: "Catch variable may not be eval or arguments in strict mode", StrictCatchVariable: "Catch variable may not be eval or arguments in strict mode",
StrictVarName: "Variable name may not be eval or arguments in strict mode", StrictVarName: "Variable name may not be eval or arguments in strict mode",
StrictParamName: "Parameter name eval or arguments is not allowed in strict mode", StrictParamName: "Parameter name eval or arguments is not allowed in strict mode",
StrictParamDupe: "Strict mode function may not have duplicate parameter names", StrictParamDupe: "Strict mode function may not have duplicate parameter names",
ParameterAfterRestParameter: "Rest parameter must be final parameter of an argument list",
DefaultRestParameter: "Rest parameter can not have a default value",
ElementAfterSpreadElement: "Spread must be the final element of an element list",
ObjectPatternAsRestParameter: "Invalid rest parameter",
ObjectPatternAsSpread: "Invalid spread argument",
StrictFunctionName: "Function name may not be eval or arguments in strict mode", StrictFunctionName: "Function name may not be eval or arguments in strict mode",
StrictOctalLiteral: "Octal literals are not allowed in strict mode.", StrictOctalLiteral: "Octal literals are not allowed in strict mode.",
StrictDelete: "Delete of an unqualified identifier in strict mode.", StrictDelete: "Delete of an unqualified identifier in strict mode.",

55
node_modules/espree/lib/string-map.js generated vendored Normal file
View File

@ -0,0 +1,55 @@
/**
* @fileoverview A simple map that helps avoid collisions on the Object prototype.
* @author Jamund Ferguson
* @copyright 2015 Jamund Ferguson. All rights reserved.
* @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
"use strict";
function StringMap() {
this.$data = {};
}
StringMap.prototype.get = function (key) {
key = "$" + key;
return this.$data[key];
};
StringMap.prototype.set = function (key, value) {
key = "$" + key;
this.$data[key] = value;
return this;
};
StringMap.prototype.has = function (key) {
key = "$" + key;
return Object.prototype.hasOwnProperty.call(this.$data, key);
};
StringMap.prototype.delete = function (key) {
key = "$" + key;
return delete this.$data[key];
};
module.exports = StringMap;

12
node_modules/espree/package.json generated vendored

File diff suppressed because one or more lines are too long

View File

@ -16,7 +16,7 @@
"async": "~0.9.0", "async": "~0.9.0",
"catharsis": "~0.8.6", "catharsis": "~0.8.6",
"escape-string-regexp": "~1.0.2", "escape-string-regexp": "~1.0.2",
"espree": "1.7.1", "espree": "~1.9.1",
"js2xmlparser": "~0.1.7", "js2xmlparser": "~0.1.7",
"marked": "~0.3.2", "marked": "~0.3.2",
"requizzle": "~0.2.0", "requizzle": "~0.2.0",

View File

@ -36,7 +36,7 @@ describe('jsdoc/src/astbuilder', function() {
it('should log (not throw) an error when a file cannot be parsed', function() { it('should log (not throw) an error when a file cannot be parsed', function() {
function parse() { function parse() {
builder.build('if (true) { return; }', 'bad.js'); builder.build('qwerty!!!!!', 'bad.js');
} }
expect(parse).not.toThrow(); expect(parse).not.toThrow();