Refresh new-cap tests
This commit is contained in:
parent
5b5d9a5dec
commit
ae68b5bf24
@ -37,23 +37,33 @@ ruleTester.run('babel/new-cap', rule, {
|
||||
"var x = Symbol('symbol')",
|
||||
"var x = _();",
|
||||
"var x = $();",
|
||||
{ code: "var x = Foo(42)", options: [{"capIsNew": false}] },
|
||||
{ code: "var x = bar.Foo(42)", options: [{"capIsNew": false}] },
|
||||
{ code: "var x = Foo(42)", options: [{ capIsNew: false }] },
|
||||
{ code: "var x = bar.Foo(42)", options: [{ capIsNew: false }] },
|
||||
{ code: "var x = Foo.bar(42)", options: [{ capIsNew: false }] },
|
||||
"var x = bar[Foo](42)",
|
||||
{code: "var x = bar['Foo'](42)", options: [{"capIsNew": false}] },
|
||||
{ code: "var x = bar['Foo'](42)", options: [{ capIsNew: false }] },
|
||||
"var x = Foo.bar(42)",
|
||||
{ code: "var x = new foo(42)", options: [{"newIsCap": false}] },
|
||||
{ code: "var x = new foo(42)", options: [{ newIsCap: false }] },
|
||||
"var o = { 1: function() {} }; o[1]();",
|
||||
"var o = { 1: function() {} }; new o[1]();",
|
||||
{ code: "var x = Foo(42);", options: [{ capIsNew: true, capIsNewExceptions: ["Foo"] }] },
|
||||
{ code: "var x = Foo(42);", options: [{ capIsNewExceptionPattern: "^Foo" }] },
|
||||
{ code: "var x = new foo(42);", options: [{ newIsCap: true, newIsCapExceptions: ["foo"] }] },
|
||||
{ code: "var x = new foo(42);", options: [{ newIsCapExceptionPattern: "^foo" }] },
|
||||
{ code: "var x = Object(42);", options: [{ capIsNewExceptions: ["Foo"] }] },
|
||||
|
||||
{ code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptions: ["Bar"] }] },
|
||||
{ code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptions: ["Foo.Bar"] }] },
|
||||
|
||||
{ code: "var x = Foo.Bar(42);", options: [{ capIsNewExceptionPattern: "^Foo\\.." }] },
|
||||
{ code: "var x = new foo.bar(42);", options: [{ newIsCapExceptions: ["bar"] }] },
|
||||
{ code: "var x = new foo.bar(42);", options: [{ newIsCapExceptions: ["foo.bar"] }] },
|
||||
|
||||
{ code: "var x = new foo.bar(42);", options: [{ newIsCapExceptionPattern: "^foo\\.." }] },
|
||||
{ code: "var x = new foo.bar(42);", options: [{ properties: false }] },
|
||||
{ code: "var x = Foo.bar(42);", options: [{ properties: false }] },
|
||||
{ code: "var x = foo.Bar(42);", options: [{ capIsNew: false, properties: false }] },
|
||||
|
||||
// Babel-specific test cases.
|
||||
{ code: "@MyDecorator(123) class MyClass{}", parser: "babel-eslint" },
|
||||
],
|
||||
@ -128,10 +138,22 @@ ruleTester.run('babel/new-cap', rule, {
|
||||
options: [{ capIsNewExceptions: ["Foo"] }],
|
||||
errors: [{ type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor." }]
|
||||
},
|
||||
{
|
||||
code: "var x = Bar.Foo(42);",
|
||||
|
||||
options: [{ capIsNewExceptionPattern: "^Foo\\.." }],
|
||||
errors: [{ type: "CallExpression", message: "A function with a name starting with an uppercase letter should only be used as a constructor." }]
|
||||
},
|
||||
{
|
||||
code: "var x = new foo.bar(42);",
|
||||
options: [{ newIsCapExceptions: ["foo"] }],
|
||||
errors: [{ type: "NewExpression", message: "A constructor name should not start with a lowercase letter." }]
|
||||
},
|
||||
{
|
||||
code: "var x = new bar.foo(42);",
|
||||
|
||||
options: [{ newIsCapExceptionPattern: "^foo\\.." }],
|
||||
errors: [{ type: "NewExpression", message: "A constructor name should not start with a lowercase letter." }]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user