UNPKG

573 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to flag when initializing octal literal
3 * @author Ilya Volodin
4 */
5
6//------------------------------------------------------------------------------
7// Rule Definition
8//------------------------------------------------------------------------------
9
10module.exports = function(context) {
11
12 "use strict";
13
14 return {
15
16 "Literal": function(node) {
17 if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) {
18 context.report(node, "Octal literals should not be used.");
19 }
20 }
21 };
22
23};