From db28c18458ef8f62e80d9cc9ddbeb2be0a943a92 Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Wed, 22 Nov 2017 18:23:28 -0800 Subject: [PATCH] Disallow nested '.env' blocks since they are useless. --- packages/babel-core/src/config/options.js | 3 +++ packages/babel-core/test/api.js | 8 -------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/babel-core/src/config/options.js b/packages/babel-core/src/config/options.js index 5ca278b14b..450f52b8e8 100644 --- a/packages/babel-core/src/config/options.js +++ b/packages/babel-core/src/config/options.js @@ -206,6 +206,9 @@ export function validate(type: OptionsType, opts: {}): ValidatedOptions { if (type !== "arguments" && ROOT_VALIDATORS[key]) { throw new Error(`.${key} is only allowed in root programmatic options`); } + if (type === "env" && key === "env") { + throw new Error(`.${key} is not allowed inside another env block`); + } const validator = COMMON_VALIDATORS[key] || diff --git a/packages/babel-core/test/api.js b/packages/babel-core/test/api.js index cad0308862..215a8960f1 100644 --- a/packages/babel-core/test/api.js +++ b/packages/babel-core/test/api.js @@ -296,12 +296,6 @@ describe("api", function() { development: { passPerPreset: true, presets: [pushPreset("argthree"), pushPreset("argfour")], - env: { - development: { - passPerPreset: true, - presets: [pushPreset("argfive"), pushPreset("argsix")], - }, - }, }, }, }); @@ -327,8 +321,6 @@ describe("api", function() { "fourteen;", "fifteen;", "sixteen;", - "argfive;", - "argsix;", "argthree;", "argfour;", "seven;",