diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4dd91759399b..23ab7c7adad5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -378,7 +378,7 @@ Note that the code shown in Chrome DevTools is compiled code and therefore diffe - After the ESTree PR is accepted, update [ast/spec.md](https://github.com/babel/babel/blob/master/packages/babel-parser/ast/spec.md). Note that there are differences between Babel AST and ESTree. In these cases, consistency with current Babel AST outweighs alignment to ESTree. Otherwise it should follow ESTree. - [ ] Implement parser plugins based on the new AST. The parser plugin name should be the unprefixed slug of the TC39 proposal URL in _camelcase_, i.e. `exportDefaultFrom` from `https://github.com/tc39/proposal-export-default-from`. - - [ ] Use the `this.expectPlugin("newSyntax")` check within `@babel/parser` to ensure your new plugin code only runs when that flag is turned on (not default behavior), and a friendly error is thrown if users forget to enable a plugin. + - [ ] Use the `this.expectPlugin("pluginName")` check within `@babel/parser` to ensure your new plugin code only runs when that flag is turned on (not default behavior), and a friendly error is thrown if users forget to enable a plugin. You can also supply an array pair to require certain configuration options, e.g., `this.expectPlugin(["pluginName", { configOption: value }])`. - [ ] Add failing/passing tests according to spec behavior - [ ] Add `@babel/syntax-new-syntax` package. You can copy `packages/babel-plugin-syntax-decimal` and replace `decimal` to `new-syntax`. - [ ] Add `@babel/syntax-new-syntax` to `@babel/standalone`. diff --git a/packages/babel-parser/src/parser/base.js b/packages/babel-parser/src/parser/base.js index 4c5c213ebd1b..522534ea5fff 100644 --- a/packages/babel-parser/src/parser/base.js +++ b/packages/babel-parser/src/parser/base.js @@ -31,12 +31,31 @@ export default class BaseParser { declare input: string; declare length: number; - hasPlugin(name: string): boolean { - return this.plugins.has(name); + // This method accepts either a string (plugin name) or an array pair + // (plugin name and options object). If an options object is given, + // then each value is non-recursively checked for identity with that + // plugin’s actual option value. + hasPlugin(pluginConfig: PluginConfig): boolean { + if (typeof pluginConfig === "string") { + return this.plugins.has(pluginConfig); + } else { + const [pluginName, pluginOptions] = pluginConfig; + if (!this.hasPlugin(pluginName)) { + return false; + } + const actualOptions = this.plugins.get(pluginName); + for (const key of Object.keys(pluginOptions)) { + if (actualOptions?.[key] !== pluginOptions[key]) { + return false; + } + } + return true; + } } getPluginOption(plugin: string, name: string) { - // $FlowIssue - if (this.hasPlugin(plugin)) return this.plugins.get(plugin)[name]; + return this.plugins.get(plugin)?.[name]; } } + +export type PluginConfig = string | [string, { [string]: any }]; diff --git a/packages/babel-parser/src/parser/expression.js b/packages/babel-parser/src/parser/expression.js index 3b0af6521f11..c9de69175558 100644 --- a/packages/babel-parser/src/parser/expression.js +++ b/packages/babel-parser/src/parser/expression.js @@ -448,7 +448,7 @@ export default class ExpressionParser extends LValParser { if ( op === tt.pipeline && - this.getPluginOption("pipelineOperator", "proposal") === "minimal" + this.hasPlugin(["pipelineOperator", { proposal: "minimal" }]) ) { if (this.state.type === tt._await && this.prodParam.hasAwait) { throw this.raise( @@ -1429,11 +1429,12 @@ export default class ExpressionParser extends LValParser { ): boolean { switch (pipeProposal) { case "hack": { - const pluginTopicToken = this.getPluginOption( + return this.hasPlugin([ "pipelineOperator", - "topicToken", - ); - return tokenLabelName(tokenType) === pluginTopicToken; + { + topicToken: tokenLabelName(tokenType), + }, + ]); } case "smart": return tokenType === tt.hash; @@ -2742,7 +2743,7 @@ export default class ExpressionParser extends LValParser { // of the infix operator `|>`. checkPipelineAtInfixOperator(left: N.Expression, leftStartPos: number) { - if (this.getPluginOption("pipelineOperator", "proposal") === "smart") { + if (this.hasPlugin(["pipelineOperator", { proposal: "smart" }])) { if (left.type === "SequenceExpression") { // Ensure that the pipeline head is not a comma-delimited // sequence expression. @@ -2843,8 +2844,7 @@ export default class ExpressionParser extends LValParser { // had before the function was called. withSmartMixTopicForbiddingContext(callback: () => T): T { - const proposal = this.getPluginOption("pipelineOperator", "proposal"); - if (proposal === "smart") { + if (this.hasPlugin(["pipelineOperator", { proposal: "smart" }])) { // Reset the parser’s topic context only if the smart-mix pipe proposal is active. const outerContextTopicState = this.state.topicContext; this.state.topicContext = { diff --git a/packages/babel-parser/src/parser/util.js b/packages/babel-parser/src/parser/util.js index 3ad3bc4b795e..a460650a3440 100644 --- a/packages/babel-parser/src/parser/util.js +++ b/packages/babel-parser/src/parser/util.js @@ -21,6 +21,7 @@ import ProductionParameterHandler, { } from "../util/production-parameter"; import { Errors, type ErrorTemplate, ErrorCodes } from "./error"; import type { ParsingError } from "./error"; +import type { PluginConfig } from "./base"; /*:: import type ScopeHandler from "../util/scope"; */ @@ -175,26 +176,38 @@ export default class UtilParser extends Tokenizer { /* eslint-enable @babel/development-internal/dry-error-messages */ } - expectPlugin(name: string, pos?: ?number): true { - if (!this.hasPlugin(name)) { + getPluginNamesFromConfigs(pluginConfigs: Array): Array { + return pluginConfigs.map(c => { + if (typeof c === "string") { + return c; + } else { + return c[0]; + } + }); + } + + expectPlugin(pluginConfig: PluginConfig, pos?: ?number): true { + if (!this.hasPlugin(pluginConfig)) { throw this.raiseWithData( pos != null ? pos : this.state.start, - { missingPlugin: [name] }, - `This experimental syntax requires enabling the parser plugin: '${name}'`, + { missingPlugin: this.getPluginNamesFromConfigs([pluginConfig]) }, + `This experimental syntax requires enabling the parser plugin: ${JSON.stringify( + pluginConfig, + )}.`, ); } return true; } - expectOnePlugin(names: Array, pos?: ?number): void { - if (!names.some(n => this.hasPlugin(n))) { + expectOnePlugin(pluginConfigs: Array, pos?: ?number): void { + if (!pluginConfigs.some(c => this.hasPlugin(c))) { throw this.raiseWithData( pos != null ? pos : this.state.start, - { missingPlugin: names }, - `This experimental syntax requires enabling one of the following parser plugin(s): '${names.join( - ", ", - )}'`, + { missingPlugin: this.getPluginNamesFromConfigs(pluginConfigs) }, + `This experimental syntax requires enabling one of the following parser plugin(s): ${pluginConfigs + .map(c => JSON.stringify(c)) + .join(", ")}.`, ); } } diff --git a/packages/babel-parser/src/plugin-utils.js b/packages/babel-parser/src/plugin-utils.js index 0e2d64c26e6f..cb750f16e0ab 100644 --- a/packages/babel-parser/src/plugin-utils.js +++ b/packages/babel-parser/src/plugin-utils.js @@ -1,19 +1,47 @@ // @flow import type Parser from "./parser"; +import type { PluginConfig } from "./parser/base"; -export type Plugin = string | [string, Object]; +export type Plugin = PluginConfig; -export type PluginList = $ReadOnlyArray; +export type PluginList = $ReadOnlyArray; export type MixinPlugin = (superClass: Class) => Class; -export function hasPlugin(plugins: PluginList, name: string): boolean { - return plugins.some(plugin => { - if (Array.isArray(plugin)) { - return plugin[0] === name; +// This function’s second parameter accepts either a string (plugin name) or an +// array pair (plugin name and options object). If an options object is given, +// then each value is non-recursively checked for identity with the actual +// option value of each plugin in the first argument (which is an array of +// plugin names or array pairs). +export function hasPlugin( + plugins: PluginList, + expectedConfig: PluginConfig, +): boolean { + // The expectedOptions object is by default an empty object if the given + // expectedConfig argument does not give an options object (i.e., if it is a + // string). + const [expectedName, expectedOptions] = + typeof expectedConfig === "string" ? [expectedConfig, {}] : expectedConfig; + + const expectedKeys = Object.keys(expectedOptions); + + const expectedOptionsIsEmpty = expectedKeys.length === 0; + + return plugins.some(p => { + if (typeof p === "string") { + return expectedOptionsIsEmpty && p === expectedName; } else { - return plugin === name; + const [pluginName, pluginOptions] = p; + if (pluginName !== expectedName) { + return false; + } + for (const key of expectedKeys) { + if (pluginOptions[key] !== expectedOptions[key]) { + return false; + } + } + return true; } }); } @@ -85,9 +113,10 @@ export function validatePlugins(plugins: PluginList) { ); } - const tupleSyntaxIsHash = - hasPlugin(plugins, "recordAndTuple") && - getPluginOption(plugins, "recordAndTuple", "syntaxType") === "hash"; + const tupleSyntaxIsHash = hasPlugin(plugins, [ + "recordAndTuple", + { syntaxType: "hash" }, + ]); if (proposal === "hack") { if (hasPlugin(plugins, "placeholders")) { diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json index 9bc4a478b7b1..b8b06c3a03ba 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default-token/options.json @@ -1,4 +1,3 @@ { - "sourceType": "module", "throws": "Unexpected token (1:18)" } diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default/options.json b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default/options.json index 689ff73f73f7..2d857a9e5c6b 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default/options.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-export-declaration/invalid-export-default/options.json @@ -1,3 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)" -} + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"exportDefaultFrom\". (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions-with-do-expressions/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions-with-do-expressions/options.json index 41eb0be83352..3f677f1889bd 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions-with-do-expressions/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions-with-do-expressions/options.json @@ -1,6 +1,6 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'asyncDoExpressions' (1:7)", + "throws": "This experimental syntax requires enabling the parser plugin: \"asyncDoExpressions\". (1:7)", "plugins": [ "doExpressions" ] -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions/options.json index 5af0fa0b53a9..e7470bdd4241 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/async-do-expressions/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'doExpressions' (1:7)", + "throws": "This experimental syntax requires enabling the parser plugin: \"doExpressions\". (1:7)", "plugins": [] -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/decimal/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/decimal/options.json index 146c207dab5b..d144bbc431ee 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/decimal/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/decimal/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'decimal' (1:2)" -} + "throws": "This experimental syntax requires enabling the parser plugin: \"decimal\". (1:2)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/decorators/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/decorators/options.json index 11f94afa3b7a..9a234d04ace0 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/decorators/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/decorators/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'decorators-legacy, decorators' (1:0)", + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"decorators-legacy\", \"decorators\". (1:0)", "plugins": [] } diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/do-expressions/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/do-expressions/options.json index 0aaae18db824..72d50bab4618 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/do-expressions/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/do-expressions/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'doExpressions' (1:1)", + "throws": "This experimental syntax requires enabling the parser plugin: \"doExpressions\". (1:1)", "plugins": [] } diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-default/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-default/options.json index e306a4f34cbf..09fd03ac7c3c 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-default/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/export-default/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)", + "throws": "This experimental syntax requires enabling the parser plugin: \"exportDefaultFrom\". (1:7)", "plugins": [] } diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions-dynamic/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions-dynamic/options.json index eab055ee2fb6..ba7532167878 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions-dynamic/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions-dynamic/options.json @@ -1,5 +1,5 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'importAssertions' (1:24)", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:24)", "sourceType": "module", "plugins": [] -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json index 25a75a1cd87e..2cf013869687 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/import-assertions/options.json @@ -1,5 +1,5 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'importAssertions' (1:27)", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)", "sourceType": "module", "plugins": [] -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json index 6fb1dbfc2421..a9fd5eec2660 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-attributes/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'moduleAttributes' (1:27)", + "throws": "This experimental syntax requires enabling the parser plugin: \"moduleAttributes\". (1:27)", "BABEL_8_BREAKING": false } diff --git a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-blocks/options.json b/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-blocks/options.json index 45ff422e6d5a..0fec31ecc92b 100644 --- a/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-blocks/options.json +++ b/packages/babel-parser/test/fixtures/experimental/_no-plugin/module-blocks/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'moduleBlocks' (1:18)" + "throws": "This experimental syntax requires enabling the parser plugin: \"moduleBlocks\". (1:18)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json index 5a8bd1e83883..ed51af8e6f31 100644 --- a/packages/babel-parser/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/decorators-2/export-decorated-class-without-plugin/options.json @@ -1,5 +1,5 @@ { + "plugins": null, "sourceType": "module", - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'decorators, decorators-legacy' (1:7)", - "plugins": null -} + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"decorators\", \"decorators-legacy\". (1:7)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/options.json b/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/options.json index 991da279e599..b7ac439f5c5d 100644 --- a/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/options.json +++ b/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'functionSent' (2:11)" -} + "throws": "This experimental syntax requires enabling the parser plugin: \"functionSent\". (2:11)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-expression/options.json b/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-expression/options.json index eee5abbf1f93..1ff4b447d2ff 100644 --- a/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-expression/options.json +++ b/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-function-keyword-expression/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'functionSent' (2:12)" -} + "throws": "This experimental syntax requires enabling the parser plugin: \"functionSent\". (2:12)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-inside-generator/options.json b/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-inside-generator/options.json index 9ce89a133dca..f1ef8a5a5777 100644 --- a/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-inside-generator/options.json +++ b/packages/babel-parser/test/fixtures/experimental/function-sent/disabled-inside-generator/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'functionSent' (2:18)" -} + "throws": "This experimental syntax requires enabling the parser plugin: \"functionSent\". (2:18)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json index 12d041cba6b3..28d88bde86ea 100644 --- a/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/import-assertions/without-plugin/options.json @@ -1,4 +1,5 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'importAssertions' (1:27)", - "plugins": [] + "plugins": [], + "sourceType": "module", + "throws": "This experimental syntax requires enabling the parser plugin: \"importAssertions\". (1:27)" } diff --git a/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json b/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json index 8645af2af8c7..12dd873d4537 100644 --- a/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json +++ b/packages/babel-parser/test/fixtures/experimental/module-attributes/without-plugin/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'moduleAttributes' (1:27)", + "throws": "This experimental syntax requires enabling the parser plugin: \"moduleAttributes\". (1:27)", "plugins": [] -} \ No newline at end of file +} diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/options.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/options.json index 5d8a6bb1204c..542c30051798 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/options.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/no-plugin-pipe/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'pipelineOperator' (1:2)" -} + "throws": "This experimental syntax requires enabling the parser plugin: \"pipelineOperator\". (1:2)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/not-enabled-hash/options.json b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/not-enabled-hash/options.json index 9565d05f7929..114fc061bb0c 100644 --- a/packages/babel-parser/test/fixtures/experimental/record-and-tuple/not-enabled-hash/options.json +++ b/packages/babel-parser/test/fixtures/experimental/record-and-tuple/not-enabled-hash/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'recordAndTuple' (1:0)" + "throws": "This experimental syntax requires enabling the parser plugin: \"recordAndTuple\". (1:0)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/experimental/throw-expression/not-enabled/options.json b/packages/babel-parser/test/fixtures/experimental/throw-expression/not-enabled/options.json index 47934f708223..02d3b11d97e7 100644 --- a/packages/babel-parser/test/fixtures/experimental/throw-expression/not-enabled/options.json +++ b/packages/babel-parser/test/fixtures/experimental/throw-expression/not-enabled/options.json @@ -1,3 +1,3 @@ { - "throws": "This experimental syntax requires enabling the parser plugin: 'throwExpressions' (2:3)" -} + "throws": "This experimental syntax requires enabling the parser plugin: \"throwExpressions\". (2:3)" +} \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/flow/expect-plugin/export-interface/options.json b/packages/babel-parser/test/fixtures/flow/expect-plugin/export-interface/options.json index 3f1eb56acdfa..29ce17f74f48 100644 --- a/packages/babel-parser/test/fixtures/flow/expect-plugin/export-interface/options.json +++ b/packages/babel-parser/test/fixtures/flow/expect-plugin/export-interface/options.json @@ -3,5 +3,5 @@ "plugins": [ "jsx" ], - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (1:7)" -} \ No newline at end of file + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"flow\", \"typescript\". (1:7)" +} diff --git a/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type-named/options.json b/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type-named/options.json index 80ced9a61c4f..cae6218d9f6e 100644 --- a/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type-named/options.json +++ b/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type-named/options.json @@ -3,5 +3,5 @@ "plugins": [ "jsx" ], - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (2:7)" -} \ No newline at end of file + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"flow\", \"typescript\". (2:7)" +} diff --git a/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type/options.json b/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type/options.json index 3f1eb56acdfa..29ce17f74f48 100644 --- a/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type/options.json +++ b/packages/babel-parser/test/fixtures/flow/expect-plugin/export-type/options.json @@ -3,5 +3,5 @@ "plugins": [ "jsx" ], - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (1:7)" -} \ No newline at end of file + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"flow\", \"typescript\". (1:7)" +} diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-fragment/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-fragment/options.json index fca5528e7115..d67ad2c142a9 100644 --- a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-fragment/options.json +++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-fragment/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (3:4)", - "plugins": [] + "plugins": [], + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"jsx\", \"flow\", \"typescript\". (3:4)" } diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/options.json index f11e7c5d0451..1adbcf23159d 100644 --- a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/options.json +++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-jsx-expression/options.json @@ -1,4 +1,4 @@ { "plugins": [], - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)" + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"jsx\", \"flow\", \"typescript\". (1:0)" } diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json index f11e7c5d0451..1adbcf23159d 100644 --- a/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json +++ b/packages/babel-parser/test/fixtures/jsx/errors/_no-plugin-type-param/options.json @@ -1,4 +1,4 @@ { "plugins": [], - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)" + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"jsx\", \"flow\", \"typescript\". (1:0)" } diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin-non-BMP-identifier/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin-non-BMP-identifier/options.json index 7e0538ba8978..1adbcf23159d 100644 --- a/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin-non-BMP-identifier/options.json +++ b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin-non-BMP-identifier/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)", - "plugins": [] + "plugins": [], + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"jsx\", \"flow\", \"typescript\". (1:0)" } diff --git a/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json index 7e0538ba8978..1adbcf23159d 100644 --- a/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json +++ b/packages/babel-parser/test/fixtures/jsx/errors/_no_plugin/options.json @@ -1,4 +1,4 @@ { - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'jsx, flow, typescript' (1:0)", - "plugins": [] + "plugins": [], + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"jsx\", \"flow\", \"typescript\". (1:0)" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json index c2396306e4fa..9fc0fe0199dd 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-default-from/options.json @@ -1,5 +1,7 @@ { - "plugins": ["placeholders"], + "plugins": [ + "placeholders" + ], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)" + "throws": "This experimental syntax requires enabling the parser plugin: \"exportDefaultFrom\". (1:7)" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json index 9bc164c502b0..28ed2f95dc25 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-2/options.json @@ -1,5 +1,7 @@ { - "plugins": ["placeholders"], + "plugins": [ + "placeholders" + ], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:16)" + "throws": "This experimental syntax requires enabling the parser plugin: \"exportDefaultFrom\". (1:16)" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json index 9bc164c502b0..28ed2f95dc25 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from-3/options.json @@ -1,5 +1,7 @@ { - "plugins": ["placeholders"], + "plugins": [ + "placeholders" + ], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:16)" + "throws": "This experimental syntax requires enabling the parser plugin: \"exportDefaultFrom\". (1:16)" } diff --git a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json index c2396306e4fa..9fc0fe0199dd 100644 --- a/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json +++ b/packages/babel-parser/test/fixtures/placeholders/export/default-named-from/options.json @@ -1,5 +1,7 @@ { - "plugins": ["placeholders"], + "plugins": [ + "placeholders" + ], "sourceType": "module", - "throws": "This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom' (1:7)" + "throws": "This experimental syntax requires enabling the parser plugin: \"exportDefaultFrom\". (1:7)" } diff --git a/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-interface/options.json b/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-interface/options.json index 6638a1d3d788..e72fb53bfa58 100644 --- a/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-interface/options.json +++ b/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-interface/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (1:7)" + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"flow\", \"typescript\". (1:7)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type-named/options.json b/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type-named/options.json index afcf32448a2c..52196018524f 100644 --- a/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type-named/options.json +++ b/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type-named/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (2:7)" + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"flow\", \"typescript\". (2:7)" } \ No newline at end of file diff --git a/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type/options.json b/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type/options.json index 6638a1d3d788..e72fb53bfa58 100644 --- a/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type/options.json +++ b/packages/babel-parser/test/fixtures/typescript/expect-plugin/export-type/options.json @@ -1,4 +1,4 @@ { "sourceType": "module", - "throws": "This experimental syntax requires enabling one of the following parser plugin(s): 'flow, typescript' (1:7)" + "throws": "This experimental syntax requires enabling one of the following parser plugin(s): \"flow\", \"typescript\". (1:7)" } \ No newline at end of file