1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | module.exports = {
|
13 | meta: {
|
14 | deprecated: true,
|
15 |
|
16 | replacedBy: [],
|
17 |
|
18 | type: "suggestion",
|
19 |
|
20 | docs: {
|
21 | description: "disallow `new` operators with calls to `require`",
|
22 | category: "Node.js and CommonJS",
|
23 | recommended: false,
|
24 | url: "https://eslint.org/docs/rules/no-new-require"
|
25 | },
|
26 |
|
27 | schema: [],
|
28 |
|
29 | messages: {
|
30 | noNewRequire: "Unexpected use of new with require."
|
31 | }
|
32 | },
|
33 |
|
34 | create(context) {
|
35 |
|
36 | return {
|
37 |
|
38 | NewExpression(node) {
|
39 | if (node.callee.type === "Identifier" && node.callee.name === "require") {
|
40 | context.report({
|
41 | node,
|
42 | messageId: "noNewRequire"
|
43 | });
|
44 | }
|
45 | }
|
46 | };
|
47 |
|
48 | }
|
49 | };
|