escaped.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Unnecessary escapes. (adapted from tests/quotes/strings.js)
  2. // Note that in directives, unnecessary escapes should be preserved.
  3. // See https://github.com/prettier/prettier/issues/1555
  4. '\'';
  5. '\"';
  6. "\'";
  7. "\"";
  8. '\\';
  9. '\a';
  10. "hol\a"
  11. 'hol\a'
  12. "hol\\a (the a is not escaped)"
  13. 'hol\\a (the a is not escaped)'
  14. "multiple \a unnecessary \a escapes"
  15. 'multiple \a unnecessary \a escapes'
  16. "unnecessarily escaped character preceded by escaped backslash \\\a"
  17. 'unnecessarily escaped character preceded by escaped backslash \\\a'
  18. "unescaped character preceded by two escaped backslashes \\\\a"
  19. 'unescaped character preceded by two escaped backslashes \\\\a'
  20. "\a\a" // consecutive unnecessarily escaped characters
  21. '\a\a' // consecutive unnecessarily escaped characters
  22. 'escaped \u2030 \‰ (should still stay escaped)'
  23. // Meaningful escapes
  24. // Commented out to avoid `SyntaxError: Octal literals are not allowed in strict mode.`
  25. // "octal escapes \0 \1 \2 \3 \4 \5 \6 \7"
  26. // 'octal escapes \0 \1 \2 \3 \4 \5 \6 \7'
  27. "meaningfully escaped alphabetical characters \n \r \v \t \b \f \u2713 \x61"
  28. 'meaningfully escaped alphabetical characters \n \r \v \t \b \f \u2713 \x61'
  29. 'escaped newline \
  30. '
  31. 'escaped carriage return \
  32. '
  33. 'escaped \u2028 \
'
  34. 'escaped \u2029 \
'