Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getMemberKind(member: Member): MemberKind | undefined {
const accessLevel = hasModifier(member.modifiers, ts.SyntaxKind.PrivateKeyword)
? "private"
: hasModifier(member.modifiers, ts.SyntaxKind.ProtectedKeyword)
? "protected"
: "public";
const membership = hasModifier(member.modifiers, ts.SyntaxKind.StaticKeyword)
? "Static"
: "Instance";
switch (member.kind) {
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.ConstructSignature:
// tslint:disable-next-line:prefer-template
return (MemberKind as any)[accessLevel + "Constructor"] as MemberKind;
case ts.SyntaxKind.GetAccessor:
case ts.SyntaxKind.SetAccessor:
// tslint:disable-next-line:prefer-template
return (MemberKind as any)[accessLevel + membership + "Accessor"] as MemberKind;
case ts.SyntaxKind.PropertyDeclaration:
case ts.SyntaxKind.PropertySignature:
break;
case ts.SyntaxKind.Parameter:
if (node.parent.kind !== ts.SyntaxKind.IndexSignature &&
!tsutils_1.isThisParameter(node) &&
tsutils_1.isFunctionWithBody(node.parent)) {
_this.handleBindingName(node.name, false, true);
}
break;
case ts.SyntaxKind.ModuleDeclaration:
if (_this.options.namespace &&
node.parent.kind !== ts.SyntaxKind.ModuleDeclaration &&
node.name.kind === ts.SyntaxKind.Identifier &&
!tsutils_1.isNodeFlagSet(node, ts.NodeFlags.GlobalAugmentation)) {
parentScope.addVariable(node.name, false);
}
if (tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) {
_this.onScopeEnd(parentScope);
_this.scope = parentScope;
return; // don't check any ambient declaration blocks
}
break;
case ts.SyntaxKind.ImportClause:
if (_this.options.import && node.name !== undefined) {
_this.scope.addVariable(node.name, false);
}
break;
case ts.SyntaxKind.NamespaceImport:
case ts.SyntaxKind.ImportSpecifier:
case ts.SyntaxKind.ImportEqualsDeclaration:
if (_this.options.import) {
_this.scope.addVariable(node.name, false);
}
function getOption(node, options) {
switch (node.kind) {
case ts.SyntaxKind.ArrowFunction:
return !hasTypeParameters(node) &&
tsutils_1.hasModifier(node.modifiers, ts.SyntaxKind.AsyncKeyword)
? options.asyncArrow
: undefined;
case ts.SyntaxKind.Constructor:
return options.constructor;
case ts.SyntaxKind.FunctionDeclaration:
// name is optional for function declaration which is default export (TS will emit error in other cases).
// Can be handled in the same way as function expression.
case ts.SyntaxKind.FunctionExpression: {
var functionName = node.name;
var hasName = functionName !== undefined && functionName.text !== "";
return hasName
? options.named
: !hasTypeParameters(node)
? options.anonymous
: undefined;
}
private shouldLocationBeDocumented(node: ts.Node) {
if (this.locations.has(ALL)) {
return true;
}
if (hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword)) {
return this.locations.has(LOCATION_STATIC);
}
return this.locations.has(LOCATION_INSTANCE);
}
protected visitInterfaceDeclaration(node: ts.InterfaceDeclaration): void {
if (this._validate.declarations) {
const { name } = node;
if (!tsutils.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
this.declared(node, name);
this.setScopedIdentifier(name);
}
}
super.visitInterfaceDeclaration(node);
}
function getMemberKind(member) {
var accessLevel = tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.PrivateKeyword)
? "private"
: tsutils_1.hasModifier(member.modifiers, ts.SyntaxKind.ProtectedKeyword)
? "protected"
: "public";
switch (member.kind) {
case ts.SyntaxKind.Constructor:
case ts.SyntaxKind.ConstructSignature:
return memberKindForConstructor(accessLevel);
case ts.SyntaxKind.PropertyDeclaration:
case ts.SyntaxKind.PropertySignature:
return methodOrField(isFunctionLiteral(member.initializer));
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.MethodSignature:
return methodOrField(true);
default:
return undefined;
protected visitTypeAliasDeclaration(node: ts.TypeAliasDeclaration): void {
if (this._validate.declarations) {
const { name } = node;
if (!tsutils.hasModifier(node.modifiers, ts.SyntaxKind.ExportKeyword)) {
this.declared(node, name);
this.setScopedIdentifier(name);
}
}
super.visitTypeAliasDeclaration(node);
}
function handleLonghandMethod(name, initializer, sourceFile) {
var nameStart = name.getStart(sourceFile);
var fix = Lint.Replacement.deleteFromTo(name.end, tsutils_1.getChildOfKind(initializer, ts.SyntaxKind.OpenParenToken).pos);
var prefix = "";
if (initializer.asteriskToken !== undefined) {
prefix = "*";
}
if (tsutils_1.hasModifier(initializer.modifiers, ts.SyntaxKind.AsyncKeyword)) {
prefix = "async " + prefix;
}
if (prefix !== "") {
fix = [fix, Lint.Replacement.appendText(nameStart, prefix)];
}
return [prefix + sourceFile.text.substring(nameStart, name.end), fix];
}
var templateObject_1;
const getStaticPropTypes = (node: ts.ClassElement): node is PropTypesMember =>
ts.isPropertyDeclaration(node) &&
tsutils.hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword) &&
ts.isIdentifier(node.name) &&
node.name.text === "propTypes" &&
node.initializer !== undefined &&
ts.isObjectLiteralExpression(node.initializer);
function isMethod(node: ts.Node, ignoreStatic: boolean): boolean {
switch (node.kind) {
case ts.SyntaxKind.MethodDeclaration:
case ts.SyntaxKind.MethodSignature:
return !(ignoreStatic && hasModifier(node.modifiers, ts.SyntaxKind.StaticKeyword));
default:
return false;
}
}