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-delete-var.js 965B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * @fileoverview Rule to flag when deleting variables
  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 deleting variables",
  14. category: "Variables",
  15. recommended: true,
  16. url: "https://eslint.org/docs/rules/no-delete-var"
  17. },
  18. schema: [],
  19. messages: {
  20. unexpected: "Variables should not be deleted."
  21. }
  22. },
  23. create(context) {
  24. return {
  25. UnaryExpression(node) {
  26. if (node.operator === "delete" && node.argument.type === "Identifier") {
  27. context.report({ node, messageId: "unexpected" });
  28. }
  29. }
  30. };
  31. }
  32. };