API swallows 'yield' vs 'await'

I’m using Adonis in API mode and when I made a mistake in my code there was no error reported in the console…

I had a ‘yield’ in an ‘async’ controller routine and there was no error reported anywhere except an internal error of type ‘cors’ returned to the browser as a result to a REST [POST] call

I’m sure this is an edge case - but I always seem to hit them in my life

How can I get an error reported or an exception thrown as a result from adonis serve --dev ?

Install and use eslint and it will catch this sort of trivial syntax error for you. That’s not really the responsibility of the framework to ensure your code is good :slight_smile:

If you try to use yield in an inappropriate place (which, with current standards is basically using it at all), eslint will spit out a relevant error:

error Parsing error: The keyword 'yield' is reserved

I do agree about it not being Adonis’ job to fix my code :+1:t3:

and I do have eslint and tslint installed and running

I find in general that ‘compile-time’ errors are not reported when I am using adonis serve --dev

Is there a way to launch adonis so that such errors are reported?

thanks!

When I have eslint configured I find that my editor (vs code) will display lint errors automatically without explicitly running eslint.

Suppose you could also manually set up a watch script that runs lint and restarts Adonis on file change too.

As described by @willvincent I also implement eslint as a pre-commit hook to prevent any such errors being pushed into the pipeline.