no-void.js 1023 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @fileoverview Rule to disallow use of void operator.
  3. * @author Mike Sidorov
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. docs: {
  12. description: "disallow `void` operators",
  13. category: "Best Practices",
  14. recommended: false,
  15. url: "https://eslint.org/docs/rules/no-void"
  16. },
  17. schema: []
  18. },
  19. create(context) {
  20. //--------------------------------------------------------------------------
  21. // Public
  22. //--------------------------------------------------------------------------
  23. return {
  24. UnaryExpression(node) {
  25. if (node.operator === "void") {
  26. context.report({ node, message: "Expected 'undefined' and instead saw 'void'." });
  27. }
  28. }
  29. };
  30. }
  31. };