Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

no-octal.js 885B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @fileoverview Rule to flag when initializing octal literal
  3. * @author Ilya Volodin
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "suggestion",
  12. docs: {
  13. description: "disallow octal literals",
  14. category: "Best Practices",
  15. recommended: true,
  16. url: "https://eslint.org/docs/rules/no-octal"
  17. },
  18. schema: []
  19. },
  20. create(context) {
  21. return {
  22. Literal(node) {
  23. if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) {
  24. context.report({ node, message: "Octal literals should not be used." });
  25. }
  26. }
  27. };
  28. }
  29. };