diff --git a/src/parser/index.js b/src/parser/index.js index 14d661b517..f229a784b3 100644 --- a/src/parser/index.js +++ b/src/parser/index.js @@ -37,7 +37,24 @@ export default class Parser extends Tokenizer { this[name] = f(this[name]); } - loadPlugins(pluginList: Array): Object { + loadAllPlugins() { + // ensure flow plugin loads last + const pluginNames = Object.keys(plugins).filter((name) => name !== "flow"); + pluginNames.push("flow"); + + pluginNames.forEach((name) => { + let plugin = plugins[name]; + if (plugin) plugin(this); + }); + } + + loadPlugins(pluginList: Array): { [key: string]: boolean } { + if (pluginList.indexOf("*") >= 0) { + this.loadAllPlugins(); + + return { "*": true }; + } + let pluginMap = {}; if (pluginList.indexOf("flow") >= 0) { diff --git a/test/fixtures/jsx/regression/test-*-option/actual.js b/test/fixtures/jsx/regression/test-*-option/actual.js new file mode 100644 index 0000000000..7aeab8e0ec --- /dev/null +++ b/test/fixtures/jsx/regression/test-*-option/actual.js @@ -0,0 +1,4 @@ +function A(): void { + a::b; +
; +} diff --git a/test/fixtures/jsx/regression/test-*-option/expected.json b/test/fixtures/jsx/regression/test-*-option/expected.json new file mode 100644 index 0000000000..1d0e4b71f8 --- /dev/null +++ b/test/fixtures/jsx/regression/test-*-option/expected.json @@ -0,0 +1,277 @@ +{ + "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-*-option/options.json b/test/fixtures/jsx/regression/test-*-option/options.json new file mode 100644 index 0000000000..2f56a201da --- /dev/null +++ b/test/fixtures/jsx/regression/test-*-option/options.json @@ -0,0 +1,3 @@ +{ + "plugins": ["*"] +}