| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701 |
- "use strict";
- var _index = require("../index");
- var t = _interopRequireWildcard(_index);
- var _constants = require("../constants");
- var _index2 = require("./index");
- var _index3 = _interopRequireDefault(_index2);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
- (0, _index3.default)("ArrayExpression", {
- fields: {
- elements: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeOrValueType)("null", "Expression", "SpreadElement"))),
- default: []
- }
- },
- visitor: ["elements"],
- aliases: ["Expression"]
- });
- (0, _index3.default)("AssignmentExpression", {
- fields: {
- operator: {
- validate: (0, _index2.assertValueType)("string")
- },
- left: {
- validate: (0, _index2.assertNodeType)("LVal")
- },
- right: {
- validate: (0, _index2.assertNodeType)("Expression")
- }
- },
- builder: ["operator", "left", "right"],
- visitor: ["left", "right"],
- aliases: ["Expression"]
- });
- (0, _index3.default)("BinaryExpression", {
- builder: ["operator", "left", "right"],
- fields: {
- operator: {
- validate: _index2.assertOneOf.apply(undefined, _constants.BINARY_OPERATORS)
- },
- left: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- right: {
- validate: (0, _index2.assertNodeType)("Expression")
- }
- },
- visitor: ["left", "right"],
- aliases: ["Binary", "Expression"]
- });
- (0, _index3.default)("Directive", {
- visitor: ["value"],
- fields: {
- value: {
- validate: (0, _index2.assertNodeType)("DirectiveLiteral")
- }
- }
- });
- (0, _index3.default)("DirectiveLiteral", {
- builder: ["value"],
- fields: {
- value: {
- validate: (0, _index2.assertValueType)("string")
- }
- }
- });
- (0, _index3.default)("BlockStatement", {
- builder: ["body", "directives"],
- visitor: ["directives", "body"],
- fields: {
- directives: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Directive"))),
- default: []
- },
- body: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Statement")))
- }
- },
- aliases: ["Scopable", "BlockParent", "Block", "Statement"]
- });
- (0, _index3.default)("BreakStatement", {
- visitor: ["label"],
- fields: {
- label: {
- validate: (0, _index2.assertNodeType)("Identifier"),
- optional: true
- }
- },
- aliases: ["Statement", "Terminatorless", "CompletionStatement"]
- });
- (0, _index3.default)("CallExpression", {
- visitor: ["callee", "arguments"],
- fields: {
- callee: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- arguments: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Expression", "SpreadElement")))
- }
- },
- aliases: ["Expression"]
- });
- (0, _index3.default)("CatchClause", {
- visitor: ["param", "body"],
- fields: {
- param: {
- validate: (0, _index2.assertNodeType)("Identifier")
- },
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement")
- }
- },
- aliases: ["Scopable"]
- });
- (0, _index3.default)("ConditionalExpression", {
- visitor: ["test", "consequent", "alternate"],
- fields: {
- test: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- consequent: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- alternate: {
- validate: (0, _index2.assertNodeType)("Expression")
- }
- },
- aliases: ["Expression", "Conditional"]
- });
- (0, _index3.default)("ContinueStatement", {
- visitor: ["label"],
- fields: {
- label: {
- validate: (0, _index2.assertNodeType)("Identifier"),
- optional: true
- }
- },
- aliases: ["Statement", "Terminatorless", "CompletionStatement"]
- });
- (0, _index3.default)("DebuggerStatement", {
- aliases: ["Statement"]
- });
- (0, _index3.default)("DoWhileStatement", {
- visitor: ["test", "body"],
- fields: {
- test: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- body: {
- validate: (0, _index2.assertNodeType)("Statement")
- }
- },
- aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"]
- });
- (0, _index3.default)("EmptyStatement", {
- aliases: ["Statement"]
- });
- (0, _index3.default)("ExpressionStatement", {
- visitor: ["expression"],
- fields: {
- expression: {
- validate: (0, _index2.assertNodeType)("Expression")
- }
- },
- aliases: ["Statement", "ExpressionWrapper"]
- });
- (0, _index3.default)("File", {
- builder: ["program", "comments", "tokens"],
- visitor: ["program"],
- fields: {
- program: {
- validate: (0, _index2.assertNodeType)("Program")
- }
- }
- });
- (0, _index3.default)("ForInStatement", {
- visitor: ["left", "right", "body"],
- aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
- fields: {
- left: {
- validate: (0, _index2.assertNodeType)("VariableDeclaration", "LVal")
- },
- right: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- body: {
- validate: (0, _index2.assertNodeType)("Statement")
- }
- }
- });
- (0, _index3.default)("ForStatement", {
- visitor: ["init", "test", "update", "body"],
- aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop"],
- fields: {
- init: {
- validate: (0, _index2.assertNodeType)("VariableDeclaration", "Expression"),
- optional: true
- },
- test: {
- validate: (0, _index2.assertNodeType)("Expression"),
- optional: true
- },
- update: {
- validate: (0, _index2.assertNodeType)("Expression"),
- optional: true
- },
- body: {
- validate: (0, _index2.assertNodeType)("Statement")
- }
- }
- });
- (0, _index3.default)("FunctionDeclaration", {
- builder: ["id", "params", "body", "generator", "async"],
- visitor: ["id", "params", "body", "returnType", "typeParameters"],
- fields: {
- id: {
- validate: (0, _index2.assertNodeType)("Identifier")
- },
- params: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("LVal")))
- },
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement")
- },
- generator: {
- default: false,
- validate: (0, _index2.assertValueType)("boolean")
- },
- async: {
- default: false,
- validate: (0, _index2.assertValueType)("boolean")
- }
- },
- aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Statement", "Pureish", "Declaration"]
- });
- (0, _index3.default)("FunctionExpression", {
- inherits: "FunctionDeclaration",
- aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
- fields: {
- id: {
- validate: (0, _index2.assertNodeType)("Identifier"),
- optional: true
- },
- params: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("LVal")))
- },
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement")
- },
- generator: {
- default: false,
- validate: (0, _index2.assertValueType)("boolean")
- },
- async: {
- default: false,
- validate: (0, _index2.assertValueType)("boolean")
- }
- }
- });
- (0, _index3.default)("Identifier", {
- builder: ["name"],
- visitor: ["typeAnnotation"],
- aliases: ["Expression", "LVal"],
- fields: {
- name: {
- validate: function validate(node, key, val) {
- if (!t.isValidIdentifier(val)) {}
- }
- },
- decorators: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator")))
- }
- }
- });
- (0, _index3.default)("IfStatement", {
- visitor: ["test", "consequent", "alternate"],
- aliases: ["Statement", "Conditional"],
- fields: {
- test: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- consequent: {
- validate: (0, _index2.assertNodeType)("Statement")
- },
- alternate: {
- optional: true,
- validate: (0, _index2.assertNodeType)("Statement")
- }
- }
- });
- (0, _index3.default)("LabeledStatement", {
- visitor: ["label", "body"],
- aliases: ["Statement"],
- fields: {
- label: {
- validate: (0, _index2.assertNodeType)("Identifier")
- },
- body: {
- validate: (0, _index2.assertNodeType)("Statement")
- }
- }
- });
- (0, _index3.default)("StringLiteral", {
- builder: ["value"],
- fields: {
- value: {
- validate: (0, _index2.assertValueType)("string")
- }
- },
- aliases: ["Expression", "Pureish", "Literal", "Immutable"]
- });
- (0, _index3.default)("NumericLiteral", {
- builder: ["value"],
- deprecatedAlias: "NumberLiteral",
- fields: {
- value: {
- validate: (0, _index2.assertValueType)("number")
- }
- },
- aliases: ["Expression", "Pureish", "Literal", "Immutable"]
- });
- (0, _index3.default)("NullLiteral", {
- aliases: ["Expression", "Pureish", "Literal", "Immutable"]
- });
- (0, _index3.default)("BooleanLiteral", {
- builder: ["value"],
- fields: {
- value: {
- validate: (0, _index2.assertValueType)("boolean")
- }
- },
- aliases: ["Expression", "Pureish", "Literal", "Immutable"]
- });
- (0, _index3.default)("RegExpLiteral", {
- builder: ["pattern", "flags"],
- deprecatedAlias: "RegexLiteral",
- aliases: ["Expression", "Literal"],
- fields: {
- pattern: {
- validate: (0, _index2.assertValueType)("string")
- },
- flags: {
- validate: (0, _index2.assertValueType)("string"),
- default: ""
- }
- }
- });
- (0, _index3.default)("LogicalExpression", {
- builder: ["operator", "left", "right"],
- visitor: ["left", "right"],
- aliases: ["Binary", "Expression"],
- fields: {
- operator: {
- validate: _index2.assertOneOf.apply(undefined, _constants.LOGICAL_OPERATORS)
- },
- left: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- right: {
- validate: (0, _index2.assertNodeType)("Expression")
- }
- }
- });
- (0, _index3.default)("MemberExpression", {
- builder: ["object", "property", "computed"],
- visitor: ["object", "property"],
- aliases: ["Expression", "LVal"],
- fields: {
- object: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- property: {
- validate: function validate(node, key, val) {
- var expectedType = node.computed ? "Expression" : "Identifier";
- (0, _index2.assertNodeType)(expectedType)(node, key, val);
- }
- },
- computed: {
- default: false
- }
- }
- });
- (0, _index3.default)("NewExpression", {
- visitor: ["callee", "arguments"],
- aliases: ["Expression"],
- fields: {
- callee: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- arguments: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Expression", "SpreadElement")))
- }
- }
- });
- (0, _index3.default)("Program", {
- visitor: ["directives", "body"],
- builder: ["body", "directives"],
- fields: {
- directives: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Directive"))),
- default: []
- },
- body: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Statement")))
- }
- },
- aliases: ["Scopable", "BlockParent", "Block", "FunctionParent"]
- });
- (0, _index3.default)("ObjectExpression", {
- visitor: ["properties"],
- aliases: ["Expression"],
- fields: {
- properties: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("ObjectMethod", "ObjectProperty", "SpreadProperty")))
- }
- }
- });
- (0, _index3.default)("ObjectMethod", {
- builder: ["kind", "key", "params", "body", "computed"],
- fields: {
- kind: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("string"), (0, _index2.assertOneOf)("method", "get", "set")),
- default: "method"
- },
- computed: {
- validate: (0, _index2.assertValueType)("boolean"),
- default: false
- },
- key: {
- validate: function validate(node, key, val) {
- var expectedTypes = node.computed ? ["Expression"] : ["Identifier", "StringLiteral", "NumericLiteral"];
- _index2.assertNodeType.apply(undefined, expectedTypes)(node, key, val);
- }
- },
- decorators: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator")))
- },
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement")
- },
- generator: {
- default: false,
- validate: (0, _index2.assertValueType)("boolean")
- },
- async: {
- default: false,
- validate: (0, _index2.assertValueType)("boolean")
- }
- },
- visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
- aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"]
- });
- (0, _index3.default)("ObjectProperty", {
- builder: ["key", "value", "computed", "shorthand", "decorators"],
- fields: {
- computed: {
- validate: (0, _index2.assertValueType)("boolean"),
- default: false
- },
- key: {
- validate: function validate(node, key, val) {
- var expectedTypes = node.computed ? ["Expression"] : ["Identifier", "StringLiteral", "NumericLiteral"];
- _index2.assertNodeType.apply(undefined, expectedTypes)(node, key, val);
- }
- },
- value: {
- validate: (0, _index2.assertNodeType)("Expression", "Pattern", "RestElement")
- },
- shorthand: {
- validate: (0, _index2.assertValueType)("boolean"),
- default: false
- },
- decorators: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator"))),
- optional: true
- }
- },
- visitor: ["key", "value", "decorators"],
- aliases: ["UserWhitespacable", "Property", "ObjectMember"]
- });
- (0, _index3.default)("RestElement", {
- visitor: ["argument", "typeAnnotation"],
- aliases: ["LVal"],
- fields: {
- argument: {
- validate: (0, _index2.assertNodeType)("LVal")
- },
- decorators: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Decorator")))
- }
- }
- });
- (0, _index3.default)("ReturnStatement", {
- visitor: ["argument"],
- aliases: ["Statement", "Terminatorless", "CompletionStatement"],
- fields: {
- argument: {
- validate: (0, _index2.assertNodeType)("Expression"),
- optional: true
- }
- }
- });
- (0, _index3.default)("SequenceExpression", {
- visitor: ["expressions"],
- fields: {
- expressions: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Expression")))
- }
- },
- aliases: ["Expression"]
- });
- (0, _index3.default)("SwitchCase", {
- visitor: ["test", "consequent"],
- fields: {
- test: {
- validate: (0, _index2.assertNodeType)("Expression"),
- optional: true
- },
- consequent: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("Statement")))
- }
- }
- });
- (0, _index3.default)("SwitchStatement", {
- visitor: ["discriminant", "cases"],
- aliases: ["Statement", "BlockParent", "Scopable"],
- fields: {
- discriminant: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- cases: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("SwitchCase")))
- }
- }
- });
- (0, _index3.default)("ThisExpression", {
- aliases: ["Expression"]
- });
- (0, _index3.default)("ThrowStatement", {
- visitor: ["argument"],
- aliases: ["Statement", "Terminatorless", "CompletionStatement"],
- fields: {
- argument: {
- validate: (0, _index2.assertNodeType)("Expression")
- }
- }
- });
- (0, _index3.default)("TryStatement", {
- visitor: ["block", "handler", "finalizer"],
- aliases: ["Statement"],
- fields: {
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement")
- },
- handler: {
- optional: true,
- handler: (0, _index2.assertNodeType)("BlockStatement")
- },
- finalizer: {
- optional: true,
- validate: (0, _index2.assertNodeType)("BlockStatement")
- }
- }
- });
- (0, _index3.default)("UnaryExpression", {
- builder: ["operator", "argument", "prefix"],
- fields: {
- prefix: {
- default: true
- },
- argument: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- operator: {
- validate: _index2.assertOneOf.apply(undefined, _constants.UNARY_OPERATORS)
- }
- },
- visitor: ["argument"],
- aliases: ["UnaryLike", "Expression"]
- });
- (0, _index3.default)("UpdateExpression", {
- builder: ["operator", "argument", "prefix"],
- fields: {
- prefix: {
- default: false
- },
- argument: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- operator: {
- validate: _index2.assertOneOf.apply(undefined, _constants.UPDATE_OPERATORS)
- }
- },
- visitor: ["argument"],
- aliases: ["Expression"]
- });
- (0, _index3.default)("VariableDeclaration", {
- builder: ["kind", "declarations"],
- visitor: ["declarations"],
- aliases: ["Statement", "Declaration"],
- fields: {
- kind: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("string"), (0, _index2.assertOneOf)("var", "let", "const"))
- },
- declarations: {
- validate: (0, _index2.chain)((0, _index2.assertValueType)("array"), (0, _index2.assertEach)((0, _index2.assertNodeType)("VariableDeclarator")))
- }
- }
- });
- (0, _index3.default)("VariableDeclarator", {
- visitor: ["id", "init"],
- fields: {
- id: {
- validate: (0, _index2.assertNodeType)("LVal")
- },
- init: {
- optional: true,
- validate: (0, _index2.assertNodeType)("Expression")
- }
- }
- });
- (0, _index3.default)("WhileStatement", {
- visitor: ["test", "body"],
- aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"],
- fields: {
- test: {
- validate: (0, _index2.assertNodeType)("Expression")
- },
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement", "Statement")
- }
- }
- });
- (0, _index3.default)("WithStatement", {
- visitor: ["object", "body"],
- aliases: ["Statement"],
- fields: {
- object: {
- object: (0, _index2.assertNodeType)("Expression")
- },
- body: {
- validate: (0, _index2.assertNodeType)("BlockStatement", "Statement")
- }
- }
- });
|