Linting
Running ESLint
Check for linting errors:ESLint Configuration
The project uses a comprehensive ESLint setup defined in.eslintrc.js:
Extends
- expo - Expo-specific linting rules
- prettier - Ensures code formatting consistency
Plugins
- prettier - Enforces Prettier formatting rules
- import - Manages import/export statements
- react-compiler - Validates React Compiler compatibility
Key Rules
prettier/prettier
prettier/prettier
Severity: ErrorEnforces Prettier code formatting. Any formatting violations will cause the linter to fail.
react-compiler/react-compiler
react-compiler/react-compiler
Severity: ErrorValidates that code is compatible with the React Compiler. This ensures optimal performance and prevents runtime issues.
sort-imports
sort-imports
Severity: ErrorEnforces sorted imports within each import statement:Options:
ignoreCase: true- Case-insensitive sortingignoreDeclarationSort: true- Doesn’t sort import declarations
import/order
import/order
Severity: ErrorEnforces a specific order for import statements:
- External/Builtin - React, React Native, and third-party packages
- Internal -
@src/**imports - Sibling/Parent - Relative imports from parent or sibling directories
- Index - Index file imports
- React and React Native always come first
@src/**imports are grouped as internal
- Newlines between groups are required
- Alphabetically sorted (case-insensitive)
Prettier Configuration
Code formatting is handled by Prettier. Configuration is defined in the project root. Common formatting rules:- Single quotes for strings
- 2-space indentation
- Trailing commas
- Semicolons required
Pre-commit Hooks
The project uses Husky and lint-staged to enforce code quality before commits.Automated Checks
When you rungit commit, the following happens automatically:
If any hook fails, the commit will be aborted. Fix the issues and try again.
Bypassing Hooks
Testing
Test Framework
The project uses Jest with jest-expo preset for testing.Running Tests
Run tests in watch mode:Test Structure
Tests should be co-located with the code they test:Writing Tests
Example test structure:Code Quality Tools
Expo Doctor
Diagnose issues with your Expo project:- Dependency version compatibility
- Configuration issues
- Common setup problems
React Compiler Health Check
Verify React Compiler compatibility:Bundle Analysis
Analyze bundle size and composition:- Bundle size by module
- Dependency tree
- Performance bottlenecks
React Scan
Monitor component re-renders during development:- Unnecessary re-renders
- Performance issues
- Optimization opportunities
Continuous Integration
The project uses GitHub Actions for CI/CD:CodeQL Analysis
Automated security scanning runs on:- Push to main branch
- Pull requests
- Weekly schedule
Quality Checks
The project is monitored by:- Codacy - Code quality analysis
- CodeQL - Security vulnerability scanning
Best Practices
Before Committing
Before Submitting PR
Troubleshooting
ESLint Errors Won’t Fix
Ifnpm run lint:fix doesn’t resolve all issues:
- Check the specific error message
- Some rules can’t be auto-fixed and require manual changes
- Ensure you’re not violating React Compiler rules
Commit Hook Failures
If pre-commit hooks fail:- Read the error message carefully
- Run
npm run lint:fixmanually - Stage the auto-fixed files:
git add . - Try committing again
Test Failures
If tests fail:- Run tests in watch mode:
npm test - Check for async issues or missing mocks
- Ensure test environment is set up correctly
- Clear Jest cache if needed:
npx jest --clearCache