node/tools/node_modules/eslint/lib/rules/no-octal.js
cjihrig 17b7fa75c3
tools: update ESLint to 5.15.0
Update ESLint to 5.15.0

PR-URL: https://github.com/nodejs/node/pull/26391
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Masashi Hirano <shisama07@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2019-03-03 22:04:24 -05:00

39 lines
886 B
JavaScript

/**
* @fileoverview Rule to flag when initializing octal literal
* @author Ilya Volodin
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
type: "suggestion",
docs: {
description: "disallow octal literals",
category: "Best Practices",
recommended: true,
url: "https://eslint.org/docs/rules/no-octal"
},
schema: []
},
create(context) {
return {
Literal(node) {
if (typeof node.value === "number" && /^0[0-7]/u.test(node.raw)) {
context.report({ node, message: "Octal literals should not be used." });
}
}
};
}
};