diff options
Diffstat (limited to 'tools/eslint/node_modules/espree/lib')
-rw-r--r-- | tools/eslint/node_modules/espree/lib/ast-node-factory.js | 932 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/ast-node-types.js | 116 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/comment-attachment.js | 171 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/features.js | 111 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/messages.js | 99 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/string-map.js | 55 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/syntax.js | 187 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/token-info.js | 90 | ||||
-rw-r--r-- | tools/eslint/node_modules/espree/lib/xhtml-entities.js | 293 |
9 files changed, 2054 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/espree/lib/ast-node-factory.js b/tools/eslint/node_modules/espree/lib/ast-node-factory.js new file mode 100644 index 0000000000..56bdbcadbf --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/ast-node-factory.js @@ -0,0 +1,932 @@ +/** + * @fileoverview A factory for creating AST nodes + * @author Fred K. Schott + * @copyright 2014 Fred K. Schott. 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +var astNodeTypes = require("./ast-node-types"); + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + + /** + * Create an Array Expression ASTNode out of an array of elements + * @param {ASTNode[]} elements An array of ASTNode elements + * @returns {ASTNode} An ASTNode representing the entire array expression + */ + createArrayExpression: function(elements) { + return { + type: astNodeTypes.ArrayExpression, + elements: elements + }; + }, + + /** + * Create an Arrow Function Expression ASTNode + * @param {ASTNode} params The function arguments + * @param {ASTNode} body The function body + * @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, body, expression) { + return { + type: astNodeTypes.ArrowFunctionExpression, + id: null, + params: params, + body: body, + generator: false, + expression: expression + }; + }, + + /** + * Create an ASTNode representation of an assignment expression + * @param {ASTNode} operator The assignment operator + * @param {ASTNode} left The left operand + * @param {ASTNode} right The right operand + * @returns {ASTNode} An ASTNode representing the entire assignment expression + */ + createAssignmentExpression: function(operator, left, right) { + return { + type: astNodeTypes.AssignmentExpression, + operator: operator, + left: left, + right: right + }; + }, + + /** + * Create an ASTNode representation of an assignment pattern (default parameters) + * @param {ASTNode} left The left operand + * @param {ASTNode} right The right operand + * @returns {ASTNode} An ASTNode representing the entire assignment pattern + */ + createAssignmentPattern: function(left, right) { + return { + type: astNodeTypes.AssignmentPattern, + left: left, + right: right + }; + }, + + /** + * Create an ASTNode representation of a binary expression + * @param {ASTNode} operator The assignment operator + * @param {ASTNode} left The left operand + * @param {ASTNode} right The right operand + * @returns {ASTNode} An ASTNode representing the entire binary expression + */ + createBinaryExpression: function(operator, left, right) { + var type = (operator === "||" || operator === "&&") ? astNodeTypes.LogicalExpression : + astNodeTypes.BinaryExpression; + return { + type: type, + operator: operator, + left: left, + right: right + }; + }, + + /** + * Create an ASTNode representation of a block statement + * @param {ASTNode} body The block statement body + * @returns {ASTNode} An ASTNode representing the entire block statement + */ + createBlockStatement: function(body) { + return { + type: astNodeTypes.BlockStatement, + body: body + }; + }, + + /** + * Create an ASTNode representation of a break statement + * @param {ASTNode} label The break statement label + * @returns {ASTNode} An ASTNode representing the break statement + */ + createBreakStatement: function(label) { + return { + type: astNodeTypes.BreakStatement, + label: label + }; + }, + + /** + * Create an ASTNode representation of a call expression + * @param {ASTNode} callee The function being called + * @param {ASTNode[]} args An array of ASTNodes representing the function call arguments + * @returns {ASTNode} An ASTNode representing the entire call expression + */ + createCallExpression: function(callee, args) { + return { + type: astNodeTypes.CallExpression, + callee: callee, + "arguments": args + }; + }, + + /** + * Create an ASTNode representation of a catch clause/block + * @param {ASTNode} param Any catch clause exeption/conditional parameter information + * @param {ASTNode} body The catch block body + * @returns {ASTNode} An ASTNode representing the entire catch clause + */ + createCatchClause: function(param, body) { + return { + type: astNodeTypes.CatchClause, + param: param, + body: body + }; + }, + + /** + * Creates an ASTNode representation of a class body. + * @param {ASTNode} body The node representing the body of the class. + * @returns {ASTNode} An ASTNode representing the class body. + */ + createClassBody: function(body) { + return { + type: astNodeTypes.ClassBody, + body: body + }; + }, + + createClassExpression: function(id, superClass, body) { + return { + type: astNodeTypes.ClassExpression, + id: id, + superClass: superClass, + body: body + }; + }, + + createClassDeclaration: function(id, superClass, body) { + return { + type: astNodeTypes.ClassDeclaration, + id: id, + superClass: superClass, + body: body + }; + }, + + createMethodDefinition: function(propertyType, kind, key, value, computed) { + return { + type: astNodeTypes.MethodDefinition, + key: key, + value: value, + kind: kind, + "static": propertyType === "static", + computed: computed + }; + }, + + /** + * Create an ASTNode representation of a conditional expression + * @param {ASTNode} test The conditional to evaluate + * @param {ASTNode} consequent The code to be run if the test returns true + * @param {ASTNode} alternate The code to be run if the test returns false + * @returns {ASTNode} An ASTNode representing the entire conditional expression + */ + createConditionalExpression: function(test, consequent, alternate) { + return { + type: astNodeTypes.ConditionalExpression, + test: test, + consequent: consequent, + alternate: alternate + }; + }, + + /** + * Create an ASTNode representation of a continue statement + * @param {?ASTNode} label The optional continue label (null if not set) + * @returns {ASTNode} An ASTNode representing the continue statement + */ + createContinueStatement: function(label) { + return { + type: astNodeTypes.ContinueStatement, + label: label + }; + }, + + /** + * Create an ASTNode representation of a debugger statement + * @returns {ASTNode} An ASTNode representing the debugger statement + */ + createDebuggerStatement: function() { + return { + type: astNodeTypes.DebuggerStatement + }; + }, + + /** + * Create an ASTNode representation of an empty statement + * @returns {ASTNode} An ASTNode representing an empty statement + */ + createEmptyStatement: function() { + return { + type: astNodeTypes.EmptyStatement + }; + }, + + /** + * Create an ASTNode representation of an expression statement + * @param {ASTNode} expression The expression + * @returns {ASTNode} An ASTNode representing an expression statement + */ + createExpressionStatement: function(expression) { + return { + type: astNodeTypes.ExpressionStatement, + expression: expression + }; + }, + + /** + * Create an ASTNode representation of a while statement + * @param {ASTNode} test The while conditional + * @param {ASTNode} body The while loop body + * @returns {ASTNode} An ASTNode representing a while statement + */ + createWhileStatement: function(test, body) { + return { + type: astNodeTypes.WhileStatement, + test: test, + body: body + }; + }, + + /** + * Create an ASTNode representation of a do..while statement + * @param {ASTNode} test The do..while conditional + * @param {ASTNode} body The do..while loop body + * @returns {ASTNode} An ASTNode representing a do..while statement + */ + createDoWhileStatement: function(test, body) { + return { + type: astNodeTypes.DoWhileStatement, + body: body, + test: test + }; + }, + + /** + * Create an ASTNode representation of a for statement + * @param {ASTNode} init The initialization expression + * @param {ASTNode} test The conditional test expression + * @param {ASTNode} update The update expression + * @param {ASTNode} body The statement body + * @returns {ASTNode} An ASTNode representing a for statement + */ + createForStatement: function(init, test, update, body) { + return { + type: astNodeTypes.ForStatement, + init: init, + test: test, + update: update, + body: body + }; + }, + + /** + * Create an ASTNode representation of a for..in statement + * @param {ASTNode} left The left-side variable for the property name + * @param {ASTNode} right The right-side object + * @param {ASTNode} body The statement body + * @returns {ASTNode} An ASTNode representing a for..in statement + */ + createForInStatement: function(left, right, body) { + return { + type: astNodeTypes.ForInStatement, + left: left, + right: right, + body: body, + each: false + }; + }, + + /** + * Create an ASTNode representation of a for..of statement + * @param {ASTNode} left The left-side variable for the property value + * @param {ASTNode} right The right-side object + * @param {ASTNode} body The statement body + * @returns {ASTNode} An ASTNode representing a for..of statement + */ + createForOfStatement: function(left, right, body) { + return { + type: astNodeTypes.ForOfStatement, + left: left, + right: right, + body: body + }; + }, + + /** + * Create an ASTNode representation of a function declaration + * @param {ASTNode} id The function name + * @param {ASTNode} params The function arguments + * @param {ASTNode} body The function body + * @param {boolean} generator True if the function is a generator, false if not. + * @param {boolean} expression True if the 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 a function declaration + */ + createFunctionDeclaration: function (id, params, body, generator, expression) { + return { + type: astNodeTypes.FunctionDeclaration, + id: id, + params: params || [], + body: body, + generator: !!generator, + expression: !!expression + }; + }, + + /** + * Create an ASTNode representation of a function expression + * @param {ASTNode} id The function name + * @param {ASTNode} params The function arguments + * @param {ASTNode} body The function body + * @param {boolean} generator True if the function is a generator, false if not. + * @param {boolean} expression True if the function is created via an expression. + * @returns {ASTNode} An ASTNode representing a function declaration + */ + createFunctionExpression: function (id, params, body, generator, expression) { + return { + type: astNodeTypes.FunctionExpression, + id: id, + params: params || [], + body: body, + generator: !!generator, + expression: !!expression + }; + }, + + /** + * Create an ASTNode representation of an identifier + * @param {ASTNode} name The identifier name + * @returns {ASTNode} An ASTNode representing an identifier + */ + createIdentifier: function(name) { + return { + type: astNodeTypes.Identifier, + name: name + }; + }, + + /** + * Create an ASTNode representation of an if statement + * @param {ASTNode} test The if conditional expression + * @param {ASTNode} consequent The consequent if statement to run + * @param {ASTNode} alternate the "else" alternate statement + * @returns {ASTNode} An ASTNode representing an if statement + */ + createIfStatement: function(test, consequent, alternate) { + return { + type: astNodeTypes.IfStatement, + test: test, + consequent: consequent, + alternate: alternate + }; + }, + + /** + * Create an ASTNode representation of a labeled statement + * @param {ASTNode} label The statement label + * @param {ASTNode} body The labeled statement body + * @returns {ASTNode} An ASTNode representing a labeled statement + */ + createLabeledStatement: function(label, body) { + return { + type: astNodeTypes.LabeledStatement, + label: label, + body: body + }; + }, + + /** + * Create an ASTNode literal from the source code + * @param {ASTNode} token The ASTNode token + * @param {string} source The source code to get the literal from + * @returns {ASTNode} An ASTNode representing the new literal + */ + createLiteralFromSource: function(token, source) { + var node = { + type: astNodeTypes.Literal, + value: token.value, + raw: source.slice(token.range[0], token.range[1]) + }; + + // regular expressions have regex properties + if (token.regex) { + node.regex = token.regex; + } + + return node; + }, + + /** + * Create an ASTNode template element + * @param {Object} value Data on the element value + * @param {string} value.raw The raw template string + * @param {string} value.cooked The processed template string + * @param {boolean} tail True if this is the final element in a template string + * @returns {ASTNode} An ASTNode representing the template string element + */ + createTemplateElement: function(value, tail) { + return { + type: astNodeTypes.TemplateElement, + value: value, + tail: tail + }; + }, + + /** + * Create an ASTNode template literal + * @param {ASTNode[]} quasis An array of the template string elements + * @param {ASTNode[]} expressions An array of the template string expressions + * @returns {ASTNode} An ASTNode representing the template string + */ + createTemplateLiteral: function(quasis, expressions) { + return { + type: astNodeTypes.TemplateLiteral, + quasis: quasis, + expressions: expressions + }; + }, + + /** + * 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 + * @param {ASTNode} tag The tag expression + * @param {ASTNode} quasi A TemplateLiteral ASTNode representing + * the template string itself. + * @returns {ASTNode} An ASTNode representing the tagged template + */ + createTaggedTemplateExpression: function(tag, quasi) { + return { + type: astNodeTypes.TaggedTemplateExpression, + tag: tag, + quasi: quasi + }; + }, + + /** + * Create an ASTNode representation of a member expression + * @param {string} accessor The member access method (bracket or period) + * @param {ASTNode} object The object being referenced + * @param {ASTNode} property The object-property being referenced + * @returns {ASTNode} An ASTNode representing a member expression + */ + createMemberExpression: function(accessor, object, property) { + return { + type: astNodeTypes.MemberExpression, + computed: accessor === "[", + object: object, + property: property + }; + }, + + /** + * Create an ASTNode representation of a new expression + * @param {ASTNode} callee The constructor for the new object type + * @param {ASTNode} args The arguments passed to the constructor + * @returns {ASTNode} An ASTNode representing a new expression + */ + createNewExpression: function(callee, args) { + return { + type: astNodeTypes.NewExpression, + callee: callee, + "arguments": args + }; + }, + + /** + * Create an ASTNode representation of a new object expression + * @param {ASTNode[]} properties An array of ASTNodes that represent all object + * properties and associated values + * @returns {ASTNode} An ASTNode representing a new object expression + */ + createObjectExpression: function(properties) { + return { + type: astNodeTypes.ObjectExpression, + properties: properties + }; + }, + + /** + * Create an ASTNode representation of a postfix expression + * @param {string} operator The postfix operator ("++", "--", etc.) + * @param {ASTNode} argument The operator argument + * @returns {ASTNode} An ASTNode representing a postfix expression + */ + createPostfixExpression: function(operator, argument) { + return { + type: astNodeTypes.UpdateExpression, + operator: operator, + argument: argument, + prefix: false + }; + }, + + /** + * Create an ASTNode representation of an entire program + * @param {ASTNode} body The program body + * @param {string} sourceType Either "module" or "script". + * @returns {ASTNode} An ASTNode representing an entire program + */ + createProgram: function(body, sourceType) { + return { + type: astNodeTypes.Program, + body: body, + sourceType: sourceType + }; + }, + + /** + * Create an ASTNode representation of an object property + * @param {string} kind The type of property represented ("get", "set", etc.) + * @param {ASTNode} key The property key + * @param {ASTNode} value The new property value + * @param {boolean} method True if the property is also a method (value is a function) + * @param {boolean} shorthand True if the property is shorthand + * @param {boolean} computed True if the property value has been computed + * @returns {ASTNode} An ASTNode representing an object property + */ + createProperty: function(kind, key, value, method, shorthand, computed) { + return { + type: astNodeTypes.Property, + key: key, + value: value, + kind: kind, + method: method, + shorthand: shorthand, + computed: computed + }; + }, + + /** + * Create an ASTNode representation of a rest element + * @param {ASTNode} argument The rest argument + * @returns {ASTNode} An ASTNode representing a rest element + */ + createRestElement: function (argument) { + return { + type: astNodeTypes.RestElement, + argument: argument + }; + }, + + /** + * Create an ASTNode representation of a return statement + * @param {?ASTNode} argument The return argument, null if no argument is provided + * @returns {ASTNode} An ASTNode representing a return statement + */ + createReturnStatement: function(argument) { + return { + type: astNodeTypes.ReturnStatement, + argument: argument + }; + }, + + /** + * Create an ASTNode representation of a sequence of expressions + * @param {ASTNode[]} expressions An array containing each expression, in order + * @returns {ASTNode} An ASTNode representing a sequence of expressions + */ + createSequenceExpression: function(expressions) { + return { + type: astNodeTypes.SequenceExpression, + expressions: expressions + }; + }, + + /** + * Create an ASTNode representation of super + * @returns {ASTNode} An ASTNode representing super + */ + createSuper: function() { + return { + type: astNodeTypes.Super + }; + }, + + /** + * Create an ASTNode representation of a switch case statement + * @param {ASTNode} test The case value to test against the switch value + * @param {ASTNode} consequent The consequent case statement + * @returns {ASTNode} An ASTNode representing a switch case + */ + createSwitchCase: function(test, consequent) { + return { + type: astNodeTypes.SwitchCase, + test: test, + consequent: consequent + }; + }, + + /** + * Create an ASTNode representation of a switch statement + * @param {ASTNode} discriminant An expression to test against each case value + * @param {ASTNode[]} cases An array of switch case statements + * @returns {ASTNode} An ASTNode representing a switch statement + */ + createSwitchStatement: function(discriminant, cases) { + return { + type: astNodeTypes.SwitchStatement, + discriminant: discriminant, + cases: cases + }; + }, + + /** + * Create an ASTNode representation of a this statement + * @returns {ASTNode} An ASTNode representing a this statement + */ + createThisExpression: function() { + return { + type: astNodeTypes.ThisExpression + }; + }, + + /** + * Create an ASTNode representation of a throw statement + * @param {ASTNode} argument The argument to throw + * @returns {ASTNode} An ASTNode representing a throw statement + */ + createThrowStatement: function(argument) { + return { + type: astNodeTypes.ThrowStatement, + argument: argument + }; + }, + + /** + * Create an ASTNode representation of a try statement + * @param {ASTNode} block The try block + * @param {ASTNode} handler A catch handler + * @param {?ASTNode} finalizer The final code block to run after the try/catch has run + * @returns {ASTNode} An ASTNode representing a try statement + */ + createTryStatement: function(block, handler, finalizer) { + return { + type: astNodeTypes.TryStatement, + block: block, + handler: handler, + finalizer: finalizer + }; + }, + + /** + * Create an ASTNode representation of a unary expression + * @param {string} operator The unary operator + * @param {ASTNode} argument The unary operand + * @returns {ASTNode} An ASTNode representing a unary expression + */ + createUnaryExpression: function(operator, argument) { + if (operator === "++" || operator === "--") { + return { + type: astNodeTypes.UpdateExpression, + operator: operator, + argument: argument, + prefix: true + }; + } + return { + type: astNodeTypes.UnaryExpression, + operator: operator, + argument: argument, + prefix: true + }; + }, + + /** + * Create an ASTNode representation of a variable declaration + * @param {ASTNode[]} declarations An array of variable declarations + * @param {string} kind The kind of variable created ("var", "let", etc.) + * @returns {ASTNode} An ASTNode representing a variable declaration + */ + createVariableDeclaration: function(declarations, kind) { + return { + type: astNodeTypes.VariableDeclaration, + declarations: declarations, + kind: kind + }; + }, + + /** + * Create an ASTNode representation of a variable declarator + * @param {ASTNode} id The variable ID + * @param {ASTNode} init The variable's initial value + * @returns {ASTNode} An ASTNode representing a variable declarator + */ + createVariableDeclarator: function(id, init) { + return { + type: astNodeTypes.VariableDeclarator, + id: id, + init: init + }; + }, + + /** + * Create an ASTNode representation of a with statement + * @param {ASTNode} object The with statement object expression + * @param {ASTNode} body The with statement body + * @returns {ASTNode} An ASTNode representing a with statement + */ + createWithStatement: function(object, body) { + return { + type: astNodeTypes.WithStatement, + object: object, + body: body + }; + }, + + createYieldExpression: function(argument, delegate) { + return { + type: astNodeTypes.YieldExpression, + argument: argument || null, + delegate: delegate + }; + }, + + createJSXAttribute: function(name, value) { + return { + type: astNodeTypes.JSXAttribute, + name: name, + value: value || null + }; + }, + + createJSXSpreadAttribute: function(argument) { + return { + type: astNodeTypes.JSXSpreadAttribute, + argument: argument + }; + }, + + createJSXIdentifier: function(name) { + return { + type: astNodeTypes.JSXIdentifier, + name: name + }; + }, + + createJSXNamespacedName: function(namespace, name) { + return { + type: astNodeTypes.JSXNamespacedName, + namespace: namespace, + name: name + }; + }, + + createJSXMemberExpression: function(object, property) { + return { + type: astNodeTypes.JSXMemberExpression, + object: object, + property: property + }; + }, + + createJSXElement: function(openingElement, closingElement, children) { + return { + type: astNodeTypes.JSXElement, + openingElement: openingElement, + closingElement: closingElement, + children: children + }; + }, + + createJSXEmptyExpression: function() { + return { + type: astNodeTypes.JSXEmptyExpression + }; + }, + + createJSXExpressionContainer: function(expression) { + return { + type: astNodeTypes.JSXExpressionContainer, + expression: expression + }; + }, + + createJSXOpeningElement: function(name, attributes, selfClosing) { + return { + type: astNodeTypes.JSXOpeningElement, + name: name, + selfClosing: selfClosing, + attributes: attributes + }; + }, + + createJSXClosingElement: function(name) { + return { + type: astNodeTypes.JSXClosingElement, + name: name + }; + }, + + createExportSpecifier: function(local, exported) { + return { + type: astNodeTypes.ExportSpecifier, + exported: exported || local, + local: local + }; + }, + + createImportDefaultSpecifier: function(local) { + return { + type: astNodeTypes.ImportDefaultSpecifier, + local: local + }; + }, + + createImportNamespaceSpecifier: function(local) { + return { + type: astNodeTypes.ImportNamespaceSpecifier, + local: local + }; + }, + + createExportNamedDeclaration: function(declaration, specifiers, source) { + return { + type: astNodeTypes.ExportNamedDeclaration, + declaration: declaration, + specifiers: specifiers, + source: source + }; + }, + + createExportDefaultDeclaration: function(declaration) { + return { + type: astNodeTypes.ExportDefaultDeclaration, + declaration: declaration + }; + }, + + createExportAllDeclaration: function(source) { + return { + type: astNodeTypes.ExportAllDeclaration, + source: source + }; + }, + + createImportSpecifier: function(local, imported) { + return { + type: astNodeTypes.ImportSpecifier, + local: local || imported, + imported: imported + }; + }, + + createImportDeclaration: function(specifiers, source) { + return { + type: astNodeTypes.ImportDeclaration, + specifiers: specifiers, + source: source + }; + } + +}; diff --git a/tools/eslint/node_modules/espree/lib/ast-node-types.js b/tools/eslint/node_modules/espree/lib/ast-node-types.js new file mode 100644 index 0000000000..5d14b7f443 --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/ast-node-types.js @@ -0,0 +1,116 @@ +/** + * @fileoverview The AST node types produced by the parser. + * @author Nicholas C. Zakas + * @copyright 2014 Nicholas C. Zakas. 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + AssignmentExpression: "AssignmentExpression", + AssignmentPattern: "AssignmentPattern", + ArrayExpression: "ArrayExpression", + ArrayPattern: "ArrayPattern", + ArrowFunctionExpression: "ArrowFunctionExpression", + BlockStatement: "BlockStatement", + BinaryExpression: "BinaryExpression", + BreakStatement: "BreakStatement", + CallExpression: "CallExpression", + CatchClause: "CatchClause", + ClassBody: "ClassBody", + ClassDeclaration: "ClassDeclaration", + ClassExpression: "ClassExpression", + ConditionalExpression: "ConditionalExpression", + ContinueStatement: "ContinueStatement", + DoWhileStatement: "DoWhileStatement", + DebuggerStatement: "DebuggerStatement", + EmptyStatement: "EmptyStatement", + ExpressionStatement: "ExpressionStatement", + ForStatement: "ForStatement", + ForInStatement: "ForInStatement", + ForOfStatement: "ForOfStatement", + FunctionDeclaration: "FunctionDeclaration", + FunctionExpression: "FunctionExpression", + Identifier: "Identifier", + IfStatement: "IfStatement", + Literal: "Literal", + LabeledStatement: "LabeledStatement", + LogicalExpression: "LogicalExpression", + MemberExpression: "MemberExpression", + MethodDefinition: "MethodDefinition", + NewExpression: "NewExpression", + ObjectExpression: "ObjectExpression", + ObjectPattern: "ObjectPattern", + Program: "Program", + Property: "Property", + RestElement: "RestElement", + ReturnStatement: "ReturnStatement", + SequenceExpression: "SequenceExpression", + SpreadElement: "SpreadElement", + Super: "Super", + SwitchCase: "SwitchCase", + SwitchStatement: "SwitchStatement", + TaggedTemplateExpression: "TaggedTemplateExpression", + TemplateElement: "TemplateElement", + TemplateLiteral: "TemplateLiteral", + ThisExpression: "ThisExpression", + ThrowStatement: "ThrowStatement", + TryStatement: "TryStatement", + UnaryExpression: "UnaryExpression", + UpdateExpression: "UpdateExpression", + VariableDeclaration: "VariableDeclaration", + VariableDeclarator: "VariableDeclarator", + WhileStatement: "WhileStatement", + WithStatement: "WithStatement", + YieldExpression: "YieldExpression", + JSXIdentifier: "JSXIdentifier", + JSXNamespacedName: "JSXNamespacedName", + JSXMemberExpression: "JSXMemberExpression", + JSXEmptyExpression: "JSXEmptyExpression", + JSXExpressionContainer: "JSXExpressionContainer", + JSXElement: "JSXElement", + JSXClosingElement: "JSXClosingElement", + JSXOpeningElement: "JSXOpeningElement", + JSXAttribute: "JSXAttribute", + JSXSpreadAttribute: "JSXSpreadAttribute", + JSXText: "JSXText", + ExportDefaultDeclaration: "ExportDefaultDeclaration", + ExportNamedDeclaration: "ExportNamedDeclaration", + ExportAllDeclaration: "ExportAllDeclaration", + ExportSpecifier: "ExportSpecifier", + ImportDeclaration: "ImportDeclaration", + ImportSpecifier: "ImportSpecifier", + ImportDefaultSpecifier: "ImportDefaultSpecifier", + ImportNamespaceSpecifier: "ImportNamespaceSpecifier" +}; diff --git a/tools/eslint/node_modules/espree/lib/comment-attachment.js b/tools/eslint/node_modules/espree/lib/comment-attachment.js new file mode 100644 index 0000000000..3618bb3bf0 --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/comment-attachment.js @@ -0,0 +1,171 @@ +/** + * @fileoverview Attaches comments to the AST. + * @author Nicholas C. Zakas + * @copyright 2015 Nicholas C. Zakas. 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +var astNodeTypes = require("./ast-node-types"); + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + +var extra = { + trailingComments: [], + leadingComments: [], + bottomRightStack: [] + }; + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + + reset: function() { + extra.trailingComments = []; + extra.leadingComments = []; + extra.bottomRightStack = []; + }, + + addComment: function(comment) { + extra.trailingComments.push(comment); + extra.leadingComments.push(comment); + }, + + processComment: function(node) { + var lastChild, + trailingComments, + i; + + if (node.type === astNodeTypes.Program) { + if (node.body.length > 0) { + return; + } + } + + if (extra.trailingComments.length > 0) { + + /* + * If the first comment in trailingComments comes after the + * current node, then we're good - all comments in the array will + * come after the node and so it's safe to add then as official + * trailingComments. + */ + if (extra.trailingComments[0].range[0] >= node.range[1]) { + trailingComments = extra.trailingComments; + extra.trailingComments = []; + } else { + + /* + * Otherwise, if the first comment doesn't come after the + * current node, that means we have a mix of leading and trailing + * comments in the array and that leadingComments contains the + * same items as trailingComments. Reset trailingComments to + * zero items and we'll handle this by evaluating leadingComments + * later. + */ + extra.trailingComments.length = 0; + } + } else { + if (extra.bottomRightStack.length > 0 && + extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments && + extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments[0].range[0] >= node.range[1]) { + trailingComments = extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments; + delete extra.bottomRightStack[extra.bottomRightStack.length - 1].trailingComments; + } + } + + // Eating the stack. + while (extra.bottomRightStack.length > 0 && extra.bottomRightStack[extra.bottomRightStack.length - 1].range[0] >= node.range[0]) { + lastChild = extra.bottomRightStack.pop(); + } + + if (lastChild) { + if (lastChild.leadingComments && lastChild.leadingComments[lastChild.leadingComments.length - 1].range[1] <= node.range[0]) { + node.leadingComments = lastChild.leadingComments; + delete lastChild.leadingComments; + } + } else if (extra.leadingComments.length > 0) { + + if (extra.leadingComments[extra.leadingComments.length - 1].range[1] <= node.range[0]) { + node.leadingComments = extra.leadingComments; + extra.leadingComments = []; + } else { + + // https://github.com/eslint/espree/issues/2 + + /* + * In special cases, such as return (without a value) and + * debugger, all comments will end up as leadingComments and + * will otherwise be eliminated. This extra step runs when the + * bottomRightStack is empty and there are comments left + * in leadingComments. + * + * This loop figures out the stopping point between the actual + * leading and trailing comments by finding the location of the + * first comment that comes after the given node. + */ + for (i = 0; i < extra.leadingComments.length; i++) { + if (extra.leadingComments[i].range[1] > node.range[0]) { + break; + } + } + + /* + * Split the array based on the location of the first comment + * that comes after the node. Keep in mind that this could + * result in an empty array, and if so, the array must be + * deleted. + */ + node.leadingComments = extra.leadingComments.slice(0, i); + if (node.leadingComments.length === 0) { + delete node.leadingComments; + } + + /* + * Similarly, trailing comments are attached later. The variable + * must be reset to null if there are no trailing comments. + */ + trailingComments = extra.leadingComments.slice(i); + if (trailingComments.length === 0) { + trailingComments = null; + } + } + } + + if (trailingComments) { + node.trailingComments = trailingComments; + } + + extra.bottomRightStack.push(node); + } + +}; diff --git a/tools/eslint/node_modules/espree/lib/features.js b/tools/eslint/node_modules/espree/lib/features.js new file mode 100644 index 0000000000..c33274a441 --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/features.js @@ -0,0 +1,111 @@ +/** + * @fileoverview The list of feature flags supported by the parser and their default + * settings. + * @author Nicholas C. Zakas + * @copyright 2015 Fred K. Schott. All rights reserved. + * @copyright 2014 Nicholas C. Zakas. All rights reserved. + * + * 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + + // enable parsing of arrow functions + arrowFunctions: false, + + // enable parsing of let and const + blockBindings: true, + + // enable parsing of destructured arrays and objects + destructuring: false, + + // enable parsing of regex u flag + regexUFlag: false, + + // enable parsing of regex y flag + regexYFlag: false, + + // enable parsing of template strings + templateStrings: false, + + // enable parsing binary literals + binaryLiterals: false, + + // enable parsing ES6 octal literals + octalLiterals: false, + + // enable parsing unicode code point escape sequences + unicodeCodePointEscapes: true, + + // enable parsing of default parameters + defaultParams: false, + + // enable parsing of rest parameters + restParams: false, + + // enable parsing of for-of statements + forOf: false, + + // enable parsing computed object literal properties + objectLiteralComputedProperties: false, + + // enable parsing of shorthand object literal methods + objectLiteralShorthandMethods: false, + + // enable parsing of shorthand object literal properties + objectLiteralShorthandProperties: false, + + // Allow duplicate object literal properties (except '__proto__') + objectLiteralDuplicateProperties: false, + + // enable parsing of generators/yield + generators: false, + + // support the spread operator + spread: false, + + // enable super in functions + superInFunctions: false, + + // enable parsing of classes + classes: false, + + // enable parsing of modules + modules: false, + + // React JSX parsing + jsx: false, + + // allow return statement in global scope + globalReturn: false +}; diff --git a/tools/eslint/node_modules/espree/lib/messages.js b/tools/eslint/node_modules/espree/lib/messages.js new file mode 100644 index 0000000000..b0f324f87d --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/messages.js @@ -0,0 +1,99 @@ +/** + * @fileoverview Error messages returned by the parser. + * @author Nicholas C. Zakas + * @copyright 2014 Nicholas C. Zakas. 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +// error messages should be identical to V8 where possible +module.exports = { + UnexpectedToken: "Unexpected token %0", + UnexpectedNumber: "Unexpected number", + UnexpectedString: "Unexpected string", + UnexpectedIdentifier: "Unexpected identifier", + UnexpectedReserved: "Unexpected reserved word", + UnexpectedTemplate: "Unexpected quasi %0", + UnexpectedEOS: "Unexpected end of input", + NewlineAfterThrow: "Illegal newline after throw", + InvalidRegExp: "Invalid regular expression", + InvalidRegExpFlag: "Invalid regular expression flag", + UnterminatedRegExp: "Invalid regular expression: missing /", + InvalidLHSInAssignment: "Invalid left-hand side in assignment", + InvalidLHSInFormalsList: "Invalid left-hand side in formals list", + InvalidLHSInForIn: "Invalid left-hand side in for-in", + MultipleDefaultsInSwitch: "More than one default clause in switch statement", + NoCatchOrFinally: "Missing catch or finally after try", + NoUnintializedConst: "Const must be initialized", + UnknownLabel: "Undefined label '%0'", + Redeclaration: "%0 '%1' has already been declared", + IllegalContinue: "Illegal continue statement", + IllegalBreak: "Illegal break statement", + IllegalReturn: "Illegal return statement", + IllegalYield: "Illegal yield expression", + IllegalSpread: "Illegal spread element", + StrictModeWith: "Strict mode code may not include a with statement", + StrictCatchVariable: "Catch variable 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", + StrictParamDupe: "Strict mode function may not have duplicate parameter names", + TemplateOctalLiteral: "Octal literals are not allowed in template strings.", + ParameterAfterRestParameter: "Rest parameter must be last formal parameter", + 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", + StrictOctalLiteral: "Octal literals are not allowed in strict mode.", + StrictDelete: "Delete of an unqualified identifier in strict mode.", + StrictDuplicateProperty: "Duplicate data property in object literal not allowed in strict mode", + DuplicatePrototypeProperty: "Duplicate '__proto__' property in object literal are not allowed", + ConstructorSpecialMethod: "Class constructor may not be an accessor", + DuplicateConstructor: "A class may only have one constructor", + StaticPrototype: "Classes may not have static property named prototype", + AccessorDataProperty: "Object literal may not have data and accessor property with the same name", + AccessorGetSet: "Object literal may not have multiple get/set accessors with the same name", + StrictLHSAssignment: "Assignment to eval or arguments is not allowed in strict mode", + StrictLHSPostfix: "Postfix increment/decrement may not have eval or arguments operand in strict mode", + StrictLHSPrefix: "Prefix increment/decrement may not have eval or arguments operand in strict mode", + StrictReservedWord: "Use of future reserved word in strict mode", + InvalidJSXAttributeValue: "JSX value should be either an expression or a quoted JSX text", + ExpectedJSXClosingTag: "Expected corresponding JSX closing tag for %0", + AdjacentJSXElements: "Adjacent JSX elements must be wrapped in an enclosing tag", + MissingFromClause: "Missing from clause", + NoAsAfterImportNamespace: "Missing as after import *", + InvalidModuleSpecifier: "Invalid module specifier", + IllegalImportDeclaration: "Illegal import declaration", + IllegalExportDeclaration: "Illegal export declaration" +}; diff --git a/tools/eslint/node_modules/espree/lib/string-map.js b/tools/eslint/node_modules/espree/lib/string-map.js new file mode 100644 index 0000000000..97c87032f2 --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/string-map.js @@ -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; diff --git a/tools/eslint/node_modules/espree/lib/syntax.js b/tools/eslint/node_modules/espree/lib/syntax.js new file mode 100644 index 0000000000..7cad1afc89 --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/syntax.js @@ -0,0 +1,187 @@ +/** + * @fileoverview Various syntax/pattern checks for parsing. + * @author Nicholas C. Zakas + * @copyright 2014 Nicholas C. Zakas. All rights reserved. + * @copyright 2011-2013 Ariya Hidayat <ariya.hidayat@gmail.com> + * @copyright 2012-2013 Mathias Bynens <mathias@qiwi.be> + * + * 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + +// See also tools/generate-identifier-regex.js. +var Regex = { + NonAsciiIdentifierStart: new RegExp("[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]"), + NonAsciiIdentifierPart: new RegExp("[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0\u08A2-\u08AC\u08E4-\u08FE\u0900-\u0963\u0966-\u096F\u0971-\u0977\u0979-\u097F\u0981-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58\u0C59\u0C60-\u0C63\u0C66-\u0C6F\u0C82\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D02\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D60-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191C\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1D00-\u1DE6\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA697\uA69F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7B\uAA80-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE26\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]"), + LeadingZeros: new RegExp("^0+(?!$)") +}; + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + + Regex: Regex, + + isDecimalDigit: function(ch) { + return (ch >= 48 && ch <= 57); // 0..9 + }, + + isHexDigit: function(ch) { + return "0123456789abcdefABCDEF".indexOf(ch) >= 0; + }, + + isOctalDigit: function(ch) { + return "01234567".indexOf(ch) >= 0; + }, + + // 7.2 White Space + + isWhiteSpace: function(ch) { + return (ch === 0x20) || (ch === 0x09) || (ch === 0x0B) || (ch === 0x0C) || (ch === 0xA0) || + (ch >= 0x1680 && [0x1680, 0x180E, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(ch) >= 0); + }, + + // 7.3 Line Terminators + + isLineTerminator: function(ch) { + return (ch === 0x0A) || (ch === 0x0D) || (ch === 0x2028) || (ch === 0x2029); + }, + + // 7.6 Identifier Names and Identifiers + + isIdentifierStart: function(ch) { + return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) + (ch >= 0x41 && ch <= 0x5A) || // A..Z + (ch >= 0x61 && ch <= 0x7A) || // a..z + (ch === 0x5C) || // \ (backslash) + ((ch >= 0x80) && Regex.NonAsciiIdentifierStart.test(String.fromCharCode(ch))); + }, + + isIdentifierPart: function(ch) { + return (ch === 0x24) || (ch === 0x5F) || // $ (dollar) and _ (underscore) + (ch >= 0x41 && ch <= 0x5A) || // A..Z + (ch >= 0x61 && ch <= 0x7A) || // a..z + (ch >= 0x30 && ch <= 0x39) || // 0..9 + (ch === 0x5C) || // \ (backslash) + ((ch >= 0x80) && Regex.NonAsciiIdentifierPart.test(String.fromCharCode(ch))); + }, + + // 7.6.1.2 Future Reserved Words + + isFutureReservedWord: function(id) { + switch (id) { + case "class": + case "enum": + case "export": + case "extends": + case "import": + case "super": + return true; + default: + return false; + } + }, + + isStrictModeReservedWord: function(id) { + switch (id) { + case "implements": + case "interface": + case "package": + case "private": + case "protected": + case "public": + case "static": + case "yield": + case "let": + return true; + default: + return false; + } + }, + + isRestrictedWord: function(id) { + return id === "eval" || id === "arguments"; + }, + + // 7.6.1.1 Keywords + + isKeyword: function(id, strict, ecmaFeatures) { + + if (strict && this.isStrictModeReservedWord(id)) { + return true; + } + + // "const" is specialized as Keyword in V8. + // "yield" and "let" are for compatiblity with SpiderMonkey and ES.next. + // Some others are from future reserved words. + + switch (id.length) { + case 2: + return (id === "if") || (id === "in") || (id === "do"); + case 3: + return (id === "var") || (id === "for") || (id === "new") || + (id === "try") || (id === "let"); + case 4: + return (id === "this") || (id === "else") || (id === "case") || + (id === "void") || (id === "with") || (id === "enum"); + case 5: + return (id === "while") || (id === "break") || (id === "catch") || + (id === "throw") || (id === "const") || (!ecmaFeatures.generators && id === "yield") || + (id === "class") || (id === "super"); + case 6: + return (id === "return") || (id === "typeof") || (id === "delete") || + (id === "switch") || (id === "export") || (id === "import"); + case 7: + return (id === "default") || (id === "finally") || (id === "extends"); + case 8: + return (id === "function") || (id === "continue") || (id === "debugger"); + case 10: + return (id === "instanceof"); + default: + return false; + } + }, + + isJSXIdentifierStart: function(ch) { + // exclude backslash (\) + return (ch !== 92) && this.isIdentifierStart(ch); + }, + + isJSXIdentifierPart: function(ch) { + // exclude backslash (\) and add hyphen (-) + return (ch !== 92) && (ch === 45 || this.isIdentifierPart(ch)); + } + + +}; diff --git a/tools/eslint/node_modules/espree/lib/token-info.js b/tools/eslint/node_modules/espree/lib/token-info.js new file mode 100644 index 0000000000..ea7676477c --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/token-info.js @@ -0,0 +1,90 @@ +/** + * @fileoverview Contains token information. + * @author Nicholas C. Zakas + * @copyright 2014 Nicholas C. Zakas. All rights reserved. + * @copyright 2013 Thaddee Tyl <thaddee.tyl@gmail.com> + * @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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Private +//------------------------------------------------------------------------------ + +var Token = { + BooleanLiteral: 1, + EOF: 2, + Identifier: 3, + Keyword: 4, + NullLiteral: 5, + NumericLiteral: 6, + Punctuator: 7, + StringLiteral: 8, + RegularExpression: 9, + Template: 10, + JSXIdentifier: 11, + JSXText: 12 +}; + +var TokenName = {}; +TokenName[Token.BooleanLiteral] = "Boolean"; +TokenName[Token.EOF] = "<end>"; +TokenName[Token.Identifier] = "Identifier"; +TokenName[Token.Keyword] = "Keyword"; +TokenName[Token.NullLiteral] = "Null"; +TokenName[Token.NumericLiteral] = "Numeric"; +TokenName[Token.Punctuator] = "Punctuator"; +TokenName[Token.StringLiteral] = "String"; +TokenName[Token.RegularExpression] = "RegularExpression"; +TokenName[Token.Template] = "Template"; +TokenName[Token.JSXIdentifier] = "JSXIdentifier"; +TokenName[Token.JSXText] = "JSXText"; + +// A function following one of those tokens is an expression. +var FnExprTokens = ["(", "{", "[", "in", "typeof", "instanceof", "new", + "return", "case", "delete", "throw", "void", + // assignment operators + "=", "+=", "-=", "*=", "/=", "%=", "<<=", ">>=", ">>>=", + "&=", "|=", "^=", ",", + // binary/unary operators + "+", "-", "*", "/", "%", "++", "--", "<<", ">>", ">>>", "&", + "|", "^", "!", "~", "&&", "||", "?", ":", "===", "==", ">=", + "<=", "<", ">", "!=", "!=="]; + + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + Token: Token, + TokenName: TokenName, + FnExprTokens: FnExprTokens +}; diff --git a/tools/eslint/node_modules/espree/lib/xhtml-entities.js b/tools/eslint/node_modules/espree/lib/xhtml-entities.js new file mode 100644 index 0000000000..1ceda1ecab --- /dev/null +++ b/tools/eslint/node_modules/espree/lib/xhtml-entities.js @@ -0,0 +1,293 @@ +/** + * @fileoverview The list of XHTML entities that are valid in JSX. + * @author Nicholas C. Zakas + * @copyright 2014 Nicholas C. Zakas. All rights reserved. + * + * 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"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +// None! + +//------------------------------------------------------------------------------ +// Public +//------------------------------------------------------------------------------ + +module.exports = { + quot: "\u0022", + amp: "&", + apos: "\u0027", + lt: "<", + gt: ">", + nbsp: "\u00A0", + iexcl: "\u00A1", + cent: "\u00A2", + pound: "\u00A3", + curren: "\u00A4", + yen: "\u00A5", + brvbar: "\u00A6", + sect: "\u00A7", + uml: "\u00A8", + copy: "\u00A9", + ordf: "\u00AA", + laquo: "\u00AB", + not: "\u00AC", + shy: "\u00AD", + reg: "\u00AE", + macr: "\u00AF", + deg: "\u00B0", + plusmn: "\u00B1", + sup2: "\u00B2", + sup3: "\u00B3", + acute: "\u00B4", + micro: "\u00B5", + para: "\u00B6", + middot: "\u00B7", + cedil: "\u00B8", + sup1: "\u00B9", + ordm: "\u00BA", + raquo: "\u00BB", + frac14: "\u00BC", + frac12: "\u00BD", + frac34: "\u00BE", + iquest: "\u00BF", + Agrave: "\u00C0", + Aacute: "\u00C1", + Acirc: "\u00C2", + Atilde: "\u00C3", + Auml: "\u00C4", + Aring: "\u00C5", + AElig: "\u00C6", + Ccedil: "\u00C7", + Egrave: "\u00C8", + Eacute: "\u00C9", + Ecirc: "\u00CA", + Euml: "\u00CB", + Igrave: "\u00CC", + Iacute: "\u00CD", + Icirc: "\u00CE", + Iuml: "\u00CF", + ETH: "\u00D0", + Ntilde: "\u00D1", + Ograve: "\u00D2", + Oacute: "\u00D3", + Ocirc: "\u00D4", + Otilde: "\u00D5", + Ouml: "\u00D6", + times: "\u00D7", + Oslash: "\u00D8", + Ugrave: "\u00D9", + Uacute: "\u00DA", + Ucirc: "\u00DB", + Uuml: "\u00DC", + Yacute: "\u00DD", + THORN: "\u00DE", + szlig: "\u00DF", + agrave: "\u00E0", + aacute: "\u00E1", + acirc: "\u00E2", + atilde: "\u00E3", + auml: "\u00E4", + aring: "\u00E5", + aelig: "\u00E6", + ccedil: "\u00E7", + egrave: "\u00E8", + eacute: "\u00E9", + ecirc: "\u00EA", + euml: "\u00EB", + igrave: "\u00EC", + iacute: "\u00ED", + icirc: "\u00EE", + iuml: "\u00EF", + eth: "\u00F0", + ntilde: "\u00F1", + ograve: "\u00F2", + oacute: "\u00F3", + ocirc: "\u00F4", + otilde: "\u00F5", + ouml: "\u00F6", + divide: "\u00F7", + oslash: "\u00F8", + ugrave: "\u00F9", + uacute: "\u00FA", + ucirc: "\u00FB", + uuml: "\u00FC", + yacute: "\u00FD", + thorn: "\u00FE", + yuml: "\u00FF", + OElig: "\u0152", + oelig: "\u0153", + Scaron: "\u0160", + scaron: "\u0161", + Yuml: "\u0178", + fnof: "\u0192", + circ: "\u02C6", + tilde: "\u02DC", + Alpha: "\u0391", + Beta: "\u0392", + Gamma: "\u0393", + Delta: "\u0394", + Epsilon: "\u0395", + Zeta: "\u0396", + Eta: "\u0397", + Theta: "\u0398", + Iota: "\u0399", + Kappa: "\u039A", + Lambda: "\u039B", + Mu: "\u039C", + Nu: "\u039D", + Xi: "\u039E", + Omicron: "\u039F", + Pi: "\u03A0", + Rho: "\u03A1", + Sigma: "\u03A3", + Tau: "\u03A4", + Upsilon: "\u03A5", + Phi: "\u03A6", + Chi: "\u03A7", + Psi: "\u03A8", + Omega: "\u03A9", + alpha: "\u03B1", + beta: "\u03B2", + gamma: "\u03B3", + delta: "\u03B4", + epsilon: "\u03B5", + zeta: "\u03B6", + eta: "\u03B7", + theta: "\u03B8", + iota: "\u03B9", + kappa: "\u03BA", + lambda: "\u03BB", + mu: "\u03BC", + nu: "\u03BD", + xi: "\u03BE", + omicron: "\u03BF", + pi: "\u03C0", + rho: "\u03C1", + sigmaf: "\u03C2", + sigma: "\u03C3", + tau: "\u03C4", + upsilon: "\u03C5", + phi: "\u03C6", + chi: "\u03C7", + psi: "\u03C8", + omega: "\u03C9", + thetasym: "\u03D1", + upsih: "\u03D2", + piv: "\u03D6", + ensp: "\u2002", + emsp: "\u2003", + thinsp: "\u2009", + zwnj: "\u200C", + zwj: "\u200D", + lrm: "\u200E", + rlm: "\u200F", + ndash: "\u2013", + mdash: "\u2014", + lsquo: "\u2018", + rsquo: "\u2019", + sbquo: "\u201A", + ldquo: "\u201C", + rdquo: "\u201D", + bdquo: "\u201E", + dagger: "\u2020", + Dagger: "\u2021", + bull: "\u2022", + hellip: "\u2026", + permil: "\u2030", + prime: "\u2032", + Prime: "\u2033", + lsaquo: "\u2039", + rsaquo: "\u203A", + oline: "\u203E", + frasl: "\u2044", + euro: "\u20AC", + image: "\u2111", + weierp: "\u2118", + real: "\u211C", + trade: "\u2122", + alefsym: "\u2135", + larr: "\u2190", + uarr: "\u2191", + rarr: "\u2192", + darr: "\u2193", + harr: "\u2194", + crarr: "\u21B5", + lArr: "\u21D0", + uArr: "\u21D1", + rArr: "\u21D2", + dArr: "\u21D3", + hArr: "\u21D4", + forall: "\u2200", + part: "\u2202", + exist: "\u2203", + empty: "\u2205", + nabla: "\u2207", + isin: "\u2208", + notin: "\u2209", + ni: "\u220B", + prod: "\u220F", + sum: "\u2211", + minus: "\u2212", + lowast: "\u2217", + radic: "\u221A", + prop: "\u221D", + infin: "\u221E", + ang: "\u2220", + and: "\u2227", + or: "\u2228", + cap: "\u2229", + cup: "\u222A", + "int": "\u222B", + there4: "\u2234", + sim: "\u223C", + cong: "\u2245", + asymp: "\u2248", + ne: "\u2260", + equiv: "\u2261", + le: "\u2264", + ge: "\u2265", + sub: "\u2282", + sup: "\u2283", + nsub: "\u2284", + sube: "\u2286", + supe: "\u2287", + oplus: "\u2295", + otimes: "\u2297", + perp: "\u22A5", + sdot: "\u22C5", + lceil: "\u2308", + rceil: "\u2309", + lfloor: "\u230A", + rfloor: "\u230B", + lang: "\u2329", + rang: "\u232A", + loz: "\u25CA", + spades: "\u2660", + clubs: "\u2663", + hearts: "\u2665", + diams: "\u2666" +}; |