Overview
The SAAC Frontend template uses ESLint 9.x with the new flat config format (eslint.config.js). This modern configuration format provides better performance and simpler composition.
Configuration File
The ESLint configuration is defined ineslint.config.js:
eslint.config.js
This is ESLint’s flat config format (not the legacy
.eslintrc.js). Flat configs are simpler, more performant, and easier to understand.Configuration Breakdown
Global Ignores
- dist: Production build output directory
File Patterns
- All
.tsfiles (TypeScript) - All
.tsxfiles (TypeScript with JSX)
Plugins and Presets
JavaScript Recommended Rules
- No unused variables
- No undefined variables
- No unreachable code
- Proper use of
===vs== - And more…
TypeScript ESLint
typescript-eslint:
Key TypeScript Rules
Key TypeScript Rules
- @typescript-eslint/no-explicit-any: Warns against using
anytype - @typescript-eslint/no-unused-vars: Detects unused variables (TypeScript-aware)
- @typescript-eslint/no-unsafe-assignment: Prevents unsafe type assignments
- @typescript-eslint/no-unsafe-call: Prevents calling potentially unsafe functions
- @typescript-eslint/explicit-function-return-type: Enforces return type declarations
- @typescript-eslint/no-non-null-assertion: Warns on
!non-null assertions
typescript-eslint: TypeScript parser and rules@typescript-eslint/parser: Parses TypeScript syntax@typescript-eslint/eslint-plugin: TypeScript-specific lint rules
React Hooks Plugin
Enforces:
- Hooks must be called at the top level (not in loops, conditions, or nested functions)
- Hooks must be called in React function components or custom hooks
Verifies the dependency array in
useEffect, useMemo, useCallback, etc:- Warns when dependencies are missing
- Suggests adding missing dependencies
- Prevents stale closure bugs
The
recommended-latest preset uses the most up-to-date rules for React 19+.React Refresh Plugin
React Refresh Rules
React Refresh Rules
The Not allowed:This ensures Fast Refresh can reliably update components without full page reloads.
react-refresh/only-export-components rule enforces:Allowed exports:Language Options
ECMAScript version to parse. 2020 includes:
- Optional chaining (
?.) - Nullish coalescing (
??) BigIntPromise.allSettled- Dynamic
import()
Defines available global variables:
- browser:
window,document,console,fetch, etc. - Prevents “undefined variable” errors for browser APIs
Running ESLint
Lint Command
package.json
The
. argument means “lint the current directory and all subdirectories”.Auto-fix Issues
- Formatting issues
- Missing semicolons
- Unused imports
- Inconsistent quotes
Check Specific Files
IDE Integration
VS Code
Install the ESLint extension:.vscode/settings.json
- Real-time linting in the editor
- Auto-fix on save
- Inline error messages
Customizing Rules
Override Specific Rules
eslint.config.js
Add Additional Plugins
eslint.config.js
After adding plugins, install them with
npm install -D eslint-plugin-jsx-a11yDisable Rules for Specific Files
eslint.config.js
Ignoring Code
Ignore Specific Lines
Ignore Entire File
Ignore Files via Config
eslint.config.js
Common Issues
”Unsafe assignment of an any value”
Problem: TypeScript ESLint detects unsafe use of any types.
Solution: Provide explicit types or use type assertions:
