Skip to content
Advertisement

Difference betweeen Two line of same code

can someone explain to me the differenec between the two line of code. In my atom editor the prettier changes the first to second.

(await fetchSearchResults(state.requestConfig, context))?.facilities ?? [] ) 

and

await fetchSearchResults(state.requestConfig, context)?.facilities ?? [] )

Advertisement

Answer

Prettier changes the whole thing to follow the rules given in a Prettier config file.
In your specific case, the (await fetchSearchResults(state.requestConfig, context)) is useless, hence why Prettier strips it.

Meanwhile, it may be quite important in a classic async context as explained in the comment below. Maybe the optional chaining is somehow tricking Prettier here, not sure.


The default Vue2 ESlint configuration comes with plugin:vue/essential and eslint:recommended as defaults.
Here is a link where you could get more details as of why.

If it’s Prettier only, check the options part of the documenation or a .prettierrc config file in your project (or above).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement