route-params-must-be-defined - ESLint plugin rules
This rule requires properties accessed on req.params in an API route handler to correspond to a [param] folder in the route path.
Severity#
error. This rule is enabled in the recommended preset.
What it Targets#
This rule targets route.ts and route.js files in your project's src/api directory. It reports access to a req.params property that has no matching [param] folder in the route path.
The following code is reported by the rule, since the route has no foo parameter:
Instead, access a parameter defined by a [param] folder:
Why it's Important#
A route parameter is only available on when a folder defines it in the route path. Accessing an undefined parameter returns , which often points to a typo or a missing folder.
Learn more in the Route Parameters documentation.
Fixable#
This rule isn't auto-fixable.