项目原始demo,不改动
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
Bu depo arşivlendi. Dosyaları görüntüleyebilir ve klonlayabilirsiniz ama işlem gönderemez ve konu/değişiklik isteği açamazsınız.
 
 
 
 

49 satır
1.3 KiB

  1. /**
  2. * @fileoverview Rule to flag octal escape sequences in string literals.
  3. * @author Ian Christian Myers
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. docs: {
  12. description: "disallow octal escape sequences in string literals",
  13. category: "Best Practices",
  14. recommended: false,
  15. url: "https://eslint.org/docs/rules/no-octal-escape"
  16. },
  17. schema: []
  18. },
  19. create(context) {
  20. return {
  21. Literal(node) {
  22. if (typeof node.value !== "string") {
  23. return;
  24. }
  25. const match = node.raw.match(/^([^\\]|\\[^0-7])*\\([0-3][0-7]{1,2}|[4-7][0-7]|[0-7])/);
  26. if (match) {
  27. const octalDigit = match[2];
  28. // \0 is actually not considered an octal
  29. if (match[2] !== "0" || typeof match[3] !== "undefined") {
  30. context.report({ node, message: "Don't use octal: '\\{{octalDigit}}'. Use '\\u....' instead.", data: { octalDigit } });
  31. }
  32. }
  33. }
  34. };
  35. }
  36. };