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

@@ -67,7 +67,7 @@ function loadAuthAdapter(provider, authOptions) {
const providerOptions = authOptions[provider];
if (
providerOptions &&
providerOptions.hasOwnProperty('oauth2') &&
Object.prototype.hasOwnProperty.call(providerOptions, 'oauth2') &&
providerOptions['oauth2'] === true
) {
defaultAdapter = oauth2;

View File

@@ -279,7 +279,7 @@ export class MongoStorageAdapter implements StorageAdapter {
delete existingIndexes[name];
} else {
Object.keys(field).forEach(key => {
if (!fields.hasOwnProperty(key)) {
if (!Object.prototype.hasOwnProperty.call(fields, key)) {
throw new Parse.Error(
Parse.Error.INVALID_QUERY,
`Field ${key} does not exist, cannot add index.`
@@ -795,7 +795,7 @@ export class MongoStorageAdapter implements StorageAdapter {
)
.then(results => {
results.forEach(result => {
if (result.hasOwnProperty('_id')) {
if (Object.prototype.hasOwnProperty.call(result, '_id')) {
if (isPointerField && result._id) {
result._id = result._id.split('$')[1];
}
@@ -1024,7 +1024,7 @@ export class MongoStorageAdapter implements StorageAdapter {
const existingIndexes = schema.indexes;
for (const key in existingIndexes) {
const index = existingIndexes[key];
if (index.hasOwnProperty(fieldName)) {
if (Object.prototype.hasOwnProperty.call(index, fieldName)) {
return Promise.resolve();
}
}

View File

@@ -1282,7 +1282,7 @@ const nestedMongoObjectToNestedParseObject = mongoObject => {
}
if (
mongoObject.hasOwnProperty('__type') &&
Object.prototype.hasOwnProperty.call(mongoObject, '__type') &&
mongoObject.__type == 'Date' &&
mongoObject.iso instanceof Date
) {

View File

@@ -903,7 +903,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
delete existingIndexes[name];
} else {
Object.keys(field).forEach(key => {
if (!fields.hasOwnProperty(key)) {
if (!Object.prototype.hasOwnProperty.call(fields, key)) {
throw new Parse.Error(
Parse.Error.INVALID_QUERY,
`Field ${key} does not exist, cannot add index.`
@@ -2219,7 +2219,12 @@ export class PostgresStorageAdapter implements StorageAdapter {
}
if (stage.$match) {
const patterns = [];
const orOrAnd = stage.$match.hasOwnProperty('$or') ? ' OR ' : ' AND ';
const orOrAnd = Object.prototype.hasOwnProperty.call(
stage.$match,
'$or'
)
? ' OR '
: ' AND ';
if (stage.$match.$or) {
const collapse = {};
@@ -2294,7 +2299,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
)
.then(results => {
results.forEach(result => {
if (!result.hasOwnProperty('objectId')) {
if (!Object.prototype.hasOwnProperty.call(result, 'objectId')) {
result.objectId = null;
}
if (groupValues) {