]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | /** |
2 | * @fileoverview Disallow the use of process.exit() | |
3 | * @author Nicholas C. Zakas | |
609c276f | 4 | * @deprecated in ESLint v7.0.0 |
eb39fafa DC |
5 | */ |
6 | "use strict"; | |
7 | ||
8 | //------------------------------------------------------------------------------ | |
9 | // Rule Definition | |
10 | //------------------------------------------------------------------------------ | |
11 | ||
34eeec05 | 12 | /** @type {import('../shared/types').Rule} */ |
eb39fafa DC |
13 | module.exports = { |
14 | meta: { | |
56c4a2cb DC |
15 | deprecated: true, |
16 | ||
ebb53d86 | 17 | replacedBy: [], |
56c4a2cb | 18 | |
eb39fafa DC |
19 | type: "suggestion", |
20 | ||
21 | docs: { | |
22 | description: "disallow the use of `process.exit()`", | |
eb39fafa DC |
23 | recommended: false, |
24 | url: "https://eslint.org/docs/rules/no-process-exit" | |
25 | }, | |
26 | ||
27 | schema: [], | |
28 | ||
29 | messages: { | |
30 | noProcessExit: "Don't use process.exit(); throw an error instead." | |
31 | } | |
32 | }, | |
33 | ||
34 | create(context) { | |
35 | ||
36 | //-------------------------------------------------------------------------- | |
37 | // Public | |
38 | //-------------------------------------------------------------------------- | |
39 | ||
40 | return { | |
41 | "CallExpression > MemberExpression.callee[object.name = 'process'][property.name = 'exit']"(node) { | |
42 | context.report({ node: node.parent, messageId: "noProcessExit" }); | |
43 | } | |
44 | }; | |
45 | ||
46 | } | |
47 | }; |