]> git.proxmox.com Git - pve-eslint.git/blame - eslint/lib/rules/no-new.js
import 8.4.0 source
[pve-eslint.git] / eslint / lib / rules / no-new.js
CommitLineData
eb39fafa
DC
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
34eeec05 13/** @type {import('../shared/types').Rule} */
eb39fafa
DC
14module.exports = {
15 meta: {
16 type: "suggestion",
17
18 docs: {
19 description: "disallow `new` operators outside of assignments or comparisons",
eb39fafa
DC
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};