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 | deprecated: true,
|
14 |
|
15 | replacedBy: [],
|
16 |
|
17 | type: "suggestion",
|
18 |
|
19 | docs: {
|
20 | description: "disallow the use of `process.exit()`",
|
21 | category: "Node.js and CommonJS",
|
22 | recommended: false,
|
23 | url: "https://eslint.org/docs/rules/no-process-exit"
|
24 | },
|
25 |
|
26 | schema: [],
|
27 |
|
28 | messages: {
|
29 | noProcessExit: "Don't use process.exit(); throw an error instead."
|
30 | }
|
31 | },
|
32 |
|
33 | create(context) {
|
34 |
|
35 | //--------------------------------------------------------------------------
|
36 | // Public
|
37 | //--------------------------------------------------------------------------
|
38 |
|
39 | return {
|
40 | "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) {
|
41 | context.report({ node: node.parent, messageId: "noProcessExit" });
|
42 | }
|
43 | };
|
44 |
|
45 | }
|
46 | };
|