1 | /**
|
2 | * @fileoverview Rule to flag when initializing octal literal
|
3 | * @author Ilya Volodin
|
4 | */
|
5 |
|
6 | ;
|
7 |
|
8 | //------------------------------------------------------------------------------
|
9 | // Rule Definition
|
10 | //------------------------------------------------------------------------------
|
11 |
|
12 | module.exports = {
|
13 | meta: {
|
14 | docs: {
|
15 | description: "disallow octal literals",
|
16 | category: "Best Practices",
|
17 | recommended: true,
|
18 | url: "https://eslint.org/docs/rules/no-octal"
|
19 | },
|
20 |
|
21 | schema: []
|
22 | },
|
23 |
|
24 | create(context) {
|
25 |
|
26 | return {
|
27 |
|
28 | Literal(node) {
|
29 | if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) {
|
30 | context.report({ node, message: "Octal literals should not be used." });
|
31 | }
|
32 | }
|
33 | };
|
34 |
|
35 | }
|
36 | };
|