UNPKG

907 BJavaScriptView Raw
1/**
2 * @fileoverview Disallow the use of process.exit()
3 * @author Nicholas C. Zakas
4 */
5"use strict";
6
7//------------------------------------------------------------------------------
8// Rule Definition
9//------------------------------------------------------------------------------
10
11module.exports = function(context) {
12
13 //--------------------------------------------------------------------------
14 // Public
15 //--------------------------------------------------------------------------
16
17 return {
18
19 "CallExpression": function(node) {
20 var callee = node.callee;
21
22 if (callee.type === "MemberExpression" && callee.object.name === "process" &&
23 callee.property.name === "exit"
24 ) {
25 context.report(node, "Don't use process.exit(); throw an error instead.");
26 }
27 }
28
29 };
30
31};
32
33module.exports.schema = [];