1.0.1 • Published 4 months ago

code-analyzer-ts v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 months ago

code-analyzer

Static code analyzer implemented using TypeScript compiler.

Installation

npm install --save code-analyzer-ts

Example Usage

import * as ts from "typescript";
import { CodeAnalyzer } from "code-analyzer-ts";

new CodeAnalyzer()
    .onFileStart((filePath: string, filename: string, fileExtension: string, content: string) => {
        console.log(filePath, filename, fileExtension, content);
    })
    .onNode((node: ts.Node) => {
        if (ts.isCallExpression(node) && node.expression.getText() === "eval") {
            console.error("Eval is evil!");
        }
    })
    .onFileEnd((filePath: string, filename: string, fileExtension: string, content: string) => {
        console.log(filePath, filename, fileExtension, content);
    })
    .analyze("path");