UNPKG

945 BJavaScriptView Raw
1/**
2 * @fileoverview Disallow the use of process.env()
3 * @author Vignesh Anand
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11module.exports = {
12 meta: {
13 docs: {
14 description: "disallow the use of `process.env`",
15 category: "Node.js and CommonJS",
16 recommended: false
17 },
18
19 schema: []
20 },
21
22 create(context) {
23
24 return {
25
26 MemberExpression(node) {
27 const objectName = node.object.name,
28 propertyName = node.property.name;
29
30 if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
31 context.report({ node, message: "Unexpected use of process.env." });
32 }
33
34 }
35
36 };
37
38 }
39};