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-multi-str.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * @fileoverview Rule to flag when using multiline strings
  3. * @author Ilya Volodin
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Requirements
  8. //------------------------------------------------------------------------------
  9. const astUtils = require("../util/ast-utils");
  10. //------------------------------------------------------------------------------
  11. // Rule Definition
  12. //------------------------------------------------------------------------------
  13. module.exports = {
  14. meta: {
  15. type: "suggestion",
  16. docs: {
  17. description: "disallow multiline strings",
  18. category: "Best Practices",
  19. recommended: false,
  20. url: "https://eslint.org/docs/rules/no-multi-str"
  21. },
  22. schema: []
  23. },
  24. create(context) {
  25. /**
  26. * Determines if a given node is part of JSX syntax.
  27. * @param {ASTNode} node The node to check.
  28. * @returns {boolean} True if the node is a JSX node, false if not.
  29. * @private
  30. */
  31. function isJSXElement(node) {
  32. return node.type.indexOf("JSX") === 0;
  33. }
  34. //--------------------------------------------------------------------------
  35. // Public API
  36. //--------------------------------------------------------------------------
  37. return {
  38. Literal(node) {
  39. if (astUtils.LINEBREAK_MATCHER.test(node.raw) && !isJSXElement(node.parent)) {
  40. context.report({ node, message: "Multiline support is limited to browsers supporting ES5 only." });
  41. }
  42. }
  43. };
  44. }
  45. };