diff --git a/packages/babel-parser/src/plugins/estree.js b/packages/babel-parser/src/plugins/estree.js index 3368b0f138..d9416b95e3 100644 --- a/packages/babel-parser/src/plugins/estree.js +++ b/packages/babel-parser/src/plugins/estree.js @@ -61,7 +61,7 @@ export default (superClass: Class): Class => directiveLiteral.loc.start, ); - expression.value = directiveLiteral.value; + expression.value = directiveLiteral.extra.expressionValue; expression.raw = directiveLiteral.extra.raw; stmt.expression = this.finishNodeAt( @@ -118,9 +118,10 @@ export default (superClass: Class): Class => const directive = super.stmtToDirective(stmt); const value = stmt.expression.value; - // Reset value to the actual value as in estree mode we want - // the stmt to have the real value and not the raw value - directive.value.value = value; + // Record the expression value as in estree mode we want + // the stmt to have the real value e.g. ("use strict") and + // not the raw value e.g. ("use\\x20strict") + this.addExtra(directive.value, "expressionValue", value); return directive; } diff --git a/packages/babel-parser/test/helpers/runFixtureTests.js b/packages/babel-parser/test/helpers/runFixtureTests.js index 2ce9e888d5..46d19c2a1a 100644 --- a/packages/babel-parser/test/helpers/runFixtureTests.js +++ b/packages/babel-parser/test/helpers/runFixtureTests.js @@ -83,14 +83,6 @@ export function runThrowTestsWithEstree(fixturesPath, parseFunction) { Object.keys(fixtures).forEach(function (name) { fixtures[name].forEach(function (testSuite) { testSuite.tests.forEach(function (task) { - if (!task.options.throws) { - const hasErrors = - !task.disabled && "errors" in JSON.parse(task.expect.code); - if (!hasErrors) { - return; - } - } - task.options.plugins = task.options.plugins || []; task.options.plugins.push("estree");