✨ (all) improve linter settings

This commit is contained in:
Gregor Zeitlinger 2022-01-08 15:46:15 +01:00
commit 4f5ec32d57
8 changed files with 28 additions and 26 deletions

View file

@ -16,17 +16,17 @@ module.exports = {
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-function": "error",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-use-before-define": "off",
"@typescript-eslint/no-namespace": "off",
"no-inner-declarations": "off",
"no-return-assign": "off",
"no-fallthrough": "off",
"no-return-assign": "error",
"no-fallthrough": "error",
"no-invalid-this": "error",
eqeqeq: ["error", "always"],
},

View file

@ -299,9 +299,6 @@ export default class Engine {
}
this.sanitizeOptions();
this.loadMoves(moves);
if (replay) {
this.options = options; // is this necessary?
}
}
/** Fix old options passed. To remove when legacy data is no more in database */

View file

@ -357,10 +357,10 @@ export default class SpaceMap {
const relative = CubeCoordinates.parse(reverseSuffixes[suffix]);
let center = this.placement!.sectors!.find((conf) => conf.sector.replace(/[AB]/, "") === sector).center!;
let center = this.placement.sectors.find((conf) => conf.sector.replace(/[AB]/, "") === sector).center;
if (!center) {
const index = this.placement!.sectors!.findIndex((conf) => conf.sector.replace(/[AB]/, "") === sector);
const index = this.placement.sectors.findIndex((conf) => conf.sector.replace(/[AB]/, "") === sector);
center = (this.placement.sectors.length === 7 ? smallCenters : bigCenters)[index];
}

View file

@ -486,8 +486,10 @@ export default class PlayerData extends EventEmitter {
switch (area) {
case PowerArea.Area3:
power += this.power.area3;
// eslint-disable-next-line no-fallthrough
case PowerArea.Area2:
power += this.power.area2;
// eslint-disable-next-line no-fallthrough
case PowerArea.Area1:
power += this.power.area1;
}

View file

@ -11,15 +11,16 @@ module.exports = {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
semi: ["error", "always"],
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/consistent-type-assertions": "off",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unused-vars": "off",
"no-return-assign": "off",
"no-lone-blocks": "off",
"no-unmodified-loop-condition": "off",
"no-useless-return": "off",
"no-return-assign": "error",
"no-lone-blocks": "error",
"no-unmodified-loop-condition": "error",
"no-useless-return": "error",
"no-invalid-this": "error",
quotes: "off",
},
};

View file

@ -94,6 +94,7 @@ type Table = { title: string; header: any[]; items: any[] };
components: { PlayerCircle, BuildingImage, SpecialAction },
})
export default class Charts extends Vue {
// eslint-disable-next-line no-invalid-this
private chartStyle: ChartStyleDisplay = this.chartStyles[0];
private chartFamily: ChartFamily = vpChartFamily;
private chartKind: ChartKind = barChartKind;

View file

@ -155,7 +155,7 @@ import { orderedPlayers } from "../data/player";
}
this.handleData(Engine.fromData(JSON.parse(JSON.stringify(this.engine))));
return;
}
});

View file

@ -198,15 +198,16 @@ export function makeHistory(
const bumpLog = () => {
advancedLogIndex += 1;
nextLogEntry = advancedLog[advancedLogIndex];
const entry = advancedLog[advancedLogIndex];
if (advancedLogIndex == 0) {
ret.push(makeEntry(data, state, recent.index > 0 && onlyRecent ? "moves-skipped" : Phase.SetupInit));
} else if (nextLogEntry?.round) {
state.round = nextLogEntry.round;
} else if (entry?.round) {
state.round = entry.round;
newPhase(Phase.RoundStart, 0);
} else if (nextLogEntry?.phase) {
newPhase(nextLogEntry?.phase, state.turn);
} else if (entry?.phase) {
newPhase(entry?.phase, state.turn);
}
return entry;
};
const newEntry = (move: ParsedMove = null, entry: LogEntry = nextLogEntry): HistoryEntry => {
@ -214,7 +215,7 @@ export function makeHistory(
return makeEntry(data, state, newPhase, move, entry.player, entry.changes);
};
bumpLog();
nextLogEntry = bumpLog();
recent.allMoves.forEach((parsedMove, i) => {
if (onlyRecent && i == recent.index) {
@ -233,19 +234,19 @@ export function makeHistory(
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
addEntry(newEntry());
}
bumpLog();
nextLogEntry = bumpLog();
}
const entry = newEntry(replaceMove(data, parsedMove), {} as LogEntry);
if (nextLogEntry && nextLogEntry.move === i) {
entry.changes = makeChanges(data, nextLogEntry.changes);
bumpLog();
nextLogEntry = bumpLog();
}
addEntry(entry);
while (nextLogEntry && nextLogEntry.move === undefined) {
if (nextLogEntry.player === undefined || !!nextLogEntry.changes) {
addEntry(newEntry());
}
bumpLog();
nextLogEntry = bumpLog();
}
});