UNPKG

884 BJavaScriptView Raw
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 docs: {
16 description: "disallow `new` operators outside of assignments or comparisons",
17 category: "Best Practices",
18 recommended: false,
19 url: "https://eslint.org/docs/rules/no-new"
20 },
21
22 schema: []
23 },
24
25 create(context) {
26
27 return {
28 "ExpressionStatement > NewExpression"(node) {
29 context.report({ node: node.parent, message: "Do not use 'new' for side effects." });
30 }
31 };
32
33 }
34};