diff options
Diffstat (limited to 'tools/eslint/lib/rules/no-floating-decimal.js')
-rw-r--r-- | tools/eslint/lib/rules/no-floating-decimal.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/eslint/lib/rules/no-floating-decimal.js b/tools/eslint/lib/rules/no-floating-decimal.js index 32767fb513..7e02305029 100644 --- a/tools/eslint/lib/rules/no-floating-decimal.js +++ b/tools/eslint/lib/rules/no-floating-decimal.js @@ -17,7 +17,9 @@ module.exports = { recommended: false }, - schema: [] + schema: [], + + fixable: "code" }, create(context) { @@ -27,10 +29,18 @@ module.exports = { if (typeof node.value === "number") { if (node.raw.indexOf(".") === 0) { - context.report(node, "A leading decimal point can be confused with a dot."); + context.report({ + node, + message: "A leading decimal point can be confused with a dot.", + fix: fixer => fixer.insertTextBefore(node, "0") + }); } if (node.raw.indexOf(".") === node.raw.length - 1) { - context.report(node, "A trailing decimal point can be confused with a dot."); + context.report({ + node, + message: "A trailing decimal point can be confused with a dot.", + fix: fixer => fixer.insertTextAfter(node, "0") + }); } } } |