@@ -23,7 +23,6 @@ const {
2323 isLineComment,
2424 isNextLineEmpty,
2525 needsHardlineAfterDanglingComment,
26- rawText,
2726 hasIgnoreComment,
2827 isCallExpression,
2928 isMemberExpression,
@@ -47,6 +46,7 @@ const {
4746 adjustClause,
4847 printRestSpread,
4948 printDefiniteToken,
49+ printDirective,
5050} = require ( "./print/misc.js" ) ;
5151const {
5252 printImportDeclaration,
@@ -215,11 +215,6 @@ function printPathNoParens(path, options, print, args) {
215215 case "EmptyStatement" :
216216 return "" ;
217217 case "ExpressionStatement" : {
218- // Detect Flow and TypeScript directives
219- if ( node . directive ) {
220- return [ printDirective ( node . expression , options ) , semi ] ;
221- }
222-
223218 if (
224219 options . parser === "__vue_event_binding" ||
225220 options . parser === "__vue_ts_event_binding"
@@ -429,7 +424,7 @@ function printPathNoParens(path, options, print, args) {
429424 case "Directive" :
430425 return [ print ( "value" ) , semi ] ; // Babel 6
431426 case "DirectiveLiteral" :
432- return printDirective ( node , options ) ;
427+ return printDirective ( node . extra . raw , options ) ;
433428 case "UnaryExpression" :
434429 parts . push ( node . operator ) ;
435430
@@ -813,25 +808,6 @@ function printPathNoParens(path, options, print, args) {
813808 }
814809}
815810
816- function printDirective ( node , options ) {
817- const raw = rawText ( node ) ;
818- const rawContent = raw . slice ( 1 , - 1 ) ;
819-
820- // Check for the alternate quote, to determine if we're allowed to swap
821- // the quotes on a DirectiveLiteral.
822- if ( rawContent . includes ( '"' ) || rawContent . includes ( "'" ) ) {
823- return raw ;
824- }
825-
826- const enclosingQuote = options . singleQuote ? "'" : '"' ;
827-
828- // Directives are exact code unit sequences, which means that you can't
829- // change the escape sequences they use.
830- // See https://github.com/prettier/prettier/issues/1555
831- // and https://tc39.github.io/ecma262/#directive-prologue
832- return enclosingQuote + rawContent + enclosingQuote ;
833- }
834-
835811function canAttachComment ( node ) {
836812 return (
837813 node . type &&
0 commit comments