Skip to main content

react_auditor/
cli.rs

1use clap::Parser;
2
3#[derive(Parser, Debug)]
4#[command(
5    name = "react-auditor",
6    version,
7    about = "A blazing-fast Rust CLI to scan JS/TS/React code for best practices, quality, and security issues",
8    long_about = "react-auditor — Scan JS/TS/React Code for Best Practices
9
10A blazing-fast Rust CLI powered by oxc to lint your React codebase for
11quality, correctness, security, performance, and accessibility issues.
12
13Categories (67 rules total):
14  quality        Code quality & clean code (13 rules)
15  react          React best practices & hooks (17 rules)
16  typescript     TypeScript strictness (9 rules)
17  security       Security vulnerabilities (7 rules)
18  nextjs         Next.js best practices (5 rules)
19  performance    Performance anti-patterns (5 rules)
20  accessibility  Accessibility violations (11 rules)
21
22Integrated with lint-staged and husky for pre-commit checks.
23
24Examples:
25  react-auditor                              Scan src/**/*.{js,jsx,ts,tsx}
26  react-auditor src/ --format json            Scan src/ output as JSON
27  react-auditor --rules react,typescript      Only React & TS rules
28  react-auditor --ignore node_modules,dist    Skip node_modules and dist
29  react-auditor --log audit.json              Write JSON log file
30   react-auditor --max-warnings 10             Fail on >10 warnings
31  react-auditor --fail-on warning             Fail on any violation
32  react-auditor --fix                         Auto-fix where supported
33
34Configuration: .rauditrc.toml, .rauditrc.json, or package.json#reactAuditor"
35)]
36pub struct Cli {
37    /// File paths or glob patterns to scan (default: src/**/*.{js,jsx,ts,tsx})
38    pub files: Vec<String>,
39
40    /// Path to config file (.rauditrc.toml, .rauditrc.json, package.json)
41    #[arg(short = 'c', long = "config")]
42    pub config: Option<String>,
43
44    /// Comma-separated rule categories to enable: quality, react, typescript, security, nextjs, performance, accessibility
45    #[arg(short = 'r', long = "rules")]
46    pub rules: Option<String>,
47
48    /// Fail on severity level: error, warning (exit code 1 if any violations at or above this level)
49    #[arg(long = "fail-on", default_value = "error")]
50    pub fail_on: String,
51
52    /// Path to output JSON log file
53    #[arg(short = 'l', long = "log")]
54    pub log: Option<String>,
55
56    /// Output format: stylish (default), json, compact
57    #[arg(short = 'f', long = "format", default_value = "stylish")]
58    pub format: String,
59
60    /// Max warnings before exiting with code 1
61    #[arg(short = 'w', long = "max-warnings")]
62    pub max_warnings: Option<u32>,
63
64    /// Only output errors (suppress warnings)
65    #[arg(short = 'q', long = "quiet")]
66    pub quiet: bool,
67
68    /// Comma-separated glob patterns to ignore (e.g. node_modules,dist,build)
69    #[arg(long = "ignore", default_value = "")]
70    pub ignore: String,
71
72    /// Auto-fix violations where supported (currently: no-var, no-console, no-empty-blocks)
73    #[arg(long = "fix")]
74    pub fix: bool,
75
76    /// Disable incremental caching (re-scan all files)
77    #[arg(long = "no-cache")]
78    pub no_cache: bool,
79
80    /// Watch mode: re-scan on file changes
81    #[arg(short = 'W', long = "watch")]
82    pub watch: bool,
83}