From 00f03bb3b0b9862f49e5cdc8164649d88adfa43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Pe=C3=B1a?= Date: Mon, 16 Jan 2017 04:34:23 -0500 Subject: [PATCH] Remove '*' as a plugin option (#301) --- src/parser/index.js | 35 --- .../jsx/regression/test-star-option/actual.js | 4 - .../regression/test-star-option/expected.json | 277 ------------------ .../regression/test-star-option/options.json | 3 - 4 files changed, 319 deletions(-) delete mode 100644 test/fixtures/jsx/regression/test-star-option/actual.js delete mode 100644 test/fixtures/jsx/regression/test-star-option/expected.json delete mode 100644 test/fixtures/jsx/regression/test-star-option/options.json diff --git a/src/parser/index.js b/src/parser/index.js index fc6a98bd4e..ef296c21af 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -3,19 +3,6 @@ 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) { @@ -43,10 +30,6 @@ export default class Parser extends Tokenizer { } hasPlugin(name: string): boolean { - if (this.plugins["*"] && frozenDeprecatedWildcardPluginList.indexOf(name) > -1) { - return true; - } - return !!this.plugins[name]; } @@ -54,25 +37,7 @@ export default class Parser extends Tokenizer { this[name] = f(this[name]); } - loadAllPlugins() { - // ensure flow plugin loads last - const pluginNames = Object.keys(plugins).filter((name) => name !== "flow"); - pluginNames.push("flow"); - - pluginNames.forEach((name) => { - const plugin = plugins[name]; - if (plugin) plugin(this); - }); - } - loadPlugins(pluginList: Array): { [key: string]: boolean } { - // TODO: Deprecate "*" option in next major version of Babylon - if (pluginList.indexOf("*") >= 0) { - this.loadAllPlugins(); - - return { "*": true }; - } - const pluginMap = {}; if (pluginList.indexOf("flow") >= 0) { diff --git a/test/fixtures/jsx/regression/test-star-option/actual.js b/test/fixtures/jsx/regression/test-star-option/actual.js deleted file mode 100644 index 7aeab8e0ec..0000000000 --- a/test/fixtures/jsx/regression/test-star-option/actual.js +++ /dev/null @@ -1,4 +0,0 @@ -function A(): void { - a::b; -
; -} diff --git a/test/fixtures/jsx/regression/test-star-option/expected.json b/test/fixtures/jsx/regression/test-star-option/expected.json deleted file mode 100644 index 1d0e4b71f8..0000000000 --- a/test/fixtures/jsx/regression/test-star-option/expected.json +++ /dev/null @@ -1,277 +0,0 @@ -{ - "type": "File", - "start": 0, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "program": { - "type": "Program", - "start": 0, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "sourceType": "script", - "body": [ - { - "type": "FunctionDeclaration", - "start": 0, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 0 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "id": { - "type": "Identifier", - "start": 9, - "end": 10, - "loc": { - "start": { - "line": 1, - "column": 9 - }, - "end": { - "line": 1, - "column": 10 - }, - "identifierName": "A" - }, - "name": "A" - }, - "generator": false, - "expression": false, - "async": false, - "params": [], - "returnType": { - "type": "TypeAnnotation", - "start": 12, - "end": 18, - "loc": { - "start": { - "line": 1, - "column": 12 - }, - "end": { - "line": 1, - "column": 18 - } - }, - "typeAnnotation": { - "type": "VoidTypeAnnotation", - "start": 14, - "end": 18, - "loc": { - "start": { - "line": 1, - "column": 14 - }, - "end": { - "line": 1, - "column": 18 - } - } - } - }, - "body": { - "type": "BlockStatement", - "start": 19, - "end": 45, - "loc": { - "start": { - "line": 1, - "column": 19 - }, - "end": { - "line": 4, - "column": 1 - } - }, - "body": [ - { - "type": "ExpressionStatement", - "start": 23, - "end": 28, - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 7 - } - }, - "expression": { - "type": "BindExpression", - "start": 23, - "end": 27, - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 6 - } - }, - "object": { - "type": "Identifier", - "start": 23, - "end": 24, - "loc": { - "start": { - "line": 2, - "column": 2 - }, - "end": { - "line": 2, - "column": 3 - }, - "identifierName": "a" - }, - "name": "a" - }, - "callee": { - "type": "Identifier", - "start": 26, - "end": 27, - "loc": { - "start": { - "line": 2, - "column": 5 - }, - "end": { - "line": 2, - "column": 6 - }, - "identifierName": "b" - }, - "name": "b" - } - } - }, - { - "type": "ExpressionStatement", - "start": 31, - "end": 43, - "loc": { - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 14 - } - }, - "expression": { - "type": "JSXElement", - "start": 31, - "end": 42, - "loc": { - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "openingElement": { - "type": "JSXOpeningElement", - "start": 31, - "end": 36, - "loc": { - "start": { - "line": 3, - "column": 2 - }, - "end": { - "line": 3, - "column": 7 - } - }, - "attributes": [], - "name": { - "type": "JSXIdentifier", - "start": 32, - "end": 35, - "loc": { - "start": { - "line": 3, - "column": 3 - }, - "end": { - "line": 3, - "column": 6 - } - }, - "name": "div" - }, - "selfClosing": false - }, - "closingElement": { - "type": "JSXClosingElement", - "start": 36, - "end": 42, - "loc": { - "start": { - "line": 3, - "column": 7 - }, - "end": { - "line": 3, - "column": 13 - } - }, - "name": { - "type": "JSXIdentifier", - "start": 38, - "end": 41, - "loc": { - "start": { - "line": 3, - "column": 9 - }, - "end": { - "line": 3, - "column": 12 - } - }, - "name": "div" - } - }, - "children": [] - } - } - ], - "directives": [] - } - } - ], - "directives": [] - } -} \ No newline at end of file diff --git a/test/fixtures/jsx/regression/test-star-option/options.json b/test/fixtures/jsx/regression/test-star-option/options.json deleted file mode 100644 index 2f56a201da..0000000000 --- a/test/fixtures/jsx/regression/test-star-option/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "plugins": ["*"] -}