New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report "\8" and "\9" in no-octal-escape #13740
Comments
\8
and \9
in no-octal-escape
Given that the spec explicitly defines them as "non-octal", then I'd vote for making a change to |
To expand on why I'm slightly more in favor of
On the other hand, |
If this is added to no-octal-escape as a default behavior then I think it’s a breaking change. I dug into this a bit. “disallowed” in this case simply means it’s not expanded, so \9 is interpreted as \9 rather than 9, so no-useless-escape doesn’t make sense. The escape isn’t useless because the slash isn’t ignored. I’m more of the mind that this should be a new rule rather than modifying an existing one. The fact that \8 and \9 look like octal escapes doesn’t seem like a good enough reason to add to no-octal-escape. |
I believe the latest spec https://tc39.es/ecma262 says that "\9" === "9" // true Either way, this looks like a different category than just "useless" escape, and while I still think that Any ideas for the name, maybe |
I’d go no-nonoctal-escapes to keep the terminology consistent. |
no-nonoctal-escapes might sound like it would disallow all escapes that aren't octal, including hexadecimal and unicode escape sequences. Maybe |
Works for me. |
Closing this in favor of #13765 |
What rule do you want to change?
no-octal-escape
Does this change cause the rule to produce more or fewer warnings?
more
How will the change be implemented? (New option, new default behavior, etc.)?
new default behavior
Please provide some example code that this change will affect:
What does the rule currently do for this code?
no errors
What will the rule do after it's changed?
errors
Are you willing to submit a pull request to implement this change?
Yes.
\8
and\9
used to be invalid (unspecified) escape sequences in string literals. But, they were not not explicitly disallowed language extensions, and all engines used to allow"\8"
and"\9"
, treating them as just"8"
and"9"
(i.e., as useless escapes).Now, as of tc39/ecma262#2054, they are defined in Annex B as NonOctalDecimalEscapeSequence:
and thus required in browsers, but only in non-strict mode. They are now explicitly disallowed in strict mode.
Although only recently added to the spec, the spec treats them as a legacy feature and in the same context as LegacyOctalEscapeSequence, so I think they should be reported by
no-octal-escape
.Questions:
no-octal-escape
orno-useless-escape
? I thinkno-octal-escape
, but there are arguments forno-useless-escape
, too.The text was updated successfully, but these errors were encountered: