Rules
no-eval
no-eval
Severity: error
Rule ID:Good:
Rule ID:
react-doctor/no-evalPrevents eval(), new Function(), and string-based code execution. These are major code injection risks.Why it’s dangerous:- Allows arbitrary code execution
- Common XSS vector
- Bypasses Content Security Policy
- Opens door to injection attacks
If you absolutely need dynamic code execution, use a sandboxed environment like VM2 or Web Workers with restricted permissions.
no-secrets-in-client-code
no-secrets-in-client-code
Severity: error
Rule ID:Good:Environment variable setup:False positive reduction:
This rule ignores variables ending with common UI-related suffixes like
Rule ID:
react-doctor/no-secrets-in-client-codeDetects hardcoded secrets, API keys, and tokens in client-side code. Client code is public and secrets should never be embedded.Why it’s dangerous:- Anyone can view client-side code
- API keys can be extracted and abused
- Can lead to unauthorized access
- May violate service ToS
- Stripe keys:
sk_live_*,sk_test_* - AWS keys:
AKIA[0-9A-Z]{16} - GitHub tokens:
ghp_*,gho_*,github_pat_* - GitLab tokens:
glpat-* - Slack tokens:
xox[bporas]-* - OpenAI keys:
sk-[a-zA-Z0-9]{32,} - Variables named:
apiKey,secret,token,password,credential
In Next.js, only variables prefixed with
NEXT_PUBLIC_ are exposed to the client. Never prefix secret keys with NEXT_PUBLIC_._LABEL, _TEXT, _TITLE, _NAME, _ID, _URL, etc.Additional Security Best Practices
While these rules catch common issues, follow these practices for secure React apps:API Keys
- Never commit
.envfiles to git - Use
.env.localfor local development - Use platform environment variables in production
- Rotate leaked keys immediately
Client vs Server
Content Security Policy
Implement CSP headers to prevent XSS:Input Sanitization
Always sanitize user input:React Security
- Avoid
dangerouslySetInnerHTML - Use the
jsx-a11y/no-script-urlrule - Enable the
react/no-dangerrule - Validate all user input server-side
Related Rules
- Correctness Rules - Common React bugs
- Next.js Rules - Next.js security patterns