Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Scoper
A high-performance, rule-based analyzer for TypeScript/JavaScript codebases that helps identify patterns, potential issues, and enforce coding standards. Scoper specializes in analyzing code structures and dependencies to help maintain clean and maintainable codebases.
Overview
TypeScript Analyzer scans your codebase for patterns defined in rule implementations. It uses the OXC parser to quickly analyze TypeScript/JavaScript files and provide insights through a rich rule evaluation system.
Key features:
- Fast, parallel analysis of large codebases
- Extensible rule system with customizable rules
- JSON export for integration with CI/CD pipelines
- Configurable rule activation through command-line options or YAML config
Installation
Prerequisites
- Rust (nightly recommended)
- Cargo
Building from Source
# Clone the repository
# Build the project
Usage
Basic Command
Quick Start with Run Script
# Run analysis on a specific directory
Command Line Options
OPTIONS:
-v, --verbose Enable verbose output
-e, --extensions <EXTS> File extensions to include (default: "ts,tsx")
--no-rules Disable rules-based analysis
--rule-debug Enable verbose rule debugging output
-s, --severity <LEVEL> Minimum severity level to report (error, warning, info)
--enable-rule <RULE_ID> Enable specific rule by ID (can be used multiple times)
--disable-rule <RULE_ID> Disable specific rule by ID (can be used multiple times)
--enable-tag <TAG> Enable rules with specific tag (can be used multiple times)
--disable-tag <TAG> Disable rules with specific tag (can be used multiple times)
--export-json <FILE> Export rule findings to a JSON file
-h, --help Print help
-V, --version Print version
Example Commands
# Analyze a specific directory with verbose output
# Only analyze JavaScript files
# Enable only specific rules
# Disable specific rules
# Enable rules by tag
# Export findings to JSON
Configuration
You can configure the analyzer using a rules.json
file:
The rules object maps rule names to their configuration. There are three ways to specify a rule's configuration:
"rule-name": "error"
or"rule-name": "warn"
- Simple rule activation with specified severity"rule-name": ["error", { options }]
- Rule with severity and configuration options"rule-name": ["warn", { options }]
- Rule with severity and configuration options
Command Line Configuration
For simple use cases, you can enable rules from the command line:
# Enable simple rules
# Enable a single rule
For more complex configuration including rule options and severity levels, use a rules.json file:
Rule Configuration Options
Different rules accept different configuration options:
angular-input-count
Controls the maximum number of Angular inputs allowed in a component.
Understanding Rule Results
When you run the analyzer, it will display rule results in the terminal:
Rule Results:
2 Error findings:
typescript-assertion-detection: 901 matches
import-count-error: 138 matches
1 Warning findings:
import-rxjs: 4 matches
Summary: 2 errors, 1 warnings
For each rule match, the analyzer counts individual occurrences. If a file has multiple matches for a rule, each match is counted separately.
JSON Export
When using the --export-json
option or the export_json
configuration, the analyzer will create a JSON file with detailed findings:
Built-in Rules
The analyzer includes several built-in rules, including:
typescript-assertion-detection
: Detects TypeScript type assertionsimport-rxjs
: Detects imports from the 'rxjs' moduleimport-rxjs-operators
: Detects imports from 'rxjs/operators'import-count
: Counts the number of import statements in a fileangular-decorators-detection
: Detects Angular property decorators
Creating Custom Rules
You can create custom rules by implementing the Rule
trait. Here's a simple example:
use Arc;
use HashMap;
use Result;
use ;
use crate;
After implementing your custom rule, you can register it with the rule registry in src/rules/custom/mod.rs
.
Performance
The analyzer is designed for high performance:
- Uses parallel processing with Rayon
- Employs the MiMalloc memory allocator for faster memory operations
- Processes thousands of files per second on modern hardware
License
[Add your license information here]