-
Notifications
You must be signed in to change notification settings - Fork 199
no-octal-literal
underdelivers
#653
Comments
Another problem spotted is errors like
I think this should be considered during fixing problems mentioned in original post. |
After second and third thoughts I think there is alternative approach:
Reasoning not to check number literals as I suggested earlier:
Not sure if linter rule should go against this recommendation and flag also
Reasoning to implement
And following question where |
+1 to pushing more ESLint rules into core, excluding formatting ones. It's a pretty common complaint that they're missing. So just to confirm @IllusionMH, your suggestion is that once that rule goes into core / tslint-eslint-rules / here, |
Yes, create new rule in core and deprecate one in this repo. |
💀 It's time! 💀TSLint is deprecated and no longer accepting pull requests other than security fixes. See #876. ☠️ 👋 It was a pleasure open sourcing with you! |
Bug Report
tslint-microsoft-contrib
version: 6.0.0-beta (master
branch)During migation of tests I've noticed some strange behviors in this rule.
TypeScript code being linted
First case is part of passing test
with
tslint.json
configuration:Actual behavior
First case: No error
Second case:
Octal literals should not be used: \0
Third case:
Octal literals should not be used: \777
Fourth case: No error
Expected behavior
First case:
Error because this string actually contains octal escape
\011
, and1
is just following character.And exactly this string will throw in
strict mode
Second case:
Should be no error because
\0
is allowed instrict mode
- it is NULL character (unless followed by decimal character)Interesting observation
'\09'
will throw because of octal escape in Edge & Opera (even if9
can't be part of octal escape, but still considered octal, details here)`\09`
will throw in Opera, but not in EdgeThird case:
Should be:
Octal literals should not be used: \77
Because octal escapes should not be bigger than
0o377
(255
) therefore only\77
is escape and7
is next character.'\777' === '?7'
Fourth case:
There are just no checks for octal literals (a.k.a. octal numeric literals) at all, however rule description is: "Do not use octal literals or escaped octal sequences." and code clearly only implements second part partially (it still allows escapes that will throw in
strict mode
).I think that checks for escapes should be strict by default with proper handling of
\0
, but for numbers I see two options:Add check for octal number literals by default.
Add
check-numbers
option that will enable check on octal literals.What do you think?
The text was updated successfully, but these errors were encountered: