c6380d546079dd07dd0afaf54359506dbb53117c
[platform/framework/web/crosswalk-tizen.git] /
1 /**
2  * @fileoverview Rule to flag use of a leading/trailing decimal point in a numeric literal
3  * @author James Allardice
4  */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Rule Definition
10 //------------------------------------------------------------------------------
11
12 module.exports = function(context) {
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 };