question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Report "\8" and "\9" in no-octal-escape

See original GitHub issue

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:

"\8"

"foo\9bar"

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:

NonOctalDecimalEscapeSequence :: one of 89

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 or no-useless-escape? I think no-octal-escape, but there are arguments for no-useless-escape, too.
  • Can we make this change in a minor version?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Oct 14, 2020

no-nonoctal-escapes might sound like it would disallow all escapes that aren’t octal, including hexadecimal and unicode escape sequences.

Maybe no-nonoctal-decimal-escape? That would fully match the name from the specification.

0reactions
mdjermanoviccommented, Oct 16, 2020

Closing this in favor of #13765

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: "0"-prefixed octal literals and octal escape seq ...
Octal literals and octal escape sequences are deprecated and will throw a SyntaxError in strict mode. The standardized syntax uses a leading ...
Read more >
Octal numbers in c - GeeksforGeeks
In C octal escape sequence is represented by \ followed by three octal digits. Note that one or two octal digits are also...
Read more >
decoding octal escape sequences in input with awk
Using GNU awk for strtonum() and lots of meaningfully-named variables to show what each step does: $ cat tst.awk function octs2chars(str, ...
Read more >
regexp/no-octal | eslint-plugin-regexp
disallow octal escape sequence. ... This rule reports octal escapes. ... 8. 9. 10. 11. /* eslint regexp/no-octal: "error" */. /* ✓ GOOD...
Read more >
Octal - Wikipedia
The octal numeral system, or oct for short, is the base-8 number system, and uses the digits 0 to 7. This is to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found