Sha256: c260578e8f84e5ac11868565402f44a4d249827ff0ce266ecf99ccc8ea4df2ab

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

/**
 * @fileoverview Rule to flag when using constructor for wrapper objects
 * @author Ilya Volodin
 */

"use strict";

//------------------------------------------------------------------------------
// Rule Definition
//------------------------------------------------------------------------------

/** @type {import('../shared/types').Rule} */
module.exports = {
    meta: {
        type: "suggestion",

        docs: {
            description: "disallow `new` operators with the `String`, `Number`, and `Boolean` objects",
            recommended: false,
            url: "https://eslint.org/docs/rules/no-new-wrappers"
        },

        schema: [],

        messages: {
            noConstructor: "Do not use {{fn}} as a constructor."
        }
    },

    create(context) {

        return {

            NewExpression(node) {
                const wrapperObjects = ["String", "Number", "Boolean"];

                if (wrapperObjects.indexOf(node.callee.name) > -1) {
                    context.report({
                        node,
                        messageId: "noConstructor",
                        data: { fn: node.callee.name }
                    });
                }
            }
        };

    }
};

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-0.27.1 packages/webpacker/node_modules/eslint/lib/rules/no-new-wrappers.js
decidim-0.26.4 packages/webpacker/node_modules/eslint/lib/rules/no-new-wrappers.js
decidim-0.27.0 packages/webpacker/node_modules/eslint/lib/rules/no-new-wrappers.js
decidim-0.26.3 packages/webpacker/node_modules/eslint/lib/rules/no-new-wrappers.js
decidim-0.27.0.rc2 packages/webpacker/node_modules/eslint/lib/rules/no-new-wrappers.js
decidim-0.27.0.rc1 packages/webpacker/node_modules/eslint/lib/rules/no-new-wrappers.js