forked from mirrors/0ad
Enable eslint rule 'no-prototype-builtins'
Enable recommended rule 'no-prototype-builtins' [1] and manually fix violations. [1] https://eslint.org/docs/latest/rules/no-prototype-builtins Ref: #8068 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
@@ -346,7 +346,7 @@ PETRA.Config.prototype.Serialize = function()
|
||||
{
|
||||
var data = {};
|
||||
for (const key in this)
|
||||
if (this.hasOwnProperty(key) && key != "debug")
|
||||
if (Object.hasOwn(this, key) && key != "debug")
|
||||
data[key] = this[key];
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ AIInterface.prototype.Serialize = function()
|
||||
const state = {};
|
||||
for (var key in this)
|
||||
{
|
||||
if (!this.hasOwnProperty(key))
|
||||
if (!Object.hasOwn(this, key))
|
||||
continue;
|
||||
if (typeof this[key] == "function")
|
||||
continue;
|
||||
@@ -63,7 +63,7 @@ AIInterface.prototype.Deserialize = function(data)
|
||||
{
|
||||
for (const key in data)
|
||||
{
|
||||
if (!data.hasOwnProperty(key))
|
||||
if (!Object.hasOwn(data, key))
|
||||
continue;
|
||||
this[key] = data[key];
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ Diplomacy.prototype.Serialize = function()
|
||||
{
|
||||
const state = {};
|
||||
for (const key of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(key))
|
||||
if (Object.hasOwn(this, key))
|
||||
state[key] = this[key];
|
||||
|
||||
return state;
|
||||
|
||||
@@ -30,7 +30,7 @@ Player.prototype.Serialize = function()
|
||||
{
|
||||
const state = {};
|
||||
for (const key in this)
|
||||
if (this.hasOwnProperty(key))
|
||||
if (Object.hasOwn(this, key))
|
||||
state[key] = this[key];
|
||||
|
||||
// Modified by GUI, so don't serialise.
|
||||
|
||||
@@ -202,7 +202,7 @@ ProductionQueue.prototype.Item.prototype.Serialize = function()
|
||||
{
|
||||
const result = {};
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
return result;
|
||||
};
|
||||
@@ -236,7 +236,7 @@ ProductionQueue.prototype.Serialize = function()
|
||||
result.queue.push(item.Serialize());
|
||||
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
|
||||
return result;
|
||||
|
||||
@@ -129,7 +129,7 @@ Researcher.prototype.Item.prototype.Serialize = function(id)
|
||||
"id": id
|
||||
};
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -183,7 +183,7 @@ TechnologyManager.prototype.Technology.prototype.Serialize = function()
|
||||
{
|
||||
const result = {};
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
return result;
|
||||
};
|
||||
@@ -227,7 +227,7 @@ TechnologyManager.prototype.Serialize = function()
|
||||
{
|
||||
const result = {};
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
|
||||
result.researchQueued = [];
|
||||
|
||||
@@ -406,7 +406,7 @@ Trainer.prototype.Item.prototype.Serialize = function(id)
|
||||
"id": id
|
||||
};
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
return result;
|
||||
};
|
||||
@@ -441,7 +441,7 @@ Trainer.prototype.Serialize = function()
|
||||
"queue": queue
|
||||
};
|
||||
for (const att of this.SerializableAttributes)
|
||||
if (this.hasOwnProperty(att))
|
||||
if (Object.hasOwn(this, att))
|
||||
result[att] = this[att];
|
||||
|
||||
return result;
|
||||
|
||||
@@ -151,7 +151,7 @@ global.SerializationCycle = function(cmp)
|
||||
{
|
||||
data = {};
|
||||
for (const att of cmp)
|
||||
if (cmp.hasOwnProperty(att))
|
||||
if (Object.hasOwn(cmp, att))
|
||||
data[att] = cmp[att];
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@ const configEslintRecommended = {
|
||||
"no-nonoctal-decimal-escape": "warn",
|
||||
"no-obj-calls": "warn",
|
||||
"no-octal": "warn",
|
||||
"no-prototype-builtins": "warn",
|
||||
"no-redeclare": "warn",
|
||||
"no-regex-spaces": "warn",
|
||||
"no-self-assign": "warn",
|
||||
|
||||
Reference in New Issue
Block a user