{"id":31522459,"url":"https://github.com/amir-valizadeh/ts-analyzer","last_synced_at":"2026-04-11T01:25:40.486Z","repository":{"id":293431313,"uuid":"984037839","full_name":"amir-valizadeh/ts-analyzer","owner":"amir-valizadeh","description":"A comprehensive TypeScript codebase analyzer that provides detailed metrics on type safety, code complexity, and quality. Get actionable insights to improve your TypeScript projects.","archived":false,"fork":false,"pushed_at":"2026-03-26T23:14:55.000Z","size":31,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-03T02:19:19.862Z","etag":null,"topics":["codecomplexity","nestjs","nextjs","react","ts-analyzer","typechecker","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/ts-analyzer","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amir-valizadeh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-15T09:51:11.000Z","updated_at":"2026-03-31T15:37:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"266a4e7f-400f-4ca2-8e4e-e8ee98b82c4c","html_url":"https://github.com/amir-valizadeh/ts-analyzer","commit_stats":null,"previous_names":["amir-valizadeh/ts-analyzer"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/amir-valizadeh/ts-analyzer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-valizadeh%2Fts-analyzer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-valizadeh%2Fts-analyzer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-valizadeh%2Fts-analyzer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-valizadeh%2Fts-analyzer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amir-valizadeh","download_url":"https://codeload.github.com/amir-valizadeh/ts-analyzer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amir-valizadeh%2Fts-analyzer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31492751,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-06T17:22:55.647Z","status":"ssl_error","status_checked_at":"2026-04-06T17:22:54.741Z","response_time":112,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["codecomplexity","nestjs","nextjs","react","ts-analyzer","typechecker","typescript"],"created_at":"2025-10-03T15:05:35.422Z","updated_at":"2026-04-11T01:25:40.472Z","avatar_url":"https://github.com/amir-valizadeh.png","language":"TypeScript","funding_links":[],"categories":["Development Utilities"],"sub_categories":["Code Analysis"],"readme":"# ts-analyzer\n\n![npm](https://img.shields.io/npm/v/ts-analyzer)\n![coverage](https://img.shields.io/badge/coverage-88%25-brightgreen)\n![license](https://img.shields.io/npm/l/ts-analyzer)\n\n`ts-analyzer` is a code analysis tool that checks your TypeScript and JavaScript projects. It looks at how safe your types are, how complex your code is, and finds common mistakes.\n\n---\n\n## Features\n\n- **Type Safety Checks**: It calculates your real type coverage. It tracks things like `any` usage, generics, and assertions.\n- **Code Complexity**: It checks how hard your code is to read by measuring cyclomatic complexity and nested blocks.\n- **Anti-patterns**: It spots bad practices like Magic Numbers, Callback Hell, Duplicate Code, huge files, and functions with too many parameters.\n- **Reports**: You can view the results as a nice HTML page, JSON, or just plain text in your terminal.\n- **Tested**: The project has around 88% test coverage using Vitest.\n\n---\n\n## How It Works\n\n### Type Safety\nThe tool looks at your code to see if your variables and parameters actually have types, or if they are just left as `any`.\n\n```text\n┌─────────────────────┐\n│ TypeScript Files    │\n└─────────┬───────────┘\n          │\n          ▼\n┌─────────────────────┐    ┌─────────────────────┐\n│ AST Analysis        │───\u003e│ Node Classification │\n└─────────┬───────────┘    └─────────┬───────────┘\n          │                          │\n          ▼                          ▼\n┌─────────────────────┐    ┌─────────────────────┐\n│ Explicitly Typed    │    │ Implicitly Typed    │\n│ Nodes               │    │ Nodes               │\n└─────────┬───────────┘    └─────────┬───────────┘\n          │                          │\n          └──────────┬──────────────┘\n                     │\n                     ▼\n┌─────────────────────┐    ┌─────────────────────┐\n│ Type Coverage       │\u003c───│ tsconfig.json       │\n│ Calculation         │    │ Analysis            │\n└─────────┬───────────┘    └─────────────────────┘\n          │\n          ▼\n┌─────────────────────┐\n│ \"any\" \u0026 Assertion   │\n│ Penalty Calculation │\n└─────────┬───────────┘\n          │\n          ▼\n┌─────────────────────┐\n│ Final Type Safety   │\n│ Score \u0026 Rating      │\n└─────────────────────┘\n```\n\n* **Score**: It calculates a score based on your type coverage percentage, minus a penalty if you use `any` or type assertions too much.\n* **tsconfig**: You get extra bonus points if your `tsconfig.json` has strict settings enabled.\n\n### Code Complexity\nIt looks at your functions to see how complicated they are:\n1. **Cyclomatic Complexity**: How many different paths your code can take.\n2. **Nesting Depth**: How many blocks are inside each other (to avoid Callback Hell).\n3. **Size**: How many lines and parameters your functions have.\n4. **Duplicate Code**: It checks for structural clones and exactly repeated function logic across multiple files in your codebase.\n\nBased on this, it gives a rating: \u003c30 is simple, 30-60 is moderate, and \u003e60 means it's too complex.\n\n### Why switch to `ts-analyzer`?\nThis tool is an upgrade from `react-loc-analyzer`. Instead of just counting lines, it actually understands your TypeScript code and gives you useful feedback to improve it.\n\n---\n\n## Quick Start\n\nYou can run it directly using npx:\n\n```bash\nnpx ts-analyzer /path/to/project\n```\n\nSome options you can use:\n- `-f, --format \u003ctype\u003e`: Choose between `text`, `json`, or `html`\n- `-e, --exclude \u003cpatterns\u003e`: Folders to ignore, separated by commas\n- `--no-safety` / `--no-complexity`: Skip specific checks to run faster\n\n## Example Reports\n\n### JSON Output\nWhen you run `npx ts-analyzer /path -f json`, it generates structured data you can use in your CI/CD pipelines:\n\n```json\n{\n  \"files\": 156,\n  \"totalLines\": 15234,\n  \"codeLines\": 12845,\n  \"typescriptSafety\": {\n    \"tsPercentage\": \"84.6\",\n    \"avgTypeCoverage\": \"92.3\",\n    \"totalAnyCount\": 12,\n    \"avgTypeSafetyScore\": 85,\n    \"overallComplexity\": \"Low\"\n  },\n  \"codeComplexity\": {\n    \"avgComplexity\": \"3.2\",\n    \"maxComplexity\": 12,\n    \"overallComplexity\": \"Low\",\n    \"codeSmells\": {\n      \"magicNumbers\": 0,\n      \"callbackHell\": 0,\n      \"excessiveParameters\": 0,\n      \"godFiles\": 0\n    },\n    \"duplicateCode\": {\n      \"totalClones\": 2,\n      \"totalDuplicateLines\": 24,\n      \"clones\": []\n    }\n  }\n}\n```\n\n### HTML Output\nWhen you run `npx ts-analyzer /path -f html`, it creates a `ts-analyzer-report.html` file. This acts as a beautiful visual dashboard with:\n- **Project Summary Cards**: Big, clear numbers for your total lines and code lines.\n- **Color-coded Progress Bars**: Visual bars for Type Coverage percentages (turns red if too low).\n- **Red/Green Indicators**: Fast visual checks for code smells like Callback Hell and God Files.\n\n## Config File\nYou don't have to type arguments every time. Just create a `ts-analyzer.config.json` in your project folder:\n```json\n{\n  \"safety\": true,\n  \"complexity\": true,\n  \"format\": \"text\",\n  \"exclude\": [\"node_modules\", \"dist\", \".next\"],\n  \"include\": [\".js\", \".ts\", \".tsx\"]\n}\n```\n\n## Development\nTo work on this project, install the dependencies and run the tests:\n```bash\nnpm install\nnpm test\nnpm run test:coverage\n```\n\n## License\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famir-valizadeh%2Fts-analyzer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famir-valizadeh%2Fts-analyzer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famir-valizadeh%2Fts-analyzer/lists"}