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-script-url.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @fileoverview Rule to flag when using javascript: urls
  3. * @author Ilya Volodin
  4. */
  5. /* jshint scripturl: true */
  6. /* eslint no-script-url: 0 */
  7. "use strict";
  8. //------------------------------------------------------------------------------
  9. // Rule Definition
  10. //------------------------------------------------------------------------------
  11. module.exports = {
  12. meta: {
  13. type: "suggestion",
  14. docs: {
  15. description: "disallow `javascript:` urls",
  16. category: "Best Practices",
  17. recommended: false,
  18. url: "https://eslint.org/docs/rules/no-script-url"
  19. },
  20. schema: []
  21. },
  22. create(context) {
  23. return {
  24. Literal(node) {
  25. if (node.value && typeof node.value === "string") {
  26. const value = node.value.toLowerCase();
  27. if (value.indexOf("javascript:") === 0) {
  28. context.report({ node, message: "Script URL is a form of eval." });
  29. }
  30. }
  31. }
  32. };
  33. }
  34. };