Made an ESLint plugin for catching duplicate API routes
I've run into this issue more times than I'd like to admit, spending hours debugging why routes aren't working, only to discover I have:
- GET /users/:id (file A)
- GET /users/:userId (file B)
They're the same route, just with different param names. Which one actually runs? Depends on which file loads first.
Standard ESLint doesn't catch this, so I built a plugin that does.
It scans your entire codebase, understands router prefixes (app.use('/api', router)), and normalizes param names so: id and: userId are flagged as conflicts.
Works with Express, Fastify, and NestJS.
Just published it would love feedback from anyone working on larger APIs where this slips through code review.
npm install --save-dev eslint-plugin-route-guard
https://t.co/6A9EB1v1mw
Hope this saves someone else the debugging headache.
Be honest, developers:
When you see a new framework, do you:
- Immediately try to build something with it
- Scroll past and stick to what you know
- Overthink and never use it
Be honest, developers:
When you see a new framework, do you:
- Immediately try to build something with it
- Scroll past and stick to what you know
- Overthink and never use it