Urara-Blog/node_modules/.pnpm-store/v3/files/cc/7e29e557b6d041898cd631a5232b73356f48d3fffbfb9655d6486ce6eb13bcdc4b10976b954ea1a51bc745504829f2955756aa0c8e424fc9d4fdb930f288b9
2022-08-14 01:14:53 +08:00

45 lines
1 KiB
Text

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