Open ajafff opened 6 years ago
The rule should probably exclude tagged template literals, because the tag function can actually access the content of the original escape and may use that for some strange magic. https://tc39.github.io/proposal-template-literal-revision/
Octal escapes in string literal types are not parsed, the escape is therefore useless. But that may also just be a bug: https://github.com/Microsoft/TypeScript/issues/24209
In the git history of
trailing-newline.ts
you can find a mistake where I wrote'\UFEFF'
instead of\uFEFF
. The rule should check every string and template literal for escaped characters that are useless. Some background on escape sequences: https://mathiasbynens.be/notes/javascript-escapesIt doesn't need to check for useless escapes in regular expressions.
It should allow
'\${'
and`\${`
only if followed by{
to allow for escaping template literal substitutions (or suppress TSLint'sno-invalid-template-strings
).Note that this information is not present in the AST node, so you need to use
node.getText()
to get the raw source text.The autofixer could just remove the backslash.