Introduction
TSLint has been deprecated for years, but many legacy projects (and their forks) still rely on it. In this post, I’ll show you how we migrated our repository to ESLint using the modern Flat Configuration, improving both performance and developer experience.
Why Migrate?
- Deprecated Stack: TSLint no longer receives updates.
- Improved Performance: ESLint (especially with Flat Config) is significantly faster.
- Modern Ecosystem: Better compatibility with modern tooling (
Prettier,Jest,VS Code). - Stricter Type Safety: Catch common bugs like floating promises and unsafe type assignments.
The Migration Journey
Step 1: Out with the Old
I started by clearing out the legacy TSLint packages and the tslint.json file.
pnpm remove tslint tslint-config-prettier
rm tslint.jsonStep 2: In with the New
I installed the core ESLint dependencies and the new typescript-eslint toolkit.
pnpm add -D eslint typescript-eslint globalsStep 3: Configuring for the Future
The new eslint.config.mjs setup is much cleaner and more modular. Here’s a snippet of our final configuration: Link
Step 4: Fixing the Fun Stuff
The migration revealed several hidden issues in our codebase:
- Floating Promises: Discovered several unawaited calls that could cause race conditions.
- Type Safety: Tightened up areas where
anywas being used loosely.
Results
- [*] Faster linting: Noticeably faster.
- [*] Better DX: Integrated seamlessly with our IDEs.
- [*] Cleaner Code: Caught several bugs that TSLint missed.
Conclusion
Don’t wait! Migrating to ESLint is an investment in your project’s long-term health. The Flat Config system makes the setup more intuitive than ever.
Follow my journey at Fastify API with TypeScript
