If this is what you mean:
function combinePlayerOptions(playerOptions1 = {}, playerOptions2 = {}) {
const combined = Object.assign({}, playerOptions1, playerOptions2);
Object.keys(playerOptions1).forEach(function checkObjects(prop) {
if (typeof playerOptions1[prop] === "object") {
combined[prop] = Object.assign(
{},
playerOptions1[prop],
playerOptions2[prop]
);
}
});
return combined;
}
When it gets indented 4 spaces, it gets changed back to this:
And jslint doesn’t like this.
function combinePlayerOptions(playerOptions1 = {}, playerOptions2 = {}) {
const combined = Object.assign({}, playerOptions1, playerOptions2);
Object.keys(playerOptions1).forEach(function checkObjects(prop) {
if (typeof playerOptions1[prop] === "object") {
combined[prop] = Object.assign({},
playerOptions1[prop],
playerOptions2[prop]
);
}
});
return combined;
}
When this is used: I don’t need to worry about indenting 4 spaces messing up the code and needing to keep re-fixing the code each time it is placed in jslint.
function combinePlayerOptions(playerOptions1 = {}, playerOptions2 = {}) {
const combined = Object.assign({}, playerOptions1, playerOptions2);
Object.keys(playerOptions1).forEach(function checkObjects(prop) {
if (typeof playerOptions1[prop] === "object") {
const first = playerOptions1[prop];
const second = playerOptions2[prop];
combined[prop] = Object.assign({}, first, second);
}
});
return combined;
}
Would I be able to use that code above, or would this one be able to be written in a way where indenting 4 spaces won’t keep messing up the code where I have to keep re-fixing it inside jslint?
jslint likes this:
function combinePlayerOptions(playerOptions1 = {}, playerOptions2 = {}) {
const combined = Object.assign({}, playerOptions1, playerOptions2);
Object.keys(playerOptions1).forEach(function checkObjects(prop) {
if (typeof playerOptions1[prop] === "object") {
combined[prop] = Object.assign(
{},
playerOptions1[prop],
playerOptions2[prop]
);
}
});
return combined;
}
But indenting 4 spaces the code keeps getting changed back to this:
function combinePlayerOptions(playerOptions1 = {}, playerOptions2 = {}) {
const combined = Object.assign({}, playerOptions1, playerOptions2);
Object.keys(playerOptions1).forEach(function checkObjects(prop) {
if (typeof playerOptions1[prop] === "object") {
combined[prop] = Object.assign({},
playerOptions1[prop],
playerOptions2[prop]
);
}
});
return combined;
}