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-new.js 913B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @fileoverview Rule to flag statements with function invocation preceded by
  3. * "new" and not part of assignment
  4. * @author Ilya Volodin
  5. */
  6. "use strict";
  7. //------------------------------------------------------------------------------
  8. // Rule Definition
  9. //------------------------------------------------------------------------------
  10. module.exports = {
  11. meta: {
  12. type: "suggestion",
  13. docs: {
  14. description: "disallow `new` operators outside of assignments or comparisons",
  15. category: "Best Practices",
  16. recommended: false,
  17. url: "https://eslint.org/docs/rules/no-new"
  18. },
  19. schema: []
  20. },
  21. create(context) {
  22. return {
  23. "ExpressionStatement > NewExpression"(node) {
  24. context.report({ node: node.parent, message: "Do not use 'new' for side effects." });
  25. }
  26. };
  27. }
  28. };