elderfo / react-native-storybook-loader

An automatic story loader for react-native-storybooks
https://github.com/elderfo/react-native-storybook-loader
MIT License
299 stars 27 forks source link

fix: Avoid prettier warning "No parser and no filepath given" #100

Closed hsource closed 3 years ago

hsource commented 3 years ago

Problem

Many .prettierrc files exclude the parser argument, because Prettier's docs recommend against including it at the top-level.

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

  1. Installed project locally in a directory using rnstl
  2. Ran yarn rnstl
  3. 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
hsource commented 3 years ago

@elderfo Thanks for pulling this! Would it be possible to do a new small release? I can then stop using my own fork for this

elderfo commented 3 years ago

Apologies for the delay. v2.0.3 has been published