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-template-curly-in-string.js 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @fileoverview Warn when using template string syntax in regular strings
  3. * @author Jeroen Engels
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "problem",
  12. docs: {
  13. description: "disallow template literal placeholder syntax in regular strings",
  14. category: "Possible Errors",
  15. recommended: false,
  16. url: "https://eslint.org/docs/rules/no-template-curly-in-string"
  17. },
  18. schema: []
  19. },
  20. create(context) {
  21. const regex = /\$\{[^}]+\}/;
  22. return {
  23. Literal(node) {
  24. if (typeof node.value === "string" && regex.test(node.value)) {
  25. context.report({
  26. node,
  27. message: "Unexpected template string expression."
  28. });
  29. }
  30. }
  31. };
  32. }
  33. };