ESLint
Create eslint.config.mjs in your project root:
import { fileURLToPath } from 'node:url';import { dirname } from 'node:path';import createConfig from '@presencelearning/frontend-config/eslint';
const __dirname = dirname(fileURLToPath(import.meta.url));export default createConfig(__dirname);Features
Section titled “Features”- Modern ESLint 9 flat config format
- Angular component/directive naming conventions (
pl-prefix) - Essential code quality rules (
no-var,prefer-const,eqeqeq, etc.) - TypeScript best practices and type checking
- Import ordering and organization
- GraphQL linting support (optional)
- Optimized for performance
Migration from existing config
Section titled “Migration from existing config”- Remove old ESLint config files (
.eslintrc,.eslintrc.json,.eslintrc.js) - Install
@presencelearning/frontend-config - Create new
eslint.config.mjsimporting this package (ESLint 9 flat config format) - Upgrade to ESLint 9 and TypeScript ESLint 8
- Run
npm run lint:fixto auto-fix issues
Troubleshooting
Section titled “Troubleshooting”ESLint can’t find tsconfig
Section titled “ESLint can’t find tsconfig”The config requires the project root directory to resolve tsconfig files correctly. Make sure you’re passing __dirname to the config factory:
import { fileURLToPath } from 'node:url';import { dirname } from 'node:path';import createConfig from '@presencelearning/frontend-config/eslint';
const __dirname = dirname(fileURLToPath(import.meta.url));export default createConfig(__dirname); // ← Must pass __dirnameThis ensures the TypeScript parser can find tsconfig.json, tsconfig.app.json, and tsconfig.spec.json in your project root.
Prettier conflicts with ESLint
Section titled “Prettier conflicts with ESLint”This config includes eslint-config-prettier to disable conflicting rules. Always run Prettier after ESLint:
npm run lint:fix && npm run format