Custom Rules · Quick recall Q&A
1 min readRapid overview
Quick recall Q&A
1. When would you create a custom ESLint rule vs using an existing one?
Create custom when:
- Enforcing company-specific conventions
- Preventing known issues specific to your codebase
- Automating repeated code review feedback
- Enforcing architectural boundaries
2. How do you ensure custom rules don't slow down linting?
- Cache AST traversal results
- Use specific node selectors instead of
Program:exitwhere possible - Avoid complex regex on every node
- Profile with
TIMING=1 eslint .
3. How do you test edge cases in custom rules?
- Use RuleTester with valid and invalid cases
- Test boundary conditions (empty files, nested structures)
- Test with TypeScript and JSX syntax
- Test auto-fix output matches expected