.ts, .tsx) and JavaScript files using tree-sitter parsing.
Features
TypeScript analysis includes:- Dead code detection: Unused functions, classes, and methods
- Security scanning:
eval(), unsafeinnerHTML - Complexity analysis: Cyclomatic complexity for functions
How It Works
Skylos uses tree-sitter with the TypeScript grammar to parse files into a syntax tree. This enables accurate analysis without requiring a full TypeScript compiler setup.Parsing Pipeline
- Read source file as bytes
- Parse with tree-sitter TypeScript grammar
- Query for definitions (functions, classes, methods)
- Query for references (calls, property accesses)
- Cross-reference to find unused definitions
Dead Code Detection
Supported Definitions
| Type | Detection Pattern |
|---|---|
| Functions | function foo() {} |
| Arrow functions | const foo = () => {} |
| Classes | class Foo {} |
| Methods | class { method() {} } |
Export Awareness
Exported definitions are treated differently:Security Rules
SKY-D501: eval()
Detects use ofeval(), which can execute arbitrary code.
SKY-D502: innerHTML
Detects unsafeinnerHTML assignments that could enable XSS.
Quality Rules
SKY-Q501: Function Complexity
Measures cyclomatic complexity for TypeScript functions. Complexity nodes:if_statementfor_statementwhile_statementswitch_casecatch_clauseternary_expression
Configuration
Override TypeScript thresholds separately from Python:Running Analysis
Skylos automatically detects TypeScript files in the scan path:File Extensions
Supported extensions:.ts- TypeScript.tsx- TypeScript with JSX
Output Example
Limitations
Not Supported
- Type checking: Skylos doesn’t validate TypeScript types
- Import resolution: Cross-file imports are not fully resolved
- Framework-specific patterns: React hooks, Angular decorators are not specially handled
- JSDoc: Documentation comments are not analyzed
