Skip to content

Commit ab98772

Browse files
authored
use in operator instead of hasOwnProperty (#1094)
1 parent 5f3c7fe commit ab98772

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

.eslintrc.js

-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ module.exports = {
2020
// want new controllers to be added again unless needed for query
2121
// parameter handling.
2222
'ember/no-controllers': 'error',
23-
// Croodle is not compliant with some of the recommended rules yet.
24-
// We should refactor the code step by step and enable them as soon
25-
// as the code is compliant.
26-
'ember/classic-decorator-no-classic-methods': 'warn',
27-
'ember/no-controller-access-in-routes': 'warn',
28-
'ember/no-observers': 'warn',
29-
'no-prototype-builtins': 'warn',
3023
},
3124
overrides: [
3225
// ts files

mirage/serializers/application.js

+9-12
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,18 @@ export default RestSerializer.extend({
2525
if (key === 'id') {
2626
// records id
2727
jsonApiPayload.data.id = attrs.id;
28-
} else if (
29-
belongsToAssociations.hasOwnProperty(key) ||
30-
hasManyAssociations.hasOwnProperty(key)
31-
) {
28+
} else if (key in belongsToAssociations || key in hasManyAssociations) {
3229
// relationship
33-
if (!jsonApiPayload.data.hasOwnProperty('relationships')) {
30+
if (!('relationships' in jsonApiPayload.data)) {
3431
jsonApiPayload.data.relationships = {};
3532
}
3633

37-
let association = belongsToAssociations.hasOwnProperty(key)
38-
? belongsToAssociations[key]
39-
: hasManyAssociations[key];
40-
let associationType = belongsToAssociations.hasOwnProperty(key)
41-
? 'belongsTo'
42-
: 'hasMany';
34+
let association =
35+
key in belongsToAssociations
36+
? belongsToAssociations[key]
37+
: hasManyAssociations[key];
38+
let associationType =
39+
key in belongsToAssociations ? 'belongsTo' : 'hasMany';
4340
let associationModel = association.modelName;
4441
let relationshipObject = {};
4542

@@ -64,7 +61,7 @@ export default RestSerializer.extend({
6461
jsonApiPayload.data.relationships[key] = relationshipObject;
6562
} else {
6663
// attribute
67-
if (!jsonApiPayload.data.hasOwnProperty('attributes')) {
64+
if (!('attributes' in jsonApiPayload.data)) {
6865
jsonApiPayload.data.attributes = {};
6966
}
7067

0 commit comments

Comments
 (0)