Files
node/tools/eslint/lib/rules/no-process-exit.js
T
Rich Trott 201115812e tools: update ESLint to 3.4.0
PR-URL: https://github.com/nodejs/node/pull/8296
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-08-30 10:40:45 -07:00

44 lines
1.1 KiB
JavaScript

/**
* @fileoverview Disallow the use of process.exit()
* @author Nicholas C. Zakas
*/
"use strict";
//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------
module.exports = {
meta: {
docs: {
description: "disallow the use of `process.exit()`",
category: "Node.js and CommonJS",
recommended: false
},
schema: []
},
create(context) {
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
return {
CallExpression(node) {
const callee = node.callee;
if (callee.type === "MemberExpression" && callee.object.name === "process" &&
callee.property.name === "exit"
) {
context.report(node, "Don't use process.exit(); throw an error instead.");
}
}
};
}
};