Require decoratorsBeforeExport option for decorators (#8465)

* Require decoratorsBeforeExport option for syntax-decorators

* Also babylon

* Enable test
This commit is contained in:
Nicolò Ribaudo
2018-08-15 09:04:52 +02:00
committed by GitHub
parent 1e0b649485
commit d79b5eeeff
14 changed files with 111 additions and 24 deletions

View File

@@ -41,13 +41,26 @@ export function getPluginOption(
const PIPELINE_PROPOSALS = ["minimal"];
export function validatePlugins(plugins: PluginList) {
if (
hasPlugin(plugins, "decorators") &&
hasPlugin(plugins, "decorators-legacy")
) {
throw new Error(
"Cannot use the decorators and decorators-legacy plugin together",
if (hasPlugin(plugins, "decorators")) {
if (hasPlugin(plugins, "decorators-legacy")) {
throw new Error(
"Cannot use the decorators and decorators-legacy plugin together",
);
}
const decoratorsBeforeExport = getPluginOption(
plugins,
"decorators",
"decoratorsBeforeExport",
);
if (decoratorsBeforeExport == null) {
throw new Error(
"The 'decorators' plugin requires a" +
" 'decoratorsBeforeExport' option, whose value must be a boolean.",
);
} else if (typeof decoratorsBeforeExport !== "boolean") {
throw new Error("'decoratorsBeforeExport' must be a boolean.");
}
}
if (hasPlugin(plugins, "flow") && hasPlugin(plugins, "typescript")) {