Skip to content

Commit

Permalink
Allow placeholder to be changed via config
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Jul 17, 2017
1 parent 32e43a0 commit d5d4e74
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/options.js
Expand Up @@ -9,7 +9,8 @@ export const defaultOptions: {
allowImportExportEverywhere: boolean,
allowSuperOutsideMethod: boolean,
plugins: Array<string>,
strictMode: any
strictMode: any,
placeholder: string
} = {
// Source type ("script" or "module") for different semantics
sourceType: "script",
Expand All @@ -30,6 +31,8 @@ export const defaultOptions: {
plugins: [],
// TODO
strictMode: null,
// Default placeholder for use with syntacticPlaceholder plugin
placeholder: "_"
};

// Interpret and default an options object
Expand Down
@@ -0,0 +1 @@
P
@@ -0,0 +1,64 @@
{
"type": "File",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"expression": {
"type": "PlaceholderExpression",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
}
}
}
],
"directives": []
}
}
@@ -0,0 +1,66 @@
{
"type": "File",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
}
},
"expression": {
"type": "Identifier",
"start": 0,
"end": 1,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 1
},
"identifierName": "P"
},
"name": "P"
}
}
],
"directives": []
}
}
@@ -0,0 +1,12 @@
{
"alternatives": {
"changePlaceholder": {
"allPlugins": true,
"excludePlugins": ["estree"],
"expected": "expected.changePlaceholder.json",
"parserOpts": {
"placeholder": "P"
}
}
}
}
4 changes: 4 additions & 0 deletions test/utils/TestRunner.js
Expand Up @@ -235,6 +235,10 @@ exports.Test = class Test {
}
}
}

if (alt.parserOpts) {
this.parserOpts = Object.assign({}, this.parserOpts, alt.parserOpts);
}
}

includePlugins(plugins, list) {
Expand Down

0 comments on commit d5d4e74

Please sign in to comment.