1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | module.exports = {
|
12 | meta: {
|
13 | type: "suggestion",
|
14 |
|
15 | docs: {
|
16 | description: "disallow the use of `process.env`",
|
17 | category: "Node.js and CommonJS",
|
18 | recommended: false,
|
19 | url: "https://eslint.org/docs/rules/no-process-env"
|
20 | },
|
21 |
|
22 | schema: []
|
23 | },
|
24 |
|
25 | create(context) {
|
26 |
|
27 | return {
|
28 |
|
29 | MemberExpression(node) {
|
30 | const objectName = node.object.name,
|
31 | propertyName = node.property.name;
|
32 |
|
33 | if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
|
34 | context.report({ node, message: "Unexpected use of process.env." });
|
35 | }
|
36 |
|
37 | }
|
38 |
|
39 | };
|
40 |
|
41 | }
|
42 | };
|