diff --git a/packages/babel-core/src/transformation/file/options/option-manager.js b/packages/babel-core/src/transformation/file/options/option-manager.js index 17574b2cf4..3739fa6aa7 100644 --- a/packages/babel-core/src/transformation/file/options/option-manager.js +++ b/packages/babel-core/src/transformation/file/options/option-manager.js @@ -13,6 +13,7 @@ import cloneDeep from "lodash/lang/cloneDeep"; import clone from "lodash/lang/clone"; import merge from "../../../helpers/merge"; import config from "./config"; +import removed from "./removed"; import path from "path"; import fs from "fs"; @@ -222,7 +223,13 @@ export default class OptionManager { // check for an unknown option if (!option && this.log) { - this.log.error(`Unknown option: ${alias}.${key}`, ReferenceError); + let pluginOptsInfo = "Check out http://babeljs.io/docs/usage/options/ for more info"; + + if (removed[key]) { + this.log.error(`Using removed Babel 5 option: ${alias}.${key} - ${removed[key].message}`, ReferenceError); + } else { + this.log.error(`Unknown option: ${alias}.${key}. ${pluginOptsInfo}`, ReferenceError); + } } } diff --git a/packages/babel-core/src/transformation/file/options/removed.js b/packages/babel-core/src/transformation/file/options/removed.js new file mode 100644 index 0000000000..00a24ea61e --- /dev/null +++ b/packages/babel-core/src/transformation/file/options/removed.js @@ -0,0 +1,52 @@ +/* eslint max-len: 0 */ + +module.exports = { + "auxiliaryComment": { + "message": "Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`" + }, + "blacklist": { + "message": "Put the specific transforms you want in the `plugins` option" + }, + "breakConfig": { + "message": "This is not a necessary option in Babel 6" + }, + "experimental": { + "message": "Put the specific transforms you want in the `plugins` option" + }, + "externalHelpers": { + "message": "Use the `external-helpers` plugin instead. Check out http://babeljs.io/docs/plugins/external-helpers/" + }, + "extra": { + "message": "" + }, + "jsxPragma": { + "message": "use the `pragma` option in the `react-jsx` plugin . Check out http://babeljs.io/docs/plugins/transform-react-jsx/" + }, + // "keepModuleIdExtensions": { + // "message": "" + // }, + "loose": { + "message": "Specify the `loose` option for the relevant plugin you are using or use a preset that sets the option." + }, + "metadataUsedHelpers": { + "message": "Not required anymore as this is enabled by default" + }, + "modules": { + "message": "Use the corresponding module transform plugin in the `plugins` option. Check out http://babeljs.io/docs/plugins/#modules", + }, + "nonStandard": { + "message": "Use the `react-jsx` and `flow-strip-types` plugins to support JSX and Flow. Also check out the react preset http://babeljs.io/docs/plugins/preset-react/", + }, + "optional": { + "message": "Put the specific transforms you want in the `plugins` option" + }, + "sourceMapName": { + "message": "Use the `sourceMapTarget` option" + }, + "stage": { + "message": "Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets" + }, + "whitelist": { + "message": "Put the specific transforms you want in the `plugins` option" + } +}; diff --git a/packages/babel-core/test/option-manager.js b/packages/babel-core/test/option-manager.js index 6c5c37118e..222275ff9c 100644 --- a/packages/babel-core/test/option-manager.js +++ b/packages/babel-core/test/option-manager.js @@ -1,5 +1,6 @@ var assert = require("assert"); var OptionManager = require("../lib/transformation/file/options/option-manager"); +var Logger = require("../lib/transformation/file/logger"); suite("option-manager", function () { suite("memoisePluginContainer", function () { @@ -17,4 +18,30 @@ suite("option-manager", function () { ); }) }); + + suite("mergeOptions", function () { + test("throws for removed babel 5 options", function() { + return assert.throws( + function () { + var opt = new OptionManager(new Logger(null, "unknown")); + opt.init({ + 'randomOption': true + }); + }, + /Unknown option: base.randomOption/ + ); + }) + test("throws for removed babel 5 options", function() { + return assert.throws( + function () { + var opt = new OptionManager(new Logger(null, "unknown")); + opt.init({ + 'auxiliaryComment': true, + 'blacklist': true + }); + }, + /Using removed Babel 5 option: base.auxiliaryComment - Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`/ + ); + }) + }); });