babel/minify

Options validation for preset

Aperta

#436 aperta il 20 feb 2017

 (1 commento) (0 reazioni) (0 assegnatari)JavaScript (223 fork)batch import
enhancementgood first issuehelp wanted

Metriche repository

Star
 (4377 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Validate the entire tree of options passed to preset.

Maybe, each plugin can export a list of options that only babili preset understands and we can validate them only when using the preset and not when using the plugin separately.

module.exports = function plugin() {};
module.exports.options = PropTypes.object({
  n: PropTypes.number
});

Or, this can be implemented in babel - where validator is built into babel for plugins and presets.

function plugin({ PropTypes }) {
  return {
    visitor: {...}
    options: PropTypes.object({
      n: PropTypes.number
    })
  };
}

Guida contributor