Skip to content

Commit

Permalink
add tests for getter-return
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Jun 14, 2020
1 parent 9a14a09 commit 276526b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/lib/rules/getter-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,30 @@ ruleTester.run("getter-return", rule, {
{ code: "Object.defineProperties(foo, { bar: { get: function () {~function () { return true; }()}} });", options, errors: [{ messageId: "expected" }] },

// option: {allowImplicit: true}
{ code: "Object.defineProperty(foo, \"bar\", { get: function (){}});", options, errors: [{ messageId: "expected" }] }
{ code: "Object.defineProperty(foo, \"bar\", { get: function (){}});", options, errors: [{ messageId: "expected" }] },

// Optional chaining
{
code: "Object?.defineProperty(foo, 'bar', { get: function (){} });",
parserOptions: { ecmaVersion: 2020 },
errors: [{ messageId: "expected", data: { name: "method 'get'" } }]
},
{
code: "(Object?.defineProperty)(foo, 'bar', { get: function (){} });",
parserOptions: { ecmaVersion: 2020 },
errors: [{ messageId: "expected", data: { name: "method 'get'" } }]
},
{
code: "Object?.defineProperty(foo, 'bar', { get: function (){} });",
options,
parserOptions: { ecmaVersion: 2020 },
errors: [{ messageId: "expected", data: { name: "method 'get'" } }]
},
{
code: "(Object?.defineProperty)(foo, 'bar', { get: function (){} });",
options,
parserOptions: { ecmaVersion: 2020 },
errors: [{ messageId: "expected", data: { name: "method 'get'" } }]
}
]
});

0 comments on commit 276526b

Please sign in to comment.