From 30545e883f65cdeac8aa4e13f23ea7fa1f3555e1 Mon Sep 17 00:00:00 2001 From: Andrew Levine Date: Tue, 6 Dec 2016 13:09:36 -0600 Subject: [PATCH] Freeze current plugins list for "*" option, and remove from README.md (#245) --- README.md | 2 -- src/parser/index.js | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f358020636..2303cc5398 100644 --- a/README.md +++ b/README.md @@ -107,8 +107,6 @@ require("babylon").parse("code", { ### Plugins -> You can use `"*"` to include everything (may be useful in certain cases) - - `jsx` - `flow` - `doExpressions` diff --git a/src/parser/index.js b/src/parser/index.js index f229a784b3..de7eb11ba4 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -3,6 +3,19 @@ import { getOptions } from "../options"; import Tokenizer from "../tokenizer"; export const plugins = {}; +const frozenDeprecatedWildcardPluginList = [ + "jsx", + "doExpressions", + "objectRestSpread", + "decorators", + "classProperties", + "exportExtensions", + "asyncGenerators", + "functionBind", + "functionSent", + "dynamicImport", + "flow" +]; export default class Parser extends Tokenizer { constructor(options: Object, input: string) { @@ -30,7 +43,11 @@ export default class Parser extends Tokenizer { } hasPlugin(name: string): boolean { - return !!(this.plugins["*"] || this.plugins[name]); + if (this.plugins["*"] && frozenDeprecatedWildcardPluginList.indexOf(name) > -1) { + return true; + } + + return !!this.plugins[name]; } extend(name: string, f: Function) { @@ -49,6 +66,7 @@ export default class Parser extends Tokenizer { } loadPlugins(pluginList: Array): { [key: string]: boolean } { + // TODO: Deprecate "*" option in next major version of Babylon if (pluginList.indexOf("*") >= 0) { this.loadAllPlugins();