no-with.js 863 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @fileoverview Rule to flag use of with statement
  3. * @author Nicholas C. Zakas
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. type: "suggestion",
  12. docs: {
  13. description: "disallow `with` statements",
  14. category: "Best Practices",
  15. recommended: true,
  16. url: "https://eslint.org/docs/rules/no-with"
  17. },
  18. schema: [],
  19. messages: {
  20. unexpectedWith: "Unexpected use of 'with' statement."
  21. }
  22. },
  23. create(context) {
  24. return {
  25. WithStatement(node) {
  26. context.report({ node, messageId: "unexpectedWith" });
  27. }
  28. };
  29. }
  30. };