no-process-env.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /**
  2. * @fileoverview Disallow the use of process.env()
  3. * @author Vignesh Anand
  4. * @deprecated in ESLint v7.0.0
  5. */
  6. "use strict";
  7. //------------------------------------------------------------------------------
  8. // Rule Definition
  9. //------------------------------------------------------------------------------
  10. /** @type {import('../shared/types').Rule} */
  11. module.exports = {
  12. meta: {
  13. deprecated: true,
  14. replacedBy: [],
  15. type: "suggestion",
  16. docs: {
  17. description: "Disallow the use of `process.env`",
  18. recommended: false,
  19. url: "https://eslint.org/docs/rules/no-process-env"
  20. },
  21. schema: [],
  22. messages: {
  23. unexpectedProcessEnv: "Unexpected use of process.env."
  24. }
  25. },
  26. create(context) {
  27. return {
  28. MemberExpression(node) {
  29. const objectName = node.object.name,
  30. propertyName = node.property.name;
  31. if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
  32. context.report({ node, messageId: "unexpectedProcessEnv" });
  33. }
  34. }
  35. };
  36. }
  37. };