1 | /**
|
2 | * @fileoverview Disallow the use of process.exit()
|
3 | * @author Nicholas C. Zakas
|
4 | */
|
5 | ;
|
6 |
|
7 | //------------------------------------------------------------------------------
|
8 | // Rule Definition
|
9 | //------------------------------------------------------------------------------
|
10 |
|
11 | module.exports = {
|
12 | meta: {
|
13 | docs: {
|
14 | description: "disallow the use of `process.exit()`",
|
15 | category: "Node.js and CommonJS",
|
16 | recommended: false
|
17 | },
|
18 |
|
19 | schema: []
|
20 | },
|
21 |
|
22 | create(context) {
|
23 |
|
24 | //--------------------------------------------------------------------------
|
25 | // Public
|
26 | //--------------------------------------------------------------------------
|
27 |
|
28 | return {
|
29 |
|
30 | CallExpression(node) {
|
31 | const callee = node.callee;
|
32 |
|
33 | if (callee.type === "MemberExpression" && callee.object.name === "process" &&
|
34 | callee.property.name === "exit"
|
35 | ) {
|
36 | context.report(node, "Don't use process.exit(); throw an error instead.");
|
37 | }
|
38 | }
|
39 |
|
40 | };
|
41 |
|
42 | }
|
43 | };
|