Remove '*' as a plugin option (#301)
This commit is contained in:
parent
7a3e717f15
commit
00f03bb3b0
@ -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<string>): { [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) {
|
||||
|
||||
@ -1,4 +0,0 @@
|
||||
function A(): void {
|
||||
a::b;
|
||||
<div></div>;
|
||||
}
|
||||
@ -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": []
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"plugins": ["*"]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user