Note: Never put the parser option at the top level of your configuration. Only use it inside overrides. Otherwise you effectively disable Prettier’s automatic file extension based parser inference. This forces Prettier to use the parser you specified for all types of files – even when it doesn’t make sense, such as trying to parse a CSS file as JavaScript.
When you run rnstlin those projects though, it gives the error:
Attempting to use prettier configuration detected at /Users/harry/code/itineraries/.prettierrc.yaml
No parser and no filepath given, using 'babel' the parser now but this will throw an error in the future. Please specify a parser or a filepath so one can be inferred.
Writing to /Users/harry/code/itineraries/mobile/storybook/storyLoader.js
Fix
Set the parser option to babel by default, even when there is a prettierrc file.
Testing
Installed project locally in a directory using rnstl
Ran yarn rnstl
Verified no error shows up
$ /Users/harry/code/itineraries/mobile/node_modules/.bin/rnstl
Attempting to use prettier configuration detected at /Users/harry/code/itineraries/.prettierrc.yaml
Writing to /Users/harry/code/itineraries/mobile/storybook/storyLoader.js
Problem
Many
.prettierrc
files exclude theparser
argument, because Prettier's docs recommend against including it at the top-level.When you run
rnstl
in those projects though, it gives the error:Fix
Set the parser option to babel by default, even when there is a prettierrc file.
Testing
rnstl
yarn rnstl