Skip to content
Permalink
Browse files

Fix: no-octal should report NonOctalDecimalIntegerLiteral (fixes #11794

…) (#11805)

Examples: 08, 018, 08.1
  • Loading branch information...
mdjermanovic authored and platinumazure committed Jun 8, 2019
1 parent e4ab053 commit 87451f4779bc4c0ec874042b6854920f947ee258
Showing with 10 additions and 2 deletions.
  1. +1 −1 lib/rules/no-octal.js
  2. +9 −1 tests/lib/rules/no-octal.js
@@ -28,7 +28,7 @@ module.exports = {
return {

Literal(node) {
if (typeof node.value === "number" && /^0[0-7]/u.test(node.raw)) {
if (typeof node.value === "number" && /^0[0-9]/u.test(node.raw)) {
context.report({ node, message: "Octal literals should not be used." });
}
}
@@ -30,6 +30,14 @@ ruleTester.run("no-octal", rule, {
invalid: [
{ code: "var a = 01234;", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "a = 1 + 01234;", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "00", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] }
{ code: "00", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "08", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "09.1", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "09e1", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "09.1e1", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "018", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "019.1", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "019e1", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] },
{ code: "019.1e1", errors: [{ message: "Octal literals should not be used.", type: "Literal" }] }
]
});

0 comments on commit 87451f4

Please sign in to comment.
You can’t perform that action at this time.