Fix: Lint no-prototype-builtins (#5920)

* Fix: Lint no-prototype-builtins

Closes: https://github.com/parse-community/parse-server/issues/5842

Reference: https://eslint.org/docs/rules/no-prototype-builtins

* replace Object.hasOwnProperty.call
This commit is contained in:
Diamond Lewis
2019-08-14 16:57:00 -05:00
committed by Antonio Davi Macedo Coelho de Castro
parent 4bffdce047
commit cf6e79ee75
22 changed files with 145 additions and 64 deletions

View File

@@ -119,7 +119,7 @@ const validateQuery = (
*/
Object.keys(query).forEach(key => {
const noCollisions = !query.$or.some(subq =>
Object.hasOwnProperty.call(subq, key)
Object.prototype.hasOwnProperty.call(subq, key)
);
let hasNears = false;
if (query[key] != null && typeof query[key] == 'object') {
@@ -1487,7 +1487,7 @@ class DatabaseController {
[key]: userPointer,
};
// if we already have a constraint on the key, use the $and
if (query.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(query, key)) {
return { $and: [q, query] };
}
// otherwise just add the constaint

View File

@@ -32,7 +32,10 @@ export class PushController {
}
// Immediate push
if (body.expiration_interval && !body.hasOwnProperty('push_time')) {
if (
body.expiration_interval &&
!Object.prototype.hasOwnProperty.call(body, 'push_time')
) {
const ttlMs = body.expiration_interval * 1000;
body.expiration_time = new Date(now.valueOf() + ttlMs).valueOf();
}
@@ -121,7 +124,7 @@ export class PushController {
})
.then(() => {
if (
body.hasOwnProperty('push_time') &&
Object.prototype.hasOwnProperty.call(body, 'push_time') &&
config.hasPushScheduledSupport
) {
return Promise.resolve();
@@ -147,7 +150,10 @@ export class PushController {
* @returns {Number|undefined} The expiration time if it exists in the request
*/
static getExpirationTime(body = {}) {
var hasExpirationTime = body.hasOwnProperty('expiration_time');
var hasExpirationTime = Object.prototype.hasOwnProperty.call(
body,
'expiration_time'
);
if (!hasExpirationTime) {
return;
}
@@ -174,7 +180,10 @@ export class PushController {
}
static getExpirationInterval(body = {}) {
const hasExpirationInterval = body.hasOwnProperty('expiration_interval');
const hasExpirationInterval = Object.prototype.hasOwnProperty.call(
body,
'expiration_interval'
);
if (!hasExpirationInterval) {
return;
}
@@ -198,7 +207,7 @@ export class PushController {
* @returns {Number|undefined} The push time if it exists in the request
*/
static getPushTime(body = {}) {
var hasPushTime = body.hasOwnProperty('push_time');
var hasPushTime = Object.prototype.hasOwnProperty.call(body, 'push_time');
if (!hasPushTime) {
return;
}