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 13module.exports = { 14 meta: { 15 type: "suggestion", 16 17 docs: { 18 description: "disallow `new` operators outside of assignments or comparisons", 19 category: "Best Practices", 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}; 44