]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-new.js
1b37f077d5c4b697393a61ac55524ed799ee5121
[pve-eslint.git] / eslint / lib / rules / no-new.js
1 /**
2 * @fileoverview Rule to flag statements with function invocation preceded by
3 * "new" and not part of assignment
4 * @author Ilya Volodin
5 */
6
7 "use strict";
8
9 //------------------------------------------------------------------------------
10 // Rule Definition
11 //------------------------------------------------------------------------------
12
13 module.exports = {
14 meta: {
15 type: "suggestion",
16
17 docs: {
18 description: "disallow `new` operators outside of assignments or comparisons",
19 recommended: false,
20 url: "https://eslint.org/docs/rules/no-new"
21 },
22
23 schema: [],
24
25 messages: {
26 noNewStatement: "Do not use 'new' for side effects."
27 }
28 },
29
30 create(context) {
31
32 return {
33 "ExpressionStatement > NewExpression"(node) {
34 context.report({
35 node: node.parent,
36 messageId: "noNewStatement"
37 });
38 }
39 };
40
41 }
42 };