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:
committed by
Antonio Davi Macedo Coelho de Castro
parent
4bffdce047
commit
cf6e79ee75
@@ -127,9 +127,15 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
get(Parse.serverURL + '/aggregate/TestObject', options)
|
||||
.then(resp => {
|
||||
expect(resp.results.length).toBe(3);
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(resp.results[1].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(resp.results[2].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[1], 'objectId')
|
||||
).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[2], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).not.toBe(undefined);
|
||||
expect(resp.results[1].objectId).not.toBe(undefined);
|
||||
expect(resp.results[2].objectId).not.toBe(undefined);
|
||||
@@ -148,9 +154,15 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
const resp = await get(Parse.serverURL + '/aggregate/TestObject', options);
|
||||
expect(resp.results.length).toBe(3);
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(resp.results[1].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(resp.results[2].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[1], 'objectId')
|
||||
).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[2], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).not.toBe(undefined);
|
||||
expect(resp.results[1].objectId).not.toBe(undefined);
|
||||
expect(resp.results[2].objectId).not.toBe(undefined);
|
||||
@@ -371,8 +383,12 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
expect(results.length).toEqual(4);
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
const item = results[i];
|
||||
expect(item.hasOwnProperty('updatedAt')).toEqual(true);
|
||||
expect(item.hasOwnProperty('objectId')).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(item, 'updatedAt')).toEqual(
|
||||
true
|
||||
);
|
||||
expect(Object.prototype.hasOwnProperty.call(item, 'objectId')).toEqual(
|
||||
false
|
||||
);
|
||||
}
|
||||
done();
|
||||
});
|
||||
@@ -482,7 +498,9 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
get(Parse.serverURL + '/aggregate/TestObject', options)
|
||||
.then(resp => {
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).toBe(null);
|
||||
expect(resp.results[0].total).toBe(50);
|
||||
done();
|
||||
@@ -498,7 +516,9 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
get(Parse.serverURL + '/aggregate/TestObject', options)
|
||||
.then(resp => {
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).toBe(null);
|
||||
expect(resp.results[0].total).toBe(4);
|
||||
done();
|
||||
@@ -514,7 +534,9 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
get(Parse.serverURL + '/aggregate/TestObject', options)
|
||||
.then(resp => {
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).toBe(null);
|
||||
expect(resp.results[0].minScore).toBe(10);
|
||||
done();
|
||||
@@ -530,7 +552,9 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
get(Parse.serverURL + '/aggregate/TestObject', options)
|
||||
.then(resp => {
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).toBe(null);
|
||||
expect(resp.results[0].maxScore).toBe(20);
|
||||
done();
|
||||
@@ -546,7 +570,9 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
});
|
||||
get(Parse.serverURL + '/aggregate/TestObject', options)
|
||||
.then(resp => {
|
||||
expect(resp.results[0].hasOwnProperty('objectId')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(resp.results[0], 'objectId')
|
||||
).toBe(true);
|
||||
expect(resp.results[0].objectId).toBe(null);
|
||||
expect(resp.results[0].avgScore).toBe(12.5);
|
||||
done();
|
||||
@@ -966,7 +992,9 @@ describe('Parse.Query Aggregate testing', () => {
|
||||
.then(resp => {
|
||||
expect(resp.results.length).toBe(2);
|
||||
resp.results.forEach(result => {
|
||||
expect(result.hasOwnProperty('objectId')).toBe(true);
|
||||
expect(Object.prototype.hasOwnProperty.call(result, 'objectId')).toBe(
|
||||
true
|
||||
);
|
||||
expect(result.name).toBe(undefined);
|
||||
expect(result.sender).toBe(undefined);
|
||||
expect(result.size).toBe(undefined);
|
||||
|
||||
@@ -1382,19 +1382,29 @@ describe('SchemaController', () => {
|
||||
|
||||
it('properly handles volatile _Schemas', done => {
|
||||
function validateSchemaStructure(schema) {
|
||||
expect(schema.hasOwnProperty('className')).toBe(true);
|
||||
expect(schema.hasOwnProperty('fields')).toBe(true);
|
||||
expect(schema.hasOwnProperty('classLevelPermissions')).toBe(true);
|
||||
expect(Object.prototype.hasOwnProperty.call(schema, 'className')).toBe(
|
||||
true
|
||||
);
|
||||
expect(Object.prototype.hasOwnProperty.call(schema, 'fields')).toBe(true);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(schema, 'classLevelPermissions')
|
||||
).toBe(true);
|
||||
}
|
||||
function validateSchemaDataStructure(schemaData) {
|
||||
Object.keys(schemaData).forEach(className => {
|
||||
const schema = schemaData[className];
|
||||
// Hooks has className...
|
||||
if (className != '_Hooks') {
|
||||
expect(schema.hasOwnProperty('className')).toBe(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(schema, 'className')
|
||||
).toBe(false);
|
||||
}
|
||||
expect(schema.hasOwnProperty('fields')).toBe(false);
|
||||
expect(schema.hasOwnProperty('classLevelPermissions')).toBe(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(schema, 'fields')).toBe(
|
||||
false
|
||||
);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(schema, 'classLevelPermissions')
|
||||
).toBe(false);
|
||||
});
|
||||
}
|
||||
let schema;
|
||||
|
||||
@@ -469,8 +469,12 @@ describe('Verify User Password', () => {
|
||||
const res = response.data;
|
||||
expect(typeof res).toBe('object');
|
||||
expect(typeof res['objectId']).toEqual('string');
|
||||
expect(res.hasOwnProperty('sessionToken')).toEqual(false);
|
||||
expect(res.hasOwnProperty('password')).toEqual(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(res, 'sessionToken')
|
||||
).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual(
|
||||
false
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -493,8 +497,12 @@ describe('Verify User Password', () => {
|
||||
const res = response.data;
|
||||
expect(typeof res).toBe('object');
|
||||
expect(typeof res['objectId']).toEqual('string');
|
||||
expect(res.hasOwnProperty('sessionToken')).toEqual(false);
|
||||
expect(res.hasOwnProperty('password')).toEqual(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(res, 'sessionToken')
|
||||
).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual(
|
||||
false
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -513,8 +521,12 @@ describe('Verify User Password', () => {
|
||||
const res = response.data;
|
||||
expect(typeof res).toBe('object');
|
||||
expect(typeof res['objectId']).toEqual('string');
|
||||
expect(res.hasOwnProperty('sessionToken')).toEqual(false);
|
||||
expect(res.hasOwnProperty('password')).toEqual(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(res, 'sessionToken')
|
||||
).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual(
|
||||
false
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -544,8 +556,12 @@ describe('Verify User Password', () => {
|
||||
expect(typeof res).toBe('string');
|
||||
const body = JSON.parse(res);
|
||||
expect(typeof body['objectId']).toEqual('string');
|
||||
expect(body.hasOwnProperty('sessionToken')).toEqual(false);
|
||||
expect(body.hasOwnProperty('password')).toEqual(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(body, 'sessionToken')
|
||||
).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(body, 'password')).toEqual(
|
||||
false
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -575,8 +591,12 @@ describe('Verify User Password', () => {
|
||||
expect(typeof res).toBe('string');
|
||||
const body = JSON.parse(res);
|
||||
expect(typeof body['objectId']).toEqual('string');
|
||||
expect(body.hasOwnProperty('sessionToken')).toEqual(false);
|
||||
expect(body.hasOwnProperty('password')).toEqual(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(body, 'sessionToken')
|
||||
).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(body, 'password')).toEqual(
|
||||
false
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
@@ -603,8 +623,12 @@ describe('Verify User Password', () => {
|
||||
const res = response.data;
|
||||
expect(typeof res).toBe('object');
|
||||
expect(typeof res['objectId']).toEqual('string');
|
||||
expect(res.hasOwnProperty('sessionToken')).toEqual(false);
|
||||
expect(res.hasOwnProperty('password')).toEqual(false);
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(res, 'sessionToken')
|
||||
).toEqual(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(res, 'password')).toEqual(
|
||||
false
|
||||
);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user