1use clap::{Parser, Subcommand};
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 (71 rules total):
14 quality Code quality & clean code (13 rules)
15 react React best practices & hooks (19 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 testing Test quality & correctness (2 rules)
22
23Presets:
24 recommended Default severity for all rules
25 strict Bump many rules to Error
26 nextjs Focus on Next.js + React rules
27 all Maximum severity for all rules
28
29Integrated with lint-staged and husky for pre-commit checks.
30
31Examples:
32 react-auditor Scan src/**/*.{js,jsx,ts,tsx}
33 react-auditor src/ --format json Scan src/ output as JSON
34 react-auditor --rules react,typescript Only React & TS rules
35 react-auditor --preset strict Use strict preset
36 react-auditor --ignore node_modules,dist Skip node_modules and dist
37 react-auditor --log audit.json Write JSON log file
38 react-auditor --max-warnings 10 Fail on >10 warnings
39 react-auditor --fail-on warning Fail on any violation
40 react-auditor --fix Auto-fix where supported
41 react-auditor init Install pre-commit hook
42
43Configuration: .rauditrc.toml, .rauditrc.json, or package.json#reactAuditor"
44)]
45pub struct Cli {
46 pub files: Vec<String>,
48
49 #[arg(short = 'c', long = "config")]
51 pub config: Option<String>,
52
53 #[arg(short = 'r', long = "rules")]
55 pub rules: Option<String>,
56
57 #[arg(long = "preset", default_value = "recommended")]
59 pub preset: String,
60
61 #[arg(long = "fail-on", default_value = "error")]
63 pub fail_on: String,
64
65 #[arg(short = 'l', long = "log")]
67 pub log: Option<String>,
68
69 #[arg(short = 'f', long = "format", default_value = "stylish")]
71 pub format: String,
72
73 #[arg(short = 'w', long = "max-warnings")]
75 pub max_warnings: Option<u32>,
76
77 #[arg(short = 'q', long = "quiet")]
79 pub quiet: bool,
80
81 #[arg(long = "ignore", default_value = "")]
83 pub ignore: String,
84
85 #[arg(long = "fix")]
87 pub fix: bool,
88
89 #[arg(long = "no-cache")]
91 pub no_cache: bool,
92
93 #[arg(short = 'W', long = "watch")]
95 pub watch: bool,
96
97 #[arg(long = "docs")]
99 pub docs: bool,
100
101 #[command(subcommand)]
102 pub command: Option<Commands>,
103}
104
105#[derive(Subcommand, Debug)]
106pub enum Commands {
107 Init,
109}