forked from eslint/eslint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prefer-object-has-own.js
43 lines (36 loc) · 1.1 KB
/
prefer-object-has-own.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @fileoverview Prefers Object.hasOwn instead of Object.prototype.hasOwnProperty
* @author Gautam Arora
* See LICENSE file in root directory for full license.
*/
"use strict";
//------------------------------------------------------------------------------
// Requirements
//------------------------------------------------------------------------------
const rule = require("../../../lib/rules/prefer-object-has-own");
const { RuleTester } = require("../../../lib/rule-tester");
//------------------------------------------------------------------------------
// Tests
//------------------------------------------------------------------------------
const parserOptions = {
ecmaVersion: 2018,
sourceType: "module"
};
const ruleTester = new RuleTester({ parserOptions });
ruleTester.run("prefer-object-has-own", rule, {
valid: [
`
let obj = {};
Object.hasOwn(obj,"");
`
],
invalid: [
`
let a = Object.prototype.hasOwnProperty();
obj.call();
`,
`
let a = Object.prototype.hasOwnProperty.call();
`
]
});