UNPKG

894 BJavaScriptView Raw
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
12module.exports = {
13 meta: {
14 docs: {
15 description: "disallow `Object` constructors",
16 category: "Stylistic Issues",
17 recommended: false,
18 url: "https://eslint.org/docs/rules/no-new-object"
19 },
20
21 schema: []
22 },
23
24 create(context) {
25
26 return {
27
28 NewExpression(node) {
29 if (node.callee.name === "Object") {
30 context.report({ node, message: "The object literal notation {} is preferrable." });
31 }
32 }
33 };
34
35 }
36};