expo / config-plugins

Out-of-tree Expo config plugins for packages that haven't adopted the config plugin system yet.
445 stars 95 forks source link

[ios-stickers] Added JSON schema validation #41

Closed EvanBacon closed 2 years ago

EvanBacon commented 2 years ago

Experiment with using schema-utils from Webpack to validate the TypeScript properties and throw an error during introspection and prebuilding.

This looks something like:

Invalid options object. @config-plugins/ios-stickers has been initialized using an options object that does not match the API schema.
 - options.stickers[0] should be one of these:
   string | object { image, name?, accessibilityLabel? }
   Details:
    * options.stickers[0] should be a string.
    * options.stickers[0] should be an object:
      object { image, name?, accessibilityLabel? }
 - options.columns should be one of these:
   2 | 3 | 4
ValidationError: Invalid options object. @config-plugins/ios-stickers has been initialized using an options object that does not match the API schema.
 - options.stickers[0] should be one of these:
   string | object { image, name?, accessibilityLabel? }
   Details:
    * options.stickers[0] should be a string.
    * options.stickers[0] should be an object:
      object { image, name?, accessibilityLabel? }
 - options.columns should be one of these:
   2 | 3 | 4
    at Object.validate (/Users/evanbacon/Documents/GitHub/config-plugins/packages/ios-stickers/node_modules/schema-utils/dist/validate.js:115:11)
    at withStickerPack (/Users/evanbacon/Documents/GitHub/config-plugins/packages/ios-stickers/build/withStickerPack.js:36:20)
    at withStaticPlugin (/Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/config-plugins/src/plugins/withStaticPlugin.ts:138:12)
    at /Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/config-plugins/src/plugins/withPlugins.ts:20:43
    at Array.reduce (<anonymous>)
    at withPlugins (/Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/config-plugins/src/plugins/withPlugins.ts:20:18)
    at withConfigPlugins (/Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/config/src/plugins/withConfigPlugins.ts:19:14)
    at fillAndReturnConfig (/Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/config/src/Config.ts:126:35)
    at getConfig (/Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/config/src/Config.ts:186:12)
    at getPrebuildConfig (/Users/evanbacon/.nvm/versions/node/v16.13.0/lib/node_modules/expo-cli/node_modules/@expo/prebuild-config/src/getPrebuildConfig.ts:47:34)