Prefer Object.hasOwn() over Object.prototype.hasOwnProperty() (#8684)

This commit is contained in:
Jon Koops
2022-11-26 17:29:21 +01:00
committed by GitHub
parent 5269db4c4f
commit 0b9ae01a9c
5 changed files with 5 additions and 4 deletions

View File

@ -40,6 +40,7 @@ module.exports = {
'wrap-iife': 'off',
// TODO: Re-enable the rules below and fix the linting issues.
'no-invalid-this': 'off',
'prefer-object-has-own': 'error',
'prefer-spread': 'off'
},
overrides: [

View File

@ -37,7 +37,7 @@ Class.extend = function (props) {
// inherit parent's statics
for (const i in this) {
if (Object.prototype.hasOwnProperty.call(this, i) && i !== 'prototype' && i !== '__super__') {
if (Object.hasOwn(this, i) && i !== 'prototype' && i !== '__super__') {
NewClass[i] = this[i];
}
}

View File

@ -100,7 +100,7 @@ export function splitWords(str) {
// @function setOptions(obj: Object, options: Object): Object
// Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.
export function setOptions(obj, options) {
if (!Object.prototype.hasOwnProperty.call(obj, 'options')) {
if (!Object.hasOwn(obj, 'options')) {
obj.options = obj.options ? Object.create(obj.options) : {};
}
for (const i in options) {

View File

@ -77,7 +77,7 @@ export const VideoOverlay = ImageOverlay.extend({
if (!Array.isArray(this._url)) { this._url = [this._url]; }
if (!this.options.keepAspectRatio && Object.prototype.hasOwnProperty.call(vid.style, 'objectFit')) {
if (!this.options.keepAspectRatio && Object.hasOwn(vid.style, 'objectFit')) {
vid.style['objectFit'] = 'fill';
}
vid.autoplay = !!this.options.autoplay;

View File

@ -105,7 +105,7 @@ export const Path = Layer.extend({
Util.setOptions(this, style);
if (this._renderer) {
this._renderer._updateStyle(this);
if (this.options.stroke && style && Object.prototype.hasOwnProperty.call(style, 'weight')) {
if (this.options.stroke && style && Object.hasOwn(style, 'weight')) {
this._updateBounds();
}
}