1 | /**
|
2 | * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
|
3 | * @author James Allardice
|
4 | */
|
5 |
|
6 | //------------------------------------------------------------------------------
|
7 | // Rule Definition
|
8 | //------------------------------------------------------------------------------
|
9 |
|
10 | module.exports = function(context) {
|
11 |
|
12 | ;
|
13 |
|
14 | return {
|
15 | "Literal": function(node) {
|
16 |
|
17 | if (typeof node.value === "number") {
|
18 | if (node.raw.indexOf(".") === 0) {
|
19 | context.report(node, "A leading decimal point can be confused with a dot.");
|
20 | }
|
21 | if (node.raw.indexOf(".") === node.raw.length - 1) {
|
22 | context.report(node, "A trailing decimal point can be confused with a dot.");
|
23 | }
|
24 | }
|
25 | }
|
26 | };
|
27 |
|
28 | };
|