]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-new.js
5b0976534d6e3d411f2905abf0b2d84c12a61636
[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 /** @type {import('../shared/types').Rule} */
14 module.exports = {
15 meta: {
16 type: "suggestion",
17
18 docs: {
19 description: "disallow `new` operators outside of assignments or comparisons",
20 recommended: false,
21 url: "https://eslint.org/docs/rules/no-new"
22 },
23
24 schema: [],
25
26 messages: {
27 noNewStatement: "Do not use 'new' for side effects."
28 }
29 },
30
31 create(context) {
32
33 return {
34 "ExpressionStatement > NewExpression"(node) {
35 context.report({
36 node: node.parent,
37 messageId: "noNewStatement"
38 });
39 }
40 };
41
42 }
43 };