How to use the tsutils.isFunctionDeclaration function in tsutils

To help you get started, we’ve selected a few tsutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nativescript-rtl / ui / node_modules / tslint / lib / rules / preferConstRule.js View on Github external
var cb = function (node) {
            var savedScope = _this.scope;
            var boundary = utils.isScopeBoundary(node);
            if (boundary !== 0 /* None */) {
                if (boundary === 1 /* Function */) {
                    if (node.kind === ts.SyntaxKind.ModuleDeclaration &&
                        utils.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) {
                        // don't check ambient namespaces
                        return;
                    }
                    _this.scope = new Scope();
                    if (utils.isFunctionDeclaration(node) ||
                        utils.isMethodDeclaration(node) ||
                        utils.isFunctionExpression(node) ||
                        utils.isArrowFunction(node) ||
                        utils.isConstructorDeclaration(node)) {
                        // special handling for function parameters
                        // each parameter initializer can only reassign preceding parameters of variables of the containing scope
                        if (node.body !== undefined) {
                            for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
                                var param = _a[_i];
                                cb(param);
                                _this.settle(savedScope);
                            }
                            cb(node.body);
                            _this.onScopeEnd(savedScope);
                        }
                        _this.scope = savedScope;
github fossasia / susper.com / node_modules / tslint / lib / rules / preferConstRule.js View on Github external
var cb = function (node) {
            var savedScope = _this.scope;
            var boundary = utils.isScopeBoundary(node);
            if (boundary !== 0 /* None */) {
                if (boundary === 1 /* Function */) {
                    if (node.kind === ts.SyntaxKind.ModuleDeclaration &&
                        utils.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)) {
                        // don't check ambient namespaces
                        return;
                    }
                    _this.scope = new Scope();
                    if (utils.isFunctionDeclaration(node) ||
                        utils.isMethodDeclaration(node) ||
                        utils.isFunctionExpression(node) ||
                        utils.isArrowFunction(node) ||
                        utils.isConstructorDeclaration(node)) {
                        // special handling for function parameters
                        // each parameter initializer can only reassign preceding parameters of variables of the containing scope
                        if (node.body !== undefined) {
                            for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
                                var param = _a[_i];
                                cb(param);
                                _this.settle(savedScope);
                            }
                            cb(node.body);
                            _this.onScopeEnd(savedScope);
                        }
                        _this.scope = savedScope;
github palantir / tslint / src / rules / preferConstRule.ts View on Github external
const cb = (node: ts.Node): void => {
            const savedScope = this.scope;
            const boundary = utils.isScopeBoundary(node);
            if (boundary !== utils.ScopeBoundary.None) {
                if (boundary === utils.ScopeBoundary.Function) {
                    if (
                        node.kind === ts.SyntaxKind.ModuleDeclaration &&
                        utils.hasModifier(node.modifiers, ts.SyntaxKind.DeclareKeyword)
                    ) {
                        // don't check ambient namespaces
                        return;
                    }
                    this.scope = new Scope();
                    if (
                        utils.isFunctionDeclaration(node) ||
                        utils.isMethodDeclaration(node) ||
                        utils.isFunctionExpression(node) ||
                        utils.isArrowFunction(node) ||
                        utils.isConstructorDeclaration(node)
                    ) {
                        // special handling for function parameters
                        // each parameter initializer can only reassign preceding parameters of variables of the containing scope
                        if (node.body !== undefined) {
                            for (const param of node.parameters) {
                                cb(param);
                                this.settle(savedScope);
                            }
                            cb(node.body);
                            this.onScopeEnd(savedScope);
                        }
                        this.scope = savedScope;
github palantir / tslint / src / rules / completedDocsRule.ts View on Github external
function getEquivalentNodesForDocs(node: ts.Node, docType: DocType): ts.Node[] {
        const exclusions = context.options.get(docType);
        if (exclusions === undefined || exclusions.overloadsSeparateDocs) {
            return [node];
        }

        if (tsutils.isFunctionDeclaration(node) && node.name !== undefined) {
            const functionName = node.name.text;

            return getSiblings(node).filter(
                child =>
                    tsutils.isFunctionDeclaration(child) &&
                    child.name !== undefined &&
                    child.name.text === functionName,
            );
        }

        if (tsutils.isConstructorDeclaration(node)) {
            const {
                parent: { members },
            } = node;

            return members.filter(child => tsutils.isConstructorDeclaration(child));
github bfwg / angular-spring-starter / frontend / node_modules / tslint / lib / rules / adjacentOverloadSignaturesRule.js View on Github external
addFailures(getMisplacedOverloads(statements, function (statement) {
            return utils.isFunctionDeclaration(statement) && statement.name !== undefined ? statement.name.text : undefined;
        }));
    }
github microsoft / tslint-microsoft-contrib / src / reactA11yAccessibleHeadingsRule.ts View on Github external
function cb(node: ts.Node): void {
        if (tsutils.isFunctionDeclaration(node)) {
            validate(node);
        } else if (tsutils.isMethodDeclaration(node)) {
            validate(node);
        } else if (tsutils.isVariableDeclaration(node)) {
            validate(node);
        }

        return ts.forEachChild(node, cb);
    }
github microsoft / tslint-microsoft-contrib / reactA11yAccessibleHeadingsRule.js View on Github external
function cb(node) {
        if (tsutils.isFunctionDeclaration(node)) {
            validate(node);
        }
        else if (tsutils.isMethodDeclaration(node)) {
            validate(node);
        }
        else if (tsutils.isVariableDeclaration(node)) {
            validate(node);
        }
        return ts.forEachChild(node, cb);
    }
    return ts.forEachChild(ctx.sourceFile, cb);
github fossasia / susper.com / node_modules / tslint / lib / rules / adjacentOverloadSignaturesRule.js View on Github external
addFailures(getMisplacedOverloads(statements, function (statement) {
            return utils.isFunctionDeclaration(statement) && statement.name !== undefined
                ? statement.name.text
                : undefined;
        }));
    }
github microsoft / tslint-microsoft-contrib / utils / BannedTermWalker.js View on Github external
function cb(node) {
        if (tsutils.isVariableDeclaration(node) ||
            tsutils.isFunctionDeclaration(node) ||
            tsutils.isPropertyDeclaration(node) ||
            tsutils.isAccessorDeclaration(node) ||
            tsutils.isMethodDeclaration(node)) {
            validateNode(node);
        }
        if (tsutils.isParameterDeclaration(node)) {
            if (node.name.getText() !== 'this') {
                validateNode(node);
            }
        }
        if (tsutils.isPropertySignature(node)) {
            if (allowQuotedProperties === false || !tsutils.isStringLiteral(node.name)) {
                validateNode(node);
            }
        }
        return ts.forEachChild(node, cb);
github microsoft / tslint-microsoft-contrib / noUnexternalizedStringsRule.js View on Github external
while (node.parent) {
            var parent_1 = node.parent;
            if (tsutils.isCallExpression(parent_1)) {
                var callExpression = parent_1;
                return {
                    callInfo: {
                        callExpression: callExpression,
                        argIndex: callExpression.arguments.indexOf(node)
                    }
                };
            }
            if (tsutils.isImportEqualsDeclaration(parent_1) || tsutils.isImportDeclaration(parent_1) || tsutils.isExportDeclaration(parent_1)) {
                return { ignoreUsage: true };
            }
            if (tsutils.isVariableDeclaration(parent_1) ||
                tsutils.isFunctionDeclaration(parent_1) ||
                tsutils.isPropertyDeclaration(parent_1) ||
                tsutils.isMethodDeclaration(parent_1) ||
                tsutils.isVariableDeclarationList(parent_1) ||
                tsutils.isInterfaceDeclaration(parent_1) ||
                tsutils.isClassDeclaration(parent_1) ||
                tsutils.isEnumDeclaration(parent_1) ||
                tsutils.isModuleDeclaration(parent_1) ||
                tsutils.isTypeAliasDeclaration(parent_1) ||
                tsutils.isSourceFile(parent_1)) {
                return undefined;
            }
            node = parent_1;
        }
        return undefined;
    }
    function cb(node) {