Closed kadikraman closed 9 months ago
We should validate any of the images that can be specified in Expo app config. Should we validate these images (that they are valid pngs, and whatever else) inside of doctor? Or is there another place that would make more sense? If in doctor, should we be running doctor before running a build? (or some subset of doctor checks?) [image (2).png](https://uploads.linear.app/4a409308-b1e3-45fc-94fd-9ef8703ee369/0e59982a-7226-477d-98fd-26e5a05eb897/2cd983a9-f174-43e8-b7b5-801a647f62e9)
Why
We wanted Expo Doctor to be able to warn against cases like this: https://expo.dev/builds/286155f5-b460-4982-b006-b59f1cd8151f
What's wrong here is:
.jpg
file extensions which aren't getting validatedprebuild
fails because they're trying to use awebp
asset which is not supportedHow
To handle each of those cases:
.png
file extension to.jpg
, expo doctor will still pass since it only looks at the file content, not the extension. I've added a new errorFILE_EXTENSION_MISMATCH
which will warn you if the mime type does not match eht file extensionwebp
image, it will always pass the Doctor check because of this line https://github.com/expo/expo-cli/blob/main/packages/schemer/src/index.ts#L196 - the library was unable to parse it and just failed silently. I updated the code to get the image data to use the example in their https://github.com/nodeca/probe-image-size#exampleI also updated the tests from js -> ts and refactored them slightly to be more future proof. I also added quite a few more tests for general image validation.
Test Plan
Tests! Many unit tests.