pve-eslint/eslint/tests/lib/rules/no-array-constructor.js
Dominik Csapak eb39fafa4f first commit
includes a (minimal) working wrapper

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2020-04-06 15:06:03 +02:00

39 lines
1.3 KiB
JavaScript

/**
* @fileoverview Tests for the no-array-constructor rule
* @author Matt DuVall <http://www.mattduvall.com/>
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/no-array-constructor"),
{ RuleTester } = require("../../../lib/rule-tester");
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const ruleTester = new RuleTester();
ruleTester.run("no-array-constructor", rule, {
valid: [
"new Array(x)",
"Array(x)",
"new Array(9)",
"Array(9)",
"new foo.Array()",
"foo.Array()",
"new Array.foo",
"Array.foo()"
],
invalid: [
{ code: "new Array()", errors: [{ messageId: "preferLiteral", type: "NewExpression" }] },
{ code: "new Array", errors: [{ messageId: "preferLiteral", type: "NewExpression" }] },
{ code: "new Array(x, y)", errors: [{ messageId: "preferLiteral", type: "NewExpression" }] },
{ code: "new Array(0, 1, 2)", errors: [{ messageId: "preferLiteral", type: "NewExpression" }] }
]
});