UNPKG

827 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 },
20
21 schema: []
22 },
23
24 create(context) {
25
26 return {
27 "ExpressionStatement > NewExpression"(node) {
28 context.report({ node: node.parent, message: "Do not use 'new' for side effects." });
29 }
30 };
31
32 }
33};