javascriptreactjsreact-nativeeslinttypescript-eslint

How to allow IIFE syntax with ESlint in useCallback?


I have the following lint error :

Eslint forbid await/async

It does Insert ';' prettier/prettier error, if I let my IDE fix it, I have a semicolon on the first line:

;(async () => {

It then complains about another rule being violated: unnecessary semicolon and offer me to remove the semicolon, etc.

How can I allow IIFE syntax in my project?


Solution

  • There is no way to keep both prettier and a stylistic lint rule happy, as they are enforcing different conventions.

    If you're using prettier - you need to disable stylistic lint rules. Stylistic lint rules can and will conflict with prettier, as you've just seen.

    This is mentioned in the prettier docs.

    Using eslint-config-prettier can help you correct your config.