UNPKG

866 BJavaScriptView Raw
1/**
2 * @fileoverview Rule to disallow use of new operator with the `require` function
3 * @author Wil Moore III
4 */
5
6"use strict";
7
8//------------------------------------------------------------------------------
9// Rule Definition
10//------------------------------------------------------------------------------
11
12module.exports = {
13 meta: {
14 docs: {
15 description: "disallow `new` operators with calls to `require`",
16 category: "Node.js and CommonJS",
17 recommended: false
18 },
19
20 schema: []
21 },
22
23 create(context) {
24
25 return {
26
27 NewExpression(node) {
28 if (node.callee.type === "Identifier" && node.callee.name === "require") {
29 context.report({ node, message: "Unexpected use of new with require." });
30 }
31 }
32 };
33
34 }
35};