2020-03-07 11:45:40 +08:00
|
|
|
/**
|
|
|
|
* @fileoverview Disallow the use of process.env()
|
|
|
|
* @author Vignesh Anand
|
|
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
// Rule Definition
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
meta: {
|
2020-05-15 05:33:08 +08:00
|
|
|
deprecated: true,
|
|
|
|
|
2020-06-06 22:11:37 +08:00
|
|
|
replacedBy: [],
|
2020-05-15 05:33:08 +08:00
|
|
|
|
2020-03-07 11:45:40 +08:00
|
|
|
type: "suggestion",
|
|
|
|
|
|
|
|
docs: {
|
|
|
|
description: "disallow the use of `process.env`",
|
|
|
|
category: "Node.js and CommonJS",
|
|
|
|
recommended: false,
|
|
|
|
url: "https://eslint.org/docs/rules/no-process-env"
|
|
|
|
},
|
|
|
|
|
2020-05-15 05:33:08 +08:00
|
|
|
schema: [],
|
|
|
|
|
|
|
|
messages: {
|
|
|
|
unexpectedProcessEnv: "Unexpected use of process.env."
|
|
|
|
}
|
2020-03-07 11:45:40 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
create(context) {
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
MemberExpression(node) {
|
|
|
|
const objectName = node.object.name,
|
|
|
|
propertyName = node.property.name;
|
|
|
|
|
|
|
|
if (objectName === "process" && !node.computed && propertyName && propertyName === "env") {
|
2020-05-15 05:33:08 +08:00
|
|
|
context.report({ node, messageId: "unexpectedProcessEnv" });
|
2020-03-07 11:45:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|