mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-20 23:44:08 +00:00
Enable eslint style rule 'keyword-spacing'
After Stan suggesting change in a review comment just enable the rule 'keyword-spacing' [1] and fix violations so this is no longer a topic in spirit of #7812. [1] https://eslint.style/rules/keyword-spacing Ref: #7245 Ref: #7812 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
@@ -20,11 +20,11 @@ Engine.RegisterComponentType(IID_Test1, "TestScript1_Init", TestScript1_Init);
|
||||
function TestScript1_readonly() {}
|
||||
|
||||
TestScript1_readonly.prototype.GetX = function() {
|
||||
try { this.template = null; } catch(e) { /* noop */ }
|
||||
try { delete this.template; } catch(e) { /* noop */ }
|
||||
try { this.template.x += 1000; } catch(e) { /* noop */ }
|
||||
try { delete this.template.x; } catch(e) { /* noop */ }
|
||||
try { this.template.y = 2000; } catch(e) { /* noop */ }
|
||||
try { this.template = null; } catch (e) { /* noop */ }
|
||||
try { delete this.template; } catch (e) { /* noop */ }
|
||||
try { this.template.x += 1000; } catch (e) { /* noop */ }
|
||||
try { delete this.template.x; } catch (e) { /* noop */ }
|
||||
try { this.template.y = 2000; } catch (e) { /* noop */ }
|
||||
return +(this.template.x || 1) + +(this.template.y || 2);
|
||||
};
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class LoadModal extends AutoWatcher
|
||||
{
|
||||
out.push(new CampaignRun(name).load());
|
||||
}
|
||||
catch(err)
|
||||
catch (err)
|
||||
{
|
||||
warn(err.toString());
|
||||
out.push(new BrokenRun(name));
|
||||
|
||||
@@ -95,7 +95,7 @@ class GameSettingsController
|
||||
if (settings)
|
||||
this.parseSettings(settings, true);
|
||||
}
|
||||
} catch(err) {
|
||||
} catch (err) {
|
||||
error("There was an error loading game settings. You may need to disable persistent match settings.");
|
||||
warn(err?.toString() ?? uneval(err));
|
||||
if (err.stack)
|
||||
|
||||
@@ -22,7 +22,7 @@ function init()
|
||||
function applySelectedLocale()
|
||||
{
|
||||
var localeText = Engine.GetGUIObjectByName("localeText");
|
||||
if(!Engine.SaveLocale(localeText.caption))
|
||||
if (!Engine.SaveLocale(localeText.caption))
|
||||
{
|
||||
warn("Selected locale could not be saved in the configuration!");
|
||||
return;
|
||||
@@ -37,7 +37,7 @@ function languageSelectionChanged()
|
||||
var locale = languageList.list_data[languageList.selected];
|
||||
if (locale == "long")
|
||||
warn("'long' is not an actual language, just a collection of all longest strings extracted from some languages");
|
||||
else if(!Engine.ValidateLocale(locale))
|
||||
else if (!Engine.ValidateLocale(locale))
|
||||
warn("Selected locale is not valid! This is not expected, please report the issue.");
|
||||
var localeText = Engine.GetGUIObjectByName("localeText");
|
||||
localeText.caption = locale;
|
||||
|
||||
@@ -79,7 +79,7 @@ var g_MainMenuItems = [
|
||||
{
|
||||
Engine.SwitchGuiPage(CampaignRun.getCurrentRun().getMenuPath());
|
||||
}
|
||||
catch(err)
|
||||
catch (err)
|
||||
{
|
||||
error("Error opening campaign run:");
|
||||
error(err.toString());
|
||||
@@ -136,7 +136,7 @@ var g_MainMenuItems = [
|
||||
{
|
||||
Engine.SwitchGuiPage(CampaignRun.getCurrentRun().getMenuPath());
|
||||
}
|
||||
catch(err)
|
||||
catch (err)
|
||||
{
|
||||
error("Error opening campaign run:");
|
||||
error(err.toString());
|
||||
|
||||
@@ -58,7 +58,7 @@ class CivInfoPage extends ReferencePage
|
||||
|
||||
const civInfo = this.civData[civCode];
|
||||
|
||||
if(!civInfo)
|
||||
if (!civInfo)
|
||||
error(sprintf("Error loading civ data for \"%(code)s\"", { "code": civCode }));
|
||||
|
||||
this.gameplaySection.update(this.activeCiv, civInfo);
|
||||
|
||||
@@ -240,10 +240,10 @@ function filterReplays()
|
||||
else if (cmpA > cmpB)
|
||||
return +sortOrder;
|
||||
|
||||
else if(cmpA_secondary && cmpB_secondary)
|
||||
else if (cmpA_secondary && cmpB_secondary)
|
||||
if (cmpA_secondary < cmpB_secondary)
|
||||
return -sortOrder;
|
||||
else if(cmpA_secondary > cmpB_secondary)
|
||||
else if (cmpA_secondary > cmpB_secondary)
|
||||
return +sortOrder;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -86,14 +86,14 @@ function Noise3D(freq, vfreq)
|
||||
for (let j=0; j < freq; ++j)
|
||||
{
|
||||
this.grads[i][j] = [];
|
||||
for(let k=0; k < vfreq; ++k)
|
||||
for (let k=0; k < vfreq; ++k)
|
||||
{
|
||||
const v = new Vector3D();
|
||||
do
|
||||
{
|
||||
v.set(randFloat(-1, 1), randFloat(-1, 1), randFloat(-1, 1));
|
||||
}
|
||||
while(v.lengthSquared() > 1 || v.lengthSquared() < 0.1);
|
||||
while (v.lengthSquared() > 1 || v.lengthSquared() < 0.1);
|
||||
|
||||
v.normalize();
|
||||
|
||||
|
||||
@@ -297,7 +297,7 @@ m.Accessibility.prototype.floodFill = function(startIndex, value, onWater)
|
||||
// Get x and y from index
|
||||
const IndexArray = [startIndex];
|
||||
let newIndex;
|
||||
while(IndexArray.length)
|
||||
while (IndexArray.length)
|
||||
{
|
||||
newIndex = IndexArray.pop();
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ PETRA.PetraBot.prototype.OnUpdate = function(sharedScript)
|
||||
{
|
||||
if (i == "AIMetadata") // not used inside petra
|
||||
continue;
|
||||
if(this.savedEvents[i] !== undefined)
|
||||
if (this.savedEvents[i] !== undefined)
|
||||
this.savedEvents[i] = this.savedEvents[i].concat(this.events[i]);
|
||||
else
|
||||
this.savedEvents[i] = this.events[i];
|
||||
|
||||
@@ -1081,7 +1081,7 @@ PETRA.BaseManager.prototype.update = function(gameState, queues, events)
|
||||
if (this.constructing)
|
||||
{
|
||||
const owner = gameState.ai.HQ.territoryMap.getOwner(this.anchor.position());
|
||||
if(owner != 0 && !gameState.isPlayerAlly(owner))
|
||||
if (owner != 0 && !gameState.isPlayerAlly(owner))
|
||||
{
|
||||
// we're in enemy territory. If we're too close from the enemy, destroy us.
|
||||
const ccEnts = gameState.updatingGlobalCollection("allCCs", API3.Filters.byClass("CivCentre"));
|
||||
|
||||
@@ -354,7 +354,7 @@ PETRA.DefenseManager.prototype.checkEnemyArmies = function(gameState)
|
||||
continue;
|
||||
if (API3.SquareVectorDistance(base.position(), army.foePosition) > 40000)
|
||||
continue;
|
||||
if(this.Config.debug > 1)
|
||||
if (this.Config.debug > 1)
|
||||
API3.warn("army in neutral territory, but still near one of our CC");
|
||||
stillDangerous = true;
|
||||
break;
|
||||
|
||||
@@ -260,7 +260,7 @@ AIInterface.prototype.OnTemplateModification = function(msg)
|
||||
newValue = Math.round(newValue);
|
||||
// TODO in some cases, we can have two opposite changes which bring us to the old value,
|
||||
// and we should keep it. But how to distinguish it ?
|
||||
if(newValue == oldValue)
|
||||
if (newValue == oldValue)
|
||||
continue;
|
||||
if (!this.changedTemplateInfo[msg.player])
|
||||
this.changedTemplateInfo[msg.player] = {};
|
||||
|
||||
@@ -62,7 +62,7 @@ PopulationCapManager.prototype.GetPopulationCap = function()
|
||||
*/
|
||||
PopulationCapManager.prototype.InitializePopCaps = function()
|
||||
{
|
||||
switch(this.popCapType)
|
||||
switch (this.popCapType)
|
||||
{
|
||||
case CAPTYPE_PLAYER_POPULATION:
|
||||
this.InitializePlayerPopCaps();
|
||||
@@ -149,7 +149,7 @@ PopulationCapManager.prototype.RedistributeWorldPopCap = function()
|
||||
*/
|
||||
PopulationCapManager.prototype.OnGlobalPlayerDefeated = function(msg)
|
||||
{
|
||||
switch(this.popCapType)
|
||||
switch (this.popCapType)
|
||||
{
|
||||
case CAPTYPE_TEAM_POPULATION:
|
||||
{
|
||||
|
||||
@@ -139,18 +139,18 @@ cmpTurretHolder = ConstructComponent(turretHolderID, "TurretHolder", {
|
||||
let spawned = 100;
|
||||
Engine.AddEntity = function() {
|
||||
++spawned;
|
||||
if(spawned > 101)
|
||||
if (spawned > 101)
|
||||
{
|
||||
ConstructComponent(spawned, "Turretable", {});
|
||||
}
|
||||
if(spawned > 102)
|
||||
if (spawned > 102)
|
||||
{
|
||||
AddMock(spawned, IID_Ownership, {
|
||||
"GetOwner": () => player,
|
||||
"SetOwner": () => {}
|
||||
});
|
||||
}
|
||||
if(spawned > 103)
|
||||
if (spawned > 103)
|
||||
{
|
||||
AddMock(spawned, IID_Position, {
|
||||
"GetPosition": () => new Vector3D(4, 3, 25),
|
||||
|
||||
@@ -14,7 +14,7 @@ function Cheat(input)
|
||||
const cmpGuiInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
|
||||
const cmpPopulationManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PopulationCapManager);
|
||||
|
||||
switch(input.action)
|
||||
switch (input.action)
|
||||
{
|
||||
case "addresource":
|
||||
if (isNaN(input.parameter))
|
||||
|
||||
@@ -41,7 +41,7 @@ var g_Commands = {
|
||||
if (!cmpDiplomacy || cmpDiplomacy.IsTeamLocked())
|
||||
return;
|
||||
|
||||
switch(cmd.to)
|
||||
switch (cmd.to)
|
||||
{
|
||||
case "ally":
|
||||
cmpDiplomacy.Ally(cmd.player);
|
||||
@@ -240,7 +240,7 @@ var g_Commands = {
|
||||
for (const ent of data.entities)
|
||||
{
|
||||
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
|
||||
if(!cmpUnitAI || !cmpUnitAI.BackToWork())
|
||||
if (!cmpUnitAI || !cmpUnitAI.BackToWork())
|
||||
notifyBackToWorkFailure(player);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -49,7 +49,7 @@ function InitGame(settings)
|
||||
|
||||
if (settings.PlayerData[i])
|
||||
{
|
||||
if(settings.PlayerData[i].Removed)
|
||||
if (settings.PlayerData[i].Removed)
|
||||
{
|
||||
cmpPlayer.Defeat(undefined);
|
||||
continue;
|
||||
|
||||
@@ -124,6 +124,7 @@ const configStylistic = {
|
||||
"@stylistic/comma-spacing": "warn",
|
||||
"@stylistic/indent": ["warn", "tab", { "outerIIFEBody": "off" }],
|
||||
"@stylistic/key-spacing": "warn",
|
||||
"@stylistic/keyword-spacing": ["warn", { "before": true, "after": true }],
|
||||
"@stylistic/new-parens": "warn",
|
||||
"@stylistic/no-extra-parens": "off",
|
||||
"@stylistic/no-extra-semi": "warn",
|
||||
|
||||
@@ -218,7 +218,7 @@ class Profiler2Report
|
||||
if (data[i][0] == this.ITEM_LEAVE)
|
||||
stack.pop();
|
||||
}
|
||||
if(!range)
|
||||
if (!range)
|
||||
{
|
||||
range = { "tmin": data[0][1], "tmax": data[data.length-1][1] };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user