Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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-buffer-constructor.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @fileoverview disallow use of the Buffer() constructor
  3. * @author Teddy Katz
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Rule Definition
  8. //------------------------------------------------------------------------------
  9. module.exports = {
  10. meta: {
  11. deprecated: true,
  12. replacedBy: [],
  13. type: "problem",
  14. docs: {
  15. description: "disallow use of the `Buffer()` constructor",
  16. category: "Node.js and CommonJS",
  17. recommended: false,
  18. url: "https://eslint.org/docs/rules/no-buffer-constructor"
  19. },
  20. schema: [],
  21. messages: {
  22. deprecated: "{{expr}} is deprecated. Use Buffer.from(), Buffer.alloc(), or Buffer.allocUnsafe() instead."
  23. }
  24. },
  25. create(context) {
  26. //----------------------------------------------------------------------
  27. // Public
  28. //----------------------------------------------------------------------
  29. return {
  30. "CallExpression[callee.name='Buffer'], NewExpression[callee.name='Buffer']"(node) {
  31. context.report({
  32. node,
  33. messageId: "deprecated",
  34. data: { expr: node.type === "CallExpression" ? "Buffer()" : "new Buffer()" }
  35. });
  36. }
  37. };
  38. }
  39. };