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 | url: "https://eslint.org/docs/rules/no-process-exit"
|
18 | },
|
19 |
|
20 | schema: []
|
21 | },
|
22 |
|
23 | create(context) {
|
24 |
|
25 | //--------------------------------------------------------------------------
|
26 | // Public
|
27 | //--------------------------------------------------------------------------
|
28 |
|
29 | return {
|
30 | "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) {
|
31 | context.report({ node: node.parent, message: "Don't use process.exit(); throw an error instead." });
|
32 | }
|
33 | };
|
34 |
|
35 | }
|
36 | };
|