darraghoriordan / eslint-plugin-nestjs-typed

Some eslint rules for working with NestJs projects
http://www.darraghoriordan.com
174 stars 34 forks source link

New Rule Suggestion: forbids `app.get()` for APP_* tokens #119

Open micalevisk opened 12 months ago

micalevisk commented 12 months ago

as mentioned here: https://github.com/nestjs/docs.nestjs.com/issues/2178 we can't do app.get(APP_GUARD)/app.get(APP_PIPE)/app.get(APP_FILTER)/app.get(APP_INTERCEPTOR) due to how those "providers" works. I tested it myself.

thus I'd like to have a rule that forbids calling app.get over then so we can prevent misusages that will lead to runtime errors

Also, I believe we can extend this to @Inject(APP_*) as well due to the same reason

darraghoriordan commented 11 months ago

yea i understand what you mean. This kind of thing is perfect for ESLint to catch for sure.

It could be as simple as matching the strings because its unlikely a dev would call a pipe APP_PIPE. It might cause issues but the rule could be disabled individually for the line in those cases.