no-octal-numeric-literals.js 909 B

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * @author Toru Nagashima <https://github.com/mysticatea>
  3. * See LICENSE file in root directory for full license.
  4. */
  5. "use strict"
  6. const Pattern = /^0[oO]/u
  7. module.exports = {
  8. meta: {
  9. docs: {
  10. description: "disallow octal numeric literals.",
  11. category: "ES2015",
  12. recommended: false,
  13. url:
  14. "http://mysticatea.github.io/eslint-plugin-es/rules/no-octal-numeric-literals.html",
  15. },
  16. fixable: null,
  17. messages: {
  18. forbidden: "ES2015 octal numeric literals are forbidden.",
  19. },
  20. schema: [],
  21. type: "problem",
  22. },
  23. create(context) {
  24. return {
  25. Literal(node) {
  26. if (typeof node.value === "number" && Pattern.test(node.raw)) {
  27. context.report({ node, messageId: "forbidden" })
  28. }
  29. },
  30. }
  31. },
  32. }