]> git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-new-object.js
first commit
[pve-eslint.git] / eslint / lib / rules / no-new-object.js
1 /**
2 * @fileoverview A rule to disallow calls to the Object constructor
3 * @author Matt DuVall <http://www.mattduvall.com/>
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Rule Definition
10 //------------------------------------------------------------------------------
11
12 module.exports = {
13 meta: {
14 type: "suggestion",
15
16 docs: {
17 description: "disallow `Object` constructors",
18 category: "Stylistic Issues",
19 recommended: false,
20 url: "https://eslint.org/docs/rules/no-new-object"
21 },
22
23 schema: [],
24
25 messages: {
26 preferLiteral: "The object literal notation {} is preferrable."
27 }
28 },
29
30 create(context) {
31
32 return {
33
34 NewExpression(node) {
35 if (node.callee.name === "Object") {
36 context.report({
37 node,
38 messageId: "preferLiteral"
39 });
40 }
41 }
42 };
43
44 }
45 };