Fast TypeScript Analyzer CLI
FTA (Fast TypeScript Analyzer) is a static analysis tool designed for TypeScript and JavaScript code, implemented in Rust for superior performance. It utilizes the SWC parser to efficiently analyze codebases and generate metrics concerning complexity and maintainability. The current stable version is 3.0.0, which features upgraded SWC libraries for enhanced accuracy in operand/operator counting and includes support for modern JavaScript/TypeScript syntax such as `import with`. The project exhibits an active release cadence, with frequent updates and major versions, reflecting continuous development. A key differentiator is its exceptional speed, capable of processing up to 1600 files per second on typical hardware, making it highly suitable for large-scale projects. It provides clear, actionable analytics to help developers identify and address potential maintainability issues.
Common errors
-
Error: Command not found: fta-cli
cause `fta-cli` is not installed globally or `npx` cannot locate it.fixEnsure you run `npx fta-cli ...` to execute the package without global installation, or install it globally with `npm install -g fta-cli` if preferred. -
Error: The specified path does not exist: /path/to/nonexistent/project
cause The directory or file path provided to `fta-cli` does not exist on your file system.fixDouble-check the provided path. Ensure it's an existing directory or file, and that your current working directory is correct if using relative paths. -
Failed to parse TypeScript/JavaScript file: Syntax Error...
cause `fta-cli` encountered modern or non-standard syntax that its underlying SWC parser version does not yet support.fixUpdate `fta-cli` to the latest version. Version 3.0.0 and above significantly improve support for modern syntax due to SWC upgrades. If the issue persists, report it to the `fta-cli` GitHub repository.
Warnings
- breaking Version 3.0.0 includes an upgrade to underlying SWC libraries. This results in material changes to how operands and operators are counted, leading to different FTA scores compared to previous versions. It may require recalibrating thresholds or expectations for existing projects.
- breaking Version 2.0.0 introduced corrections to the Halstead calculations. This change materially affects the reported Halstead and FTA scores, making direct comparison with results from v1.x inaccurate.
- breaking In v1.0.0, the `include_comments` option's default value changed to `false`, meaning comments are no longer included in scoring by default. Also, the `exclude_under` option was added with a default of `6`, excluding files under 6 lines of code.
Install
-
npm install fta-cli -
yarn add fta-cli -
pnpm add fta-cli
Imports
- FtaAnalysisOptions
import type { FtaAnalysisOptions } from 'fta-cli' - FtaReportEntry
import type { FtaReportEntry } from 'fta-cli' - FtaAssessment
import type { FtaAssessment } from 'fta-cli' - ftaCliCommand
import { ftaCliCommand } from 'fta-cli'
Quickstart
npx fta-cli ./src --format table --exclude-under 10 # Example of running against a specific file or directory npx fta-cli my-project/index.ts # To analyze your current project directory npx fta-cli .