]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-octal.js
eec56919f1eb7d36a5f3e22426cef86b278d70f4
[pve-eslint.git] / eslint / lib / rules / no-octal.js
1 /**
2 * @fileoverview Rule to flag when initializing octal literal
3 * @author Ilya Volodin
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Rule Definition
10 //------------------------------------------------------------------------------
11
12 /** @type {import('../shared/types').Rule} */
13 module.exports = {
14 meta: {
15 type: "suggestion",
16
17 docs: {
18 description: "Disallow octal literals",
19 recommended: true,
20 url: "https://eslint.org/docs/rules/no-octal"
21 },
22
23 schema: [],
24
25 messages: {
26 noOctal: "Octal literals should not be used."
27 }
28 },
29
30 create(context) {
31
32 return {
33
34 Literal(node) {
35 if (typeof node.value === "number" && /^0[0-9]/u.test(node.raw)) {
36 context.report({
37 node,
38 messageId: "noOctal"
39 });
40 }
41 }
42 };
43
44 }
45 };