Run new lint rules (#5413)
This commit is contained in:
@@ -1,28 +1,28 @@
|
||||
/* eslint max-len: "off" */
|
||||
|
||||
export const STATEMENT_OR_BLOCK_KEYS = ["consequent", "body", "alternate"];
|
||||
export const FLATTENABLE_KEYS = ["body", "expressions"];
|
||||
export const FOR_INIT_KEYS = ["left", "init"];
|
||||
export const COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"];
|
||||
export const FLATTENABLE_KEYS = ["body", "expressions"];
|
||||
export const FOR_INIT_KEYS = ["left", "init"];
|
||||
export const COMMENT_KEYS = ["leadingComments", "trailingComments", "innerComments"];
|
||||
|
||||
export const LOGICAL_OPERATORS = ["||", "&&"];
|
||||
export const UPDATE_OPERATORS = ["++", "--"];
|
||||
export const UPDATE_OPERATORS = ["++", "--"];
|
||||
|
||||
export const BOOLEAN_NUMBER_BINARY_OPERATORS = [">", "<", ">=", "<="];
|
||||
export const EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="];
|
||||
export const COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"];
|
||||
export const BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS];
|
||||
export const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"];
|
||||
export const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS];
|
||||
export const EQUALITY_BINARY_OPERATORS = ["==", "===", "!=", "!=="];
|
||||
export const COMPARISON_BINARY_OPERATORS = [...EQUALITY_BINARY_OPERATORS, "in", "instanceof"];
|
||||
export const BOOLEAN_BINARY_OPERATORS = [...COMPARISON_BINARY_OPERATORS, ...BOOLEAN_NUMBER_BINARY_OPERATORS];
|
||||
export const NUMBER_BINARY_OPERATORS = ["-", "/", "%", "*", "**", "&", "|", ">>", ">>>", "<<", "^"];
|
||||
export const BINARY_OPERATORS = ["+", ...NUMBER_BINARY_OPERATORS, ...BOOLEAN_BINARY_OPERATORS];
|
||||
|
||||
export const BOOLEAN_UNARY_OPERATORS = ["delete", "!"];
|
||||
export const NUMBER_UNARY_OPERATORS = ["+", "-", "++", "--", "~"];
|
||||
export const STRING_UNARY_OPERATORS = ["typeof"];
|
||||
export const UNARY_OPERATORS = ["void", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS];
|
||||
export const NUMBER_UNARY_OPERATORS = ["+", "-", "++", "--", "~"];
|
||||
export const STRING_UNARY_OPERATORS = ["typeof"];
|
||||
export const UNARY_OPERATORS = ["void", ...BOOLEAN_UNARY_OPERATORS, ...NUMBER_UNARY_OPERATORS, ...STRING_UNARY_OPERATORS];
|
||||
|
||||
export const INHERIT_KEYS = {
|
||||
optional: ["typeAnnotation", "typeParameters", "returnType"],
|
||||
force: ["start", "loc", "end"]
|
||||
force: ["start", "loc", "end"],
|
||||
};
|
||||
|
||||
export const BLOCK_SCOPED_SYMBOL = Symbol.for("var used to be block scoped");
|
||||
|
||||
@@ -23,7 +23,7 @@ export function toSequenceExpression(nodes: Array<Object>, scope: Scope): ?Objec
|
||||
if (!nodes || !nodes.length) return;
|
||||
|
||||
const declars = [];
|
||||
let bailed = false;
|
||||
let bailed = false;
|
||||
|
||||
const result = convert(nodes);
|
||||
if (bailed) return;
|
||||
@@ -36,7 +36,7 @@ export function toSequenceExpression(nodes: Array<Object>, scope: Scope): ?Objec
|
||||
|
||||
function convert(nodes) {
|
||||
let ensureLastUndefined = false;
|
||||
const exprs = [];
|
||||
const exprs = [];
|
||||
|
||||
for (const node of (nodes: Array)) {
|
||||
if (t.isExpression(node)) {
|
||||
@@ -51,7 +51,7 @@ export function toSequenceExpression(nodes: Array<Object>, scope: Scope): ?Objec
|
||||
for (const key in bindings) {
|
||||
declars.push({
|
||||
kind: node.kind,
|
||||
id: bindings[key]
|
||||
id: bindings[key],
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,62 +26,62 @@ defineType("ArrayExpression", {
|
||||
assertEach(assertNodeOrValueType("null", "Expression", "SpreadElement"))
|
||||
),
|
||||
default: [],
|
||||
}
|
||||
},
|
||||
},
|
||||
visitor: ["elements"],
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("AssignmentExpression", {
|
||||
fields: {
|
||||
operator: {
|
||||
validate: assertValueType("string")
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
left: {
|
||||
validate: assertNodeType("LVal")
|
||||
validate: assertNodeType("LVal"),
|
||||
},
|
||||
right: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
builder: ["operator", "left", "right"],
|
||||
visitor: ["left", "right"],
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("BinaryExpression", {
|
||||
builder: ["operator", "left", "right"],
|
||||
fields: {
|
||||
operator: {
|
||||
validate: assertOneOf(...BINARY_OPERATORS)
|
||||
validate: assertOneOf(...BINARY_OPERATORS),
|
||||
},
|
||||
left: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
right: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
visitor: ["left", "right"],
|
||||
aliases: ["Binary", "Expression"]
|
||||
aliases: ["Binary", "Expression"],
|
||||
});
|
||||
|
||||
defineType("Directive", {
|
||||
visitor: ["value"],
|
||||
fields: {
|
||||
value: {
|
||||
validate: assertNodeType("DirectiveLiteral")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("DirectiveLiteral"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DirectiveLiteral", {
|
||||
builder: ["value"],
|
||||
fields: {
|
||||
value: {
|
||||
validate: assertValueType("string")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("BlockStatement", {
|
||||
@@ -90,13 +90,13 @@ defineType("BlockStatement", {
|
||||
fields: {
|
||||
directives: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Directive"))),
|
||||
default: []
|
||||
default: [],
|
||||
},
|
||||
body: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Statement")))
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Statement"))),
|
||||
},
|
||||
},
|
||||
aliases: ["Scopable", "BlockParent", "Block", "Statement"]
|
||||
aliases: ["Scopable", "BlockParent", "Block", "Statement"],
|
||||
});
|
||||
|
||||
defineType("BreakStatement", {
|
||||
@@ -104,52 +104,52 @@ defineType("BreakStatement", {
|
||||
fields: {
|
||||
label: {
|
||||
validate: assertNodeType("Identifier"),
|
||||
optional: true
|
||||
}
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"],
|
||||
});
|
||||
|
||||
defineType("CallExpression", {
|
||||
visitor: ["callee", "arguments"],
|
||||
fields: {
|
||||
callee: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
arguments: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression", "SpreadElement")))
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression", "SpreadElement"))),
|
||||
},
|
||||
},
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("CatchClause", {
|
||||
visitor: ["param", "body"],
|
||||
fields: {
|
||||
param: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
}
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
},
|
||||
aliases: ["Scopable"]
|
||||
aliases: ["Scopable"],
|
||||
});
|
||||
|
||||
defineType("ConditionalExpression", {
|
||||
visitor: ["test", "consequent", "alternate"],
|
||||
fields: {
|
||||
test: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
consequent: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
alternate: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
aliases: ["Expression", "Conditional"]
|
||||
aliases: ["Expression", "Conditional"],
|
||||
});
|
||||
|
||||
defineType("ContinueStatement", {
|
||||
@@ -157,41 +157,41 @@ defineType("ContinueStatement", {
|
||||
fields: {
|
||||
label: {
|
||||
validate: assertNodeType("Identifier"),
|
||||
optional: true
|
||||
}
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"]
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"],
|
||||
});
|
||||
|
||||
defineType("DebuggerStatement", {
|
||||
aliases: ["Statement"]
|
||||
aliases: ["Statement"],
|
||||
});
|
||||
|
||||
defineType("DoWhileStatement", {
|
||||
visitor: ["test", "body"],
|
||||
fields: {
|
||||
test: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("Statement")
|
||||
}
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
},
|
||||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"]
|
||||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"],
|
||||
});
|
||||
|
||||
defineType("EmptyStatement", {
|
||||
aliases: ["Statement"]
|
||||
aliases: ["Statement"],
|
||||
});
|
||||
|
||||
defineType("ExpressionStatement", {
|
||||
visitor: ["expression"],
|
||||
fields: {
|
||||
expression: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
aliases: ["Statement", "ExpressionWrapper"]
|
||||
aliases: ["Statement", "ExpressionWrapper"],
|
||||
});
|
||||
|
||||
defineType("File", {
|
||||
@@ -199,9 +199,9 @@ defineType("File", {
|
||||
visitor: ["program"],
|
||||
fields: {
|
||||
program: {
|
||||
validate: assertNodeType("Program")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Program"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ForInStatement", {
|
||||
@@ -209,15 +209,15 @@ defineType("ForInStatement", {
|
||||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
|
||||
fields: {
|
||||
left: {
|
||||
validate: assertNodeType("VariableDeclaration", "LVal")
|
||||
validate: assertNodeType("VariableDeclaration", "LVal"),
|
||||
},
|
||||
right: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("Statement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ForStatement", {
|
||||
@@ -226,20 +226,20 @@ defineType("ForStatement", {
|
||||
fields: {
|
||||
init: {
|
||||
validate: assertNodeType("VariableDeclaration", "Expression"),
|
||||
optional: true
|
||||
optional: true,
|
||||
},
|
||||
test: {
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true
|
||||
optional: true,
|
||||
},
|
||||
update: {
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true
|
||||
optional: true,
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("Statement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("FunctionDeclaration", {
|
||||
@@ -247,22 +247,22 @@ defineType("FunctionDeclaration", {
|
||||
visitor: ["id", "params", "body", "returnType", "typeParameters"],
|
||||
fields: {
|
||||
id: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
params: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal"))),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
generator: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
async: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
}
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
},
|
||||
aliases: [
|
||||
"Scopable",
|
||||
@@ -271,8 +271,8 @@ defineType("FunctionDeclaration", {
|
||||
"FunctionParent",
|
||||
"Statement",
|
||||
"Pureish",
|
||||
"Declaration"
|
||||
]
|
||||
"Declaration",
|
||||
],
|
||||
});
|
||||
|
||||
defineType("FunctionExpression", {
|
||||
@@ -281,23 +281,23 @@ defineType("FunctionExpression", {
|
||||
fields: {
|
||||
id: {
|
||||
validate: assertNodeType("Identifier"),
|
||||
optional: true
|
||||
optional: true,
|
||||
},
|
||||
params: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal"))),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
generator: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
async: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("Identifier", {
|
||||
@@ -310,12 +310,12 @@ defineType("Identifier", {
|
||||
if (!t.isValidIdentifier(val)) {
|
||||
// todo
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("IfStatement", {
|
||||
@@ -323,16 +323,16 @@ defineType("IfStatement", {
|
||||
aliases: ["Statement", "Conditional"],
|
||||
fields: {
|
||||
test: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
consequent: {
|
||||
validate: assertNodeType("Statement")
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
alternate: {
|
||||
optional: true,
|
||||
validate: assertNodeType("Statement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("LabeledStatement", {
|
||||
@@ -340,22 +340,22 @@ defineType("LabeledStatement", {
|
||||
aliases: ["Statement"],
|
||||
fields: {
|
||||
label: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("Statement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("StringLiteral", {
|
||||
builder: ["value"],
|
||||
fields: {
|
||||
value: {
|
||||
validate: assertValueType("string")
|
||||
}
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
},
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"],
|
||||
});
|
||||
|
||||
defineType("NumericLiteral", {
|
||||
@@ -363,24 +363,24 @@ defineType("NumericLiteral", {
|
||||
deprecatedAlias: "NumberLiteral",
|
||||
fields: {
|
||||
value: {
|
||||
validate: assertValueType("number")
|
||||
}
|
||||
validate: assertValueType("number"),
|
||||
},
|
||||
},
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"],
|
||||
});
|
||||
|
||||
defineType("NullLiteral", {
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"],
|
||||
});
|
||||
|
||||
defineType("BooleanLiteral", {
|
||||
builder: ["value"],
|
||||
fields: {
|
||||
value: {
|
||||
validate: assertValueType("boolean")
|
||||
}
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
},
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"]
|
||||
aliases: ["Expression", "Pureish", "Literal", "Immutable"],
|
||||
});
|
||||
|
||||
defineType("RegExpLiteral", {
|
||||
@@ -389,13 +389,13 @@ defineType("RegExpLiteral", {
|
||||
aliases: ["Expression", "Literal"],
|
||||
fields: {
|
||||
pattern: {
|
||||
validate: assertValueType("string")
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
flags: {
|
||||
validate: assertValueType("string"),
|
||||
default: ""
|
||||
}
|
||||
}
|
||||
default: "",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("LogicalExpression", {
|
||||
@@ -404,15 +404,15 @@ defineType("LogicalExpression", {
|
||||
aliases: ["Binary", "Expression"],
|
||||
fields: {
|
||||
operator: {
|
||||
validate: assertOneOf(...LOGICAL_OPERATORS)
|
||||
validate: assertOneOf(...LOGICAL_OPERATORS),
|
||||
},
|
||||
left: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
right: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("MemberExpression", {
|
||||
@@ -421,18 +421,18 @@ defineType("MemberExpression", {
|
||||
aliases: ["Expression", "LVal"],
|
||||
fields: {
|
||||
object: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
property: {
|
||||
validate(node, key, val) {
|
||||
const expectedType = node.computed ? "Expression" : "Identifier";
|
||||
assertNodeType(expectedType)(node, key, val);
|
||||
}
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
default: false
|
||||
}
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("NewExpression", {
|
||||
@@ -440,12 +440,12 @@ defineType("NewExpression", {
|
||||
aliases: ["Expression"],
|
||||
fields: {
|
||||
callee: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
arguments: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression", "SpreadElement")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression", "SpreadElement"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("Program", {
|
||||
@@ -454,13 +454,13 @@ defineType("Program", {
|
||||
fields: {
|
||||
directives: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Directive"))),
|
||||
default: []
|
||||
default: [],
|
||||
},
|
||||
body: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Statement")))
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Statement"))),
|
||||
},
|
||||
},
|
||||
aliases: ["Scopable", "BlockParent", "Block", "FunctionParent"]
|
||||
aliases: ["Scopable", "BlockParent", "Block", "FunctionParent"],
|
||||
});
|
||||
|
||||
defineType("ObjectExpression", {
|
||||
@@ -471,9 +471,9 @@ defineType("ObjectExpression", {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("ObjectMethod", "ObjectProperty", "SpreadElement"))
|
||||
)
|
||||
}
|
||||
}
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectMethod", {
|
||||
@@ -481,35 +481,35 @@ defineType("ObjectMethod", {
|
||||
fields: {
|
||||
kind: {
|
||||
validate: chain(assertValueType("string"), assertOneOf("method", "get", "set")),
|
||||
default: "method"
|
||||
default: "method",
|
||||
},
|
||||
computed: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
key: {
|
||||
validate(node, key, val) {
|
||||
const expectedTypes = node.computed ? ["Expression"] : ["Identifier", "StringLiteral", "NumericLiteral"];
|
||||
assertNodeType(...expectedTypes)(node, key, val);
|
||||
}
|
||||
},
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
generator: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
async: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
}
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
},
|
||||
visitor: ["key", "params", "body", "decorators", "returnType", "typeParameters"],
|
||||
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"]
|
||||
aliases: ["UserWhitespacable", "Function", "Scopable", "BlockParent", "FunctionParent", "Method", "ObjectMember"],
|
||||
});
|
||||
|
||||
defineType("ObjectProperty", {
|
||||
@@ -517,28 +517,28 @@ defineType("ObjectProperty", {
|
||||
fields: {
|
||||
computed: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
key: {
|
||||
validate(node, key, val) {
|
||||
const expectedTypes = node.computed ? ["Expression"] : ["Identifier", "StringLiteral", "NumericLiteral"];
|
||||
assertNodeType(...expectedTypes)(node, key, val);
|
||||
}
|
||||
},
|
||||
},
|
||||
value: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
shorthand: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
optional: true
|
||||
}
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
visitor: ["key", "value", "decorators"],
|
||||
aliases: ["UserWhitespacable", "Property", "ObjectMember"]
|
||||
aliases: ["UserWhitespacable", "Property", "ObjectMember"],
|
||||
});
|
||||
|
||||
defineType("RestElement", {
|
||||
@@ -546,12 +546,12 @@ defineType("RestElement", {
|
||||
aliases: ["LVal"],
|
||||
fields: {
|
||||
argument: {
|
||||
validate: assertNodeType("LVal")
|
||||
validate: assertNodeType("LVal"),
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ReturnStatement", {
|
||||
@@ -560,19 +560,19 @@ defineType("ReturnStatement", {
|
||||
fields: {
|
||||
argument: {
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true
|
||||
}
|
||||
}
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("SequenceExpression", {
|
||||
visitor: ["expressions"],
|
||||
fields: {
|
||||
expressions: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression")))
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression"))),
|
||||
},
|
||||
},
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("SwitchCase", {
|
||||
@@ -580,12 +580,12 @@ defineType("SwitchCase", {
|
||||
fields: {
|
||||
test: {
|
||||
validate: assertNodeType("Expression"),
|
||||
optional: true
|
||||
optional: true,
|
||||
},
|
||||
consequent: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Statement")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Statement"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("SwitchStatement", {
|
||||
@@ -593,16 +593,16 @@ defineType("SwitchStatement", {
|
||||
aliases: ["Statement", "BlockParent", "Scopable"],
|
||||
fields: {
|
||||
discriminant: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
cases: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("SwitchCase")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("SwitchCase"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ThisExpression", {
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("ThrowStatement", {
|
||||
@@ -610,9 +610,9 @@ defineType("ThrowStatement", {
|
||||
aliases: ["Statement", "Terminatorless", "CompletionStatement"],
|
||||
fields: {
|
||||
argument: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// todo: at least handler or finalizer should be set to be valid
|
||||
@@ -621,51 +621,51 @@ defineType("TryStatement", {
|
||||
aliases: ["Statement"],
|
||||
fields: {
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
handler: {
|
||||
optional: true,
|
||||
handler: assertNodeType("BlockStatement")
|
||||
handler: assertNodeType("BlockStatement"),
|
||||
},
|
||||
finalizer: {
|
||||
optional: true,
|
||||
validate: assertNodeType("BlockStatement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("UnaryExpression", {
|
||||
builder: ["operator", "argument", "prefix"],
|
||||
fields: {
|
||||
prefix: {
|
||||
default: true
|
||||
default: true,
|
||||
},
|
||||
argument: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
operator: {
|
||||
validate: assertOneOf(...UNARY_OPERATORS)
|
||||
}
|
||||
validate: assertOneOf(...UNARY_OPERATORS),
|
||||
},
|
||||
},
|
||||
visitor: ["argument"],
|
||||
aliases: ["UnaryLike", "Expression"]
|
||||
aliases: ["UnaryLike", "Expression"],
|
||||
});
|
||||
|
||||
defineType("UpdateExpression", {
|
||||
builder: ["operator", "argument", "prefix"],
|
||||
fields: {
|
||||
prefix: {
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
argument: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
operator: {
|
||||
validate: assertOneOf(...UPDATE_OPERATORS)
|
||||
}
|
||||
validate: assertOneOf(...UPDATE_OPERATORS),
|
||||
},
|
||||
},
|
||||
visitor: ["argument"],
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("VariableDeclaration", {
|
||||
@@ -674,25 +674,25 @@ defineType("VariableDeclaration", {
|
||||
aliases: ["Statement", "Declaration"],
|
||||
fields: {
|
||||
kind: {
|
||||
validate: chain(assertValueType("string"), assertOneOf("var", "let", "const"))
|
||||
validate: chain(assertValueType("string"), assertOneOf("var", "let", "const")),
|
||||
},
|
||||
declarations: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("VariableDeclarator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("VariableDeclarator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("VariableDeclarator", {
|
||||
visitor: ["id", "init"],
|
||||
fields: {
|
||||
id: {
|
||||
validate: assertNodeType("LVal")
|
||||
validate: assertNodeType("LVal"),
|
||||
},
|
||||
init: {
|
||||
optional: true,
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("WhileStatement", {
|
||||
@@ -700,12 +700,12 @@ defineType("WhileStatement", {
|
||||
aliases: ["Statement", "BlockParent", "Loop", "While", "Scopable"],
|
||||
fields: {
|
||||
test: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement", "Statement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("BlockStatement", "Statement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("WithStatement", {
|
||||
@@ -713,10 +713,10 @@ defineType("WithStatement", {
|
||||
aliases: ["Statement"],
|
||||
fields: {
|
||||
object: {
|
||||
object: assertNodeType("Expression")
|
||||
object: assertNodeType("Expression"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement", "Statement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("BlockStatement", "Statement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -13,15 +13,15 @@ defineType("AssignmentPattern", {
|
||||
aliases: ["Pattern", "LVal"],
|
||||
fields: {
|
||||
left: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
right: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ArrayPattern", {
|
||||
@@ -29,12 +29,12 @@ defineType("ArrayPattern", {
|
||||
aliases: ["Pattern", "LVal"],
|
||||
fields: {
|
||||
elements: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression"))),
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ArrowFunctionExpression", {
|
||||
@@ -43,25 +43,25 @@ defineType("ArrowFunctionExpression", {
|
||||
aliases: ["Scopable", "Function", "BlockParent", "FunctionParent", "Expression", "Pureish"],
|
||||
fields: {
|
||||
params: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal"))),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement", "Expression")
|
||||
validate: assertNodeType("BlockStatement", "Expression"),
|
||||
},
|
||||
async: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
}
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassBody", {
|
||||
visitor: ["body"],
|
||||
fields: {
|
||||
body: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("ClassMethod", "ClassProperty")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("ClassMethod", "ClassProperty"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassDeclaration", {
|
||||
@@ -74,24 +74,24 @@ defineType("ClassDeclaration", {
|
||||
"typeParameters",
|
||||
"superTypeParameters",
|
||||
"implements",
|
||||
"decorators"
|
||||
"decorators",
|
||||
],
|
||||
aliases: ["Scopable", "Class", "Statement", "Declaration", "Pureish"],
|
||||
fields: {
|
||||
id: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("ClassBody")
|
||||
validate: assertNodeType("ClassBody"),
|
||||
},
|
||||
superClass: {
|
||||
optional: true,
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassExpression", {
|
||||
@@ -100,19 +100,19 @@ defineType("ClassExpression", {
|
||||
fields: {
|
||||
id: {
|
||||
optional: true,
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("ClassBody")
|
||||
validate: assertNodeType("ClassBody"),
|
||||
},
|
||||
superClass: {
|
||||
optional: true,
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExportAllDeclaration", {
|
||||
@@ -120,9 +120,9 @@ defineType("ExportAllDeclaration", {
|
||||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
|
||||
fields: {
|
||||
source: {
|
||||
validate: assertNodeType("StringLiteral")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("StringLiteral"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExportDefaultDeclaration", {
|
||||
@@ -130,9 +130,9 @@ defineType("ExportDefaultDeclaration", {
|
||||
aliases: ["Statement", "Declaration", "ModuleDeclaration", "ExportDeclaration"],
|
||||
fields: {
|
||||
declaration: {
|
||||
validate: assertNodeType("FunctionDeclaration", "ClassDeclaration", "Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("FunctionDeclaration", "ClassDeclaration", "Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExportNamedDeclaration", {
|
||||
@@ -141,16 +141,16 @@ defineType("ExportNamedDeclaration", {
|
||||
fields: {
|
||||
declaration: {
|
||||
validate: assertNodeType("Declaration"),
|
||||
optional: true
|
||||
optional: true,
|
||||
},
|
||||
specifiers: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("ExportSpecifier")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("ExportSpecifier"))),
|
||||
},
|
||||
source: {
|
||||
validate: assertNodeType("StringLiteral"),
|
||||
optional: true
|
||||
}
|
||||
}
|
||||
optional: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExportSpecifier", {
|
||||
@@ -158,12 +158,12 @@ defineType("ExportSpecifier", {
|
||||
aliases: ["ModuleSpecifier"],
|
||||
fields: {
|
||||
local: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
exported: {
|
||||
validate: assertNodeType("Identifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ForOfStatement", {
|
||||
@@ -171,19 +171,19 @@ defineType("ForOfStatement", {
|
||||
aliases: ["Scopable", "Statement", "For", "BlockParent", "Loop", "ForXStatement"],
|
||||
fields: {
|
||||
left: {
|
||||
validate: assertNodeType("VariableDeclaration", "LVal")
|
||||
validate: assertNodeType("VariableDeclaration", "LVal"),
|
||||
},
|
||||
right: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("Statement")
|
||||
validate: assertNodeType("Statement"),
|
||||
},
|
||||
await: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ImportDeclaration", {
|
||||
@@ -194,12 +194,12 @@ defineType("ImportDeclaration", {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("ImportSpecifier", "ImportDefaultSpecifier", "ImportNamespaceSpecifier"))
|
||||
)
|
||||
),
|
||||
},
|
||||
source: {
|
||||
validate: assertNodeType("StringLiteral")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("StringLiteral"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ImportDefaultSpecifier", {
|
||||
@@ -207,9 +207,9 @@ defineType("ImportDefaultSpecifier", {
|
||||
aliases: ["ModuleSpecifier"],
|
||||
fields: {
|
||||
local: {
|
||||
validate: assertNodeType("Identifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ImportNamespaceSpecifier", {
|
||||
@@ -217,9 +217,9 @@ defineType("ImportNamespaceSpecifier", {
|
||||
aliases: ["ModuleSpecifier"],
|
||||
fields: {
|
||||
local: {
|
||||
validate: assertNodeType("Identifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ImportSpecifier", {
|
||||
@@ -227,16 +227,16 @@ defineType("ImportSpecifier", {
|
||||
aliases: ["ModuleSpecifier"],
|
||||
fields: {
|
||||
local: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
imported: {
|
||||
validate: assertNodeType("Identifier")
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
importKind: {
|
||||
// Handle Flowtype's extension "import {typeof foo} from"
|
||||
validate: assertOneOf(null, "type", "typeof")
|
||||
}
|
||||
}
|
||||
validate: assertOneOf(null, "type", "typeof"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("MetaProperty", {
|
||||
@@ -245,12 +245,12 @@ defineType("MetaProperty", {
|
||||
fields: {
|
||||
// todo: limit to new.target
|
||||
meta: {
|
||||
validate: assertValueType("string")
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
property: {
|
||||
validate: assertValueType("string")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassMethod", {
|
||||
@@ -260,37 +260,37 @@ defineType("ClassMethod", {
|
||||
fields: {
|
||||
kind: {
|
||||
validate: chain(assertValueType("string"), assertOneOf("get", "set", "method", "constructor")),
|
||||
default: "method"
|
||||
default: "method",
|
||||
},
|
||||
computed: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
static: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
key: {
|
||||
validate(node, key, val) {
|
||||
const expectedTypes = node.computed ? ["Expression"] : ["Identifier", "StringLiteral", "NumericLiteral"];
|
||||
assertNodeType(...expectedTypes)(node, key, val);
|
||||
}
|
||||
},
|
||||
},
|
||||
params: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("LVal"))),
|
||||
},
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
generator: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
async: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectPattern", {
|
||||
@@ -298,12 +298,12 @@ defineType("ObjectPattern", {
|
||||
aliases: ["Pattern", "LVal"],
|
||||
fields: {
|
||||
properties: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("RestElement", "Property")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("RestElement", "Property"))),
|
||||
},
|
||||
decorators: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Decorator"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("SpreadElement", {
|
||||
@@ -311,13 +311,13 @@ defineType("SpreadElement", {
|
||||
aliases: ["UnaryLike"],
|
||||
fields: {
|
||||
argument: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("Super", {
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("TaggedTemplateExpression", {
|
||||
@@ -325,12 +325,12 @@ defineType("TaggedTemplateExpression", {
|
||||
aliases: ["Expression"],
|
||||
fields: {
|
||||
tag: {
|
||||
validate: assertNodeType("Expression")
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
quasi: {
|
||||
validate: assertNodeType("TemplateLiteral")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("TemplateLiteral"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TemplateElement", {
|
||||
@@ -341,9 +341,9 @@ defineType("TemplateElement", {
|
||||
},
|
||||
tail: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
}
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TemplateLiteral", {
|
||||
@@ -351,12 +351,12 @@ defineType("TemplateLiteral", {
|
||||
aliases: ["Expression", "Literal"],
|
||||
fields: {
|
||||
quasis: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("TemplateElement")))
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("TemplateElement"))),
|
||||
},
|
||||
expressions: {
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression")))
|
||||
}
|
||||
}
|
||||
validate: chain(assertValueType("array"), assertEach(assertNodeType("Expression"))),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("YieldExpression", {
|
||||
@@ -366,11 +366,11 @@ defineType("YieldExpression", {
|
||||
fields: {
|
||||
delegate: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
default: false,
|
||||
},
|
||||
argument: {
|
||||
optional: true,
|
||||
validate: assertNodeType("Expression"),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -7,8 +7,8 @@ defineType("AwaitExpression", {
|
||||
fields: {
|
||||
argument: {
|
||||
validate: assertNodeType("Expression"),
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("BindExpression", {
|
||||
@@ -16,20 +16,20 @@ defineType("BindExpression", {
|
||||
aliases: ["Expression"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("Import", {
|
||||
aliases: ["Expression"]
|
||||
aliases: ["Expression"],
|
||||
});
|
||||
|
||||
defineType("Decorator", {
|
||||
visitor: ["expression"],
|
||||
fields: {
|
||||
expression: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DoExpression", {
|
||||
@@ -37,9 +37,9 @@ defineType("DoExpression", {
|
||||
aliases: ["Expression"],
|
||||
fields: {
|
||||
body: {
|
||||
validate: assertNodeType("BlockStatement")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("BlockStatement"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExportDefaultSpecifier", {
|
||||
@@ -47,9 +47,9 @@ defineType("ExportDefaultSpecifier", {
|
||||
aliases: ["ModuleSpecifier"],
|
||||
fields: {
|
||||
exported: {
|
||||
validate: assertNodeType("Identifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExportNamespaceSpecifier", {
|
||||
@@ -57,7 +57,7 @@ defineType("ExportNamespaceSpecifier", {
|
||||
aliases: ["ModuleSpecifier"],
|
||||
fields: {
|
||||
exported: {
|
||||
validate: assertNodeType("Identifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Identifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import defineType, {
|
||||
assertValueType
|
||||
assertValueType,
|
||||
} from "./index";
|
||||
|
||||
defineType("AnyTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ArrayTypeAnnotation", {
|
||||
@@ -14,24 +14,24 @@ defineType("ArrayTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("BooleanTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("BooleanLiteralTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {}
|
||||
fields: {},
|
||||
});
|
||||
|
||||
defineType("NullLiteralTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {}
|
||||
fields: {},
|
||||
});
|
||||
|
||||
defineType("ClassImplements", {
|
||||
@@ -39,7 +39,7 @@ defineType("ClassImplements", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ClassProperty", {
|
||||
@@ -49,10 +49,10 @@ defineType("ClassProperty", {
|
||||
fields: {
|
||||
computed: {
|
||||
validate: assertValueType("boolean"),
|
||||
default: false
|
||||
}
|
||||
default: false,
|
||||
},
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareClass", {
|
||||
@@ -60,7 +60,7 @@ defineType("DeclareClass", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareFunction", {
|
||||
@@ -68,7 +68,7 @@ defineType("DeclareFunction", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareInterface", {
|
||||
@@ -76,7 +76,7 @@ defineType("DeclareInterface", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareModule", {
|
||||
@@ -84,7 +84,7 @@ defineType("DeclareModule", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareModuleExports", {
|
||||
@@ -92,7 +92,7 @@ defineType("DeclareModuleExports", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareTypeAlias", {
|
||||
@@ -100,7 +100,7 @@ defineType("DeclareTypeAlias", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("DeclareVariable", {
|
||||
@@ -108,11 +108,11 @@ defineType("DeclareVariable", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ExistsTypeAnnotation", {
|
||||
aliases: ["Flow"]
|
||||
aliases: ["Flow"],
|
||||
});
|
||||
|
||||
defineType("FunctionTypeAnnotation", {
|
||||
@@ -120,7 +120,7 @@ defineType("FunctionTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("FunctionTypeParam", {
|
||||
@@ -128,7 +128,7 @@ defineType("FunctionTypeParam", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("GenericTypeAnnotation", {
|
||||
@@ -136,7 +136,7 @@ defineType("GenericTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("InterfaceExtends", {
|
||||
@@ -144,7 +144,7 @@ defineType("InterfaceExtends", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("InterfaceDeclaration", {
|
||||
@@ -152,7 +152,7 @@ defineType("InterfaceDeclaration", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("IntersectionTypeAnnotation", {
|
||||
@@ -160,15 +160,15 @@ defineType("IntersectionTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("MixedTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"]
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
});
|
||||
|
||||
defineType("EmptyTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"]
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
});
|
||||
|
||||
defineType("NullableTypeAnnotation", {
|
||||
@@ -176,40 +176,40 @@ defineType("NullableTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("NumberLiteralTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("NumberTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("StringLiteralTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("StringTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ThisTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {}
|
||||
fields: {},
|
||||
});
|
||||
|
||||
defineType("TupleTypeAnnotation", {
|
||||
@@ -217,7 +217,7 @@ defineType("TupleTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeofTypeAnnotation", {
|
||||
@@ -225,7 +225,7 @@ defineType("TypeofTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeAlias", {
|
||||
@@ -233,7 +233,7 @@ defineType("TypeAlias", {
|
||||
aliases: ["Flow", "FlowDeclaration", "Statement", "Declaration"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeAnnotation", {
|
||||
@@ -241,7 +241,7 @@ defineType("TypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeCastExpression", {
|
||||
@@ -249,7 +249,7 @@ defineType("TypeCastExpression", {
|
||||
aliases: ["Flow", "ExpressionWrapper", "Expression"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameter", {
|
||||
@@ -257,7 +257,7 @@ defineType("TypeParameter", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameterDeclaration", {
|
||||
@@ -265,7 +265,7 @@ defineType("TypeParameterDeclaration", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("TypeParameterInstantiation", {
|
||||
@@ -273,7 +273,7 @@ defineType("TypeParameterInstantiation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeAnnotation", {
|
||||
@@ -281,7 +281,7 @@ defineType("ObjectTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeCallProperty", {
|
||||
@@ -289,7 +289,7 @@ defineType("ObjectTypeCallProperty", {
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeIndexer", {
|
||||
@@ -297,7 +297,7 @@ defineType("ObjectTypeIndexer", {
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("ObjectTypeProperty", {
|
||||
@@ -305,7 +305,7 @@ defineType("ObjectTypeProperty", {
|
||||
aliases: ["Flow", "UserWhitespacable"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("QualifiedTypeIdentifier", {
|
||||
@@ -313,7 +313,7 @@ defineType("QualifiedTypeIdentifier", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("UnionTypeAnnotation", {
|
||||
@@ -321,12 +321,12 @@ defineType("UnionTypeAnnotation", {
|
||||
aliases: ["Flow"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
defineType("VoidTypeAnnotation", {
|
||||
aliases: ["Flow", "FlowBaseAnnotation"],
|
||||
fields: {
|
||||
// todo
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ export default function defineType(
|
||||
) {
|
||||
const inherits = (opts.inherits && store[opts.inherits]) || {};
|
||||
|
||||
opts.fields = opts.fields || inherits.fields || {};
|
||||
opts.fields = opts.fields || inherits.fields || {};
|
||||
opts.visitor = opts.visitor || inherits.visitor || [];
|
||||
opts.aliases = opts.aliases || inherits.aliases || [];
|
||||
opts.builder = opts.builder || inherits.builder || opts.visitor || [];
|
||||
@@ -158,8 +158,8 @@ export default function defineType(
|
||||
|
||||
VISITOR_KEYS[type] = opts.visitor;
|
||||
BUILDER_KEYS[type] = opts.builder;
|
||||
NODE_FIELDS[type] = opts.fields;
|
||||
ALIAS_KEYS[type] = opts.aliases;
|
||||
NODE_FIELDS[type] = opts.fields;
|
||||
ALIAS_KEYS[type] = opts.aliases;
|
||||
|
||||
store[type] = opts;
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ defineType("JSXAttribute", {
|
||||
aliases: ["JSX", "Immutable"],
|
||||
fields: {
|
||||
name: {
|
||||
validate: assertNodeType("JSXIdentifier", "JSXNamespacedName")
|
||||
validate: assertNodeType("JSXIdentifier", "JSXNamespacedName"),
|
||||
},
|
||||
value: {
|
||||
optional: true,
|
||||
validate: assertNodeType("JSXElement", "StringLiteral", "JSXExpressionContainer")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("JSXElement", "StringLiteral", "JSXExpressionContainer"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXClosingElement", {
|
||||
@@ -19,9 +19,9 @@ defineType("JSXClosingElement", {
|
||||
aliases: ["JSX", "Immutable"],
|
||||
fields: {
|
||||
name: {
|
||||
validate: assertNodeType("JSXIdentifier", "JSXMemberExpression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("JSXIdentifier", "JSXMemberExpression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXElement", {
|
||||
@@ -30,23 +30,23 @@ defineType("JSXElement", {
|
||||
aliases: ["JSX", "Immutable", "Expression"],
|
||||
fields: {
|
||||
openingElement: {
|
||||
validate: assertNodeType("JSXOpeningElement")
|
||||
validate: assertNodeType("JSXOpeningElement"),
|
||||
},
|
||||
closingElement: {
|
||||
optional: true,
|
||||
validate: assertNodeType("JSXClosingElement")
|
||||
validate: assertNodeType("JSXClosingElement"),
|
||||
},
|
||||
children: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("JSXText", "JSXExpressionContainer", "JSXSpreadChild", "JSXElement"))
|
||||
)
|
||||
}
|
||||
}
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXEmptyExpression", {
|
||||
aliases: ["JSX", "Expression"]
|
||||
aliases: ["JSX", "Expression"],
|
||||
});
|
||||
|
||||
defineType("JSXExpressionContainer", {
|
||||
@@ -54,9 +54,9 @@ defineType("JSXExpressionContainer", {
|
||||
aliases: ["JSX", "Immutable"],
|
||||
fields: {
|
||||
expression: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXSpreadChild", {
|
||||
@@ -64,9 +64,9 @@ defineType("JSXSpreadChild", {
|
||||
aliases: ["JSX", "Immutable"],
|
||||
fields: {
|
||||
expression: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXIdentifier", {
|
||||
@@ -74,9 +74,9 @@ defineType("JSXIdentifier", {
|
||||
aliases: ["JSX", "Expression"],
|
||||
fields: {
|
||||
name: {
|
||||
validate: assertValueType("string")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXMemberExpression", {
|
||||
@@ -84,12 +84,12 @@ defineType("JSXMemberExpression", {
|
||||
aliases: ["JSX", "Expression"],
|
||||
fields: {
|
||||
object: {
|
||||
validate: assertNodeType("JSXMemberExpression", "JSXIdentifier")
|
||||
validate: assertNodeType("JSXMemberExpression", "JSXIdentifier"),
|
||||
},
|
||||
property: {
|
||||
validate: assertNodeType("JSXIdentifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("JSXIdentifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXNamespacedName", {
|
||||
@@ -97,12 +97,12 @@ defineType("JSXNamespacedName", {
|
||||
aliases: ["JSX"],
|
||||
fields: {
|
||||
namespace: {
|
||||
validate: assertNodeType("JSXIdentifier")
|
||||
validate: assertNodeType("JSXIdentifier"),
|
||||
},
|
||||
name: {
|
||||
validate: assertNodeType("JSXIdentifier")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("JSXIdentifier"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXOpeningElement", {
|
||||
@@ -111,19 +111,19 @@ defineType("JSXOpeningElement", {
|
||||
aliases: ["JSX", "Immutable"],
|
||||
fields: {
|
||||
name: {
|
||||
validate: assertNodeType("JSXIdentifier", "JSXMemberExpression")
|
||||
validate: assertNodeType("JSXIdentifier", "JSXMemberExpression"),
|
||||
},
|
||||
selfClosing: {
|
||||
default: false,
|
||||
validate: assertValueType("boolean")
|
||||
validate: assertValueType("boolean"),
|
||||
},
|
||||
attributes: {
|
||||
validate: chain(
|
||||
assertValueType("array"),
|
||||
assertEach(assertNodeType("JSXAttribute", "JSXSpreadAttribute"))
|
||||
)
|
||||
}
|
||||
}
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXSpreadAttribute", {
|
||||
@@ -131,9 +131,9 @@ defineType("JSXSpreadAttribute", {
|
||||
aliases: ["JSX"],
|
||||
fields: {
|
||||
argument: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
defineType("JSXText", {
|
||||
@@ -141,7 +141,7 @@ defineType("JSXText", {
|
||||
builder: ["value"],
|
||||
fields: {
|
||||
value: {
|
||||
validate: assertValueType("string")
|
||||
}
|
||||
}
|
||||
validate: assertValueType("string"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import defineType, { assertNodeType } from "./index";
|
||||
|
||||
defineType("Noop", {
|
||||
visitor: []
|
||||
visitor: [],
|
||||
});
|
||||
|
||||
defineType("ParenthesizedExpression", {
|
||||
@@ -9,7 +9,7 @@ defineType("ParenthesizedExpression", {
|
||||
aliases: ["Expression", "ExpressionWrapper"],
|
||||
fields: {
|
||||
expression: {
|
||||
validate: assertNodeType("Expression")
|
||||
}
|
||||
}
|
||||
validate: assertNodeType("Expression"),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -6,7 +6,7 @@ import * as t from "./index";
|
||||
*/
|
||||
|
||||
export function createUnionTypeAnnotation(types: Array<Object>) {
|
||||
const flattened = removeTypeDuplicates(types);
|
||||
const flattened = removeTypeDuplicates(types);
|
||||
|
||||
if (flattened.length === 1) {
|
||||
return flattened[0];
|
||||
|
||||
@@ -46,7 +46,7 @@ export {
|
||||
UNARY_OPERATORS,
|
||||
INHERIT_KEYS,
|
||||
BLOCK_SCOPED_SYMBOL,
|
||||
NOT_LOCAL_BINDING
|
||||
NOT_LOCAL_BINDING,
|
||||
} from "./constants";
|
||||
|
||||
import "./definitions/init";
|
||||
@@ -230,7 +230,7 @@ export function shallowEqual(actual: Object, expected: Object): boolean {
|
||||
*/
|
||||
|
||||
export function appendToMemberExpression(member: Object, append: Object, computed?: boolean): Object {
|
||||
member.object = t.memberExpression(member.object, member.property, member.computed);
|
||||
member.object = t.memberExpression(member.object, member.property, member.computed);
|
||||
member.property = append;
|
||||
member.computed = !!computed;
|
||||
return member;
|
||||
@@ -485,11 +485,11 @@ export function traverseFast(node: Node, enter: (node: Node) => void, opts?: Obj
|
||||
const CLEAR_KEYS: Array = [
|
||||
"tokens",
|
||||
"start", "end", "loc",
|
||||
"raw", "rawValue"
|
||||
"raw", "rawValue",
|
||||
];
|
||||
|
||||
const CLEAR_KEYS_PLUS_COMMENTS: Array = t.COMMENT_KEYS.concat([
|
||||
"comments"
|
||||
"comments",
|
||||
]).concat(CLEAR_KEYS);
|
||||
|
||||
/**
|
||||
@@ -522,7 +522,7 @@ export function removePropertiesDeep(tree: Node, opts?: Object): Node {
|
||||
//
|
||||
export {
|
||||
getBindingIdentifiers,
|
||||
getOuterBindingIdentifiers
|
||||
getOuterBindingIdentifiers,
|
||||
} from "./retrievers";
|
||||
|
||||
export {
|
||||
@@ -535,7 +535,7 @@ export {
|
||||
isSpecifierDefault,
|
||||
isScope,
|
||||
isImmutable,
|
||||
isNodesEquivalent
|
||||
isNodesEquivalent,
|
||||
} from "./validators";
|
||||
|
||||
export {
|
||||
@@ -547,11 +547,11 @@ export {
|
||||
toStatement,
|
||||
toExpression,
|
||||
toBlock,
|
||||
valueToNode
|
||||
valueToNode,
|
||||
} from "./converters";
|
||||
|
||||
export {
|
||||
createUnionTypeAnnotation,
|
||||
removeTypeDuplicates,
|
||||
createTypeAnnotationBasedOnTypeof
|
||||
createTypeAnnotationBasedOnTypeof,
|
||||
} from "./flow";
|
||||
|
||||
@@ -10,7 +10,7 @@ export function getBindingIdentifiers(
|
||||
outerOnly?: boolean
|
||||
): Object {
|
||||
let search = [].concat(node);
|
||||
const ids = Object.create(null);
|
||||
const ids = Object.create(null);
|
||||
|
||||
while (search.length) {
|
||||
const id = search.shift();
|
||||
@@ -101,7 +101,7 @@ getBindingIdentifiers.keys = {
|
||||
ObjectPattern: ["properties"],
|
||||
|
||||
VariableDeclaration: ["declarations"],
|
||||
VariableDeclarator: ["id"]
|
||||
VariableDeclarator: ["id"],
|
||||
};
|
||||
|
||||
export function getOuterBindingIdentifiers(
|
||||
|
||||
Reference in New Issue
Block a user