Skip to content

Enable all linting rules blocking unused code #451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
},
"correctness": {
"recommended": true,
"noSwitchDeclarations": "off"
"noUnusedFunctionParameters": "error",
"noUnusedImports": "error",
"noUnusedVariables": "error",
"noUnusedPrivateClassMembers": "error"
},
"performance": {
"recommended": true,
Expand All @@ -58,7 +61,6 @@
"noInferrableTypes": "off",
"noNonNullAssertion": "off",
"noParameterAssign": "off",
"noUnusedTemplateLiteral": "off",
"noUselessElse": "off",
"useEnumInitializers": "off",
"useImportType": "off",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"build:watch": "swc ./src -d dist -w --strip-leading-paths",
"lint": "biome lint",
"lint:fin": "biome lint --write --diagnostic-level=error --reporter=summary",
"lint:fix": "biome lint --write",
"lint:fix": "biome lint --write --unsafe",
"format": "biome format",
"format:fin": "biome format --write --reporter=summary",
"format:fix": "biome format --write",
Expand Down
4 changes: 2 additions & 2 deletions src/engine/action/hook/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class TaskExecutor<T> {
const response = await this.task.activate(this, this.iteration++);
return typeof response === 'boolean' ? response : true;
} catch (error) {
logger.error(`Error executing action task`);
logger.error('Error executing action task');
logger.error(error);
return false;
}
Expand All @@ -130,7 +130,7 @@ export class TaskExecutor<T> {
try {
return this.task.canActivate(this, this.iteration);
} catch (error) {
logger.error(`Error calling action canActivate`, this.task);
logger.error('Error calling action canActivate', this.task);
logger.error(error);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/action/pipe/prayer.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface PrayerAction {
* @param buttonId
*/
const prayerActionPipe = (npc: Npc, player: Player, widgetId: number, buttonId: number): RunnableHooks<PrayerAction> => {
console.info(`You used prayer`);
console.info('You used prayer');

// Find all object action plugins that reference this location object
const matchingHooks = getActionHooks<PrayerActionHook>('button');
Expand Down
2 changes: 1 addition & 1 deletion src/engine/config/config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function loadCoreConfigurations(): Promise<void> {
}

export async function loadGameConfigurations(): Promise<void> {
logger.info(`Loading server configurations...`);
logger.info('Loading server configurations...');

const { items, itemIds, itemPresets, itemGroups } = await loadItemConfigurations('data/config/items/');
itemMap = items;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/config/data-dump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function dump<T>(fileName: string, definitions: T[]): DataDumpResult {
successful: true,
filePath,
};
} catch (error) {
} catch (_) {
logger.error(`Error dumping ${fileName}`);
return {
successful: false,
Expand Down
3 changes: 1 addition & 2 deletions src/engine/config/shop-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,9 @@ describe('shopping', () => {

const shopname = 'rs:test_shop';
let shop: Shop;
let world;

beforeAll(async () => {
world = await setupConfig();
await setupConfig();
});

beforeEach(() => {
Expand Down
1 change: 1 addition & 0 deletions src/engine/net/inbound-packets/walk.packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const walkPacket = (player: Player, packet: PacketData) => {
const totalSteps = Math.floor((size - 5) / 2);

const firstY = buffer.get('short', 'u', 'le');
// biome-ignore lint/correctness/noUnusedVariables: Someone might need this one day I guess.
const runSteps = buffer.get('byte') === 1; // @TODO forced running
const firstX = buffer.get('short', 'u', 'le');

Expand Down
11 changes: 2 additions & 9 deletions src/engine/net/outbound-packet-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class OutboundPacketHandler {
this.queue(packet);
}

public sendPrivateMessage(chatId: number, sender: Player, message: number[]): void {
public sendPrivateMessage(sender: Player, message: number[]): void {
const packet = new Packet(51, PacketType.DYNAMIC_SMALL);
packet.put(stringToLong(sender.username.toLowerCase()), 'LONG');
packet.put(32767, 'SHORT');
Expand Down Expand Up @@ -134,14 +134,7 @@ export class OutboundPacketHandler {
this.queue(packet);
}

public playSoundAtPosition(
soundId: number,
soundX: number,
soundY: number,
volume: number,
radius: number = 5,
delay: number = 0,
): void {
public playSoundAtPosition(soundId: number, volume: number, radius: number = 5, delay: number = 0): void {
const packet = new Packet(9);
const offset = 0;
packet.put(offset, 'BYTE');
Expand Down
2 changes: 1 addition & 1 deletion src/engine/plugins/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function loadPlugins(): Promise<void> {
}
});
} else {
logger.warn(`No action hooks detected - update plugins.`);
logger.warn('No action hooks detected - update plugins.');
}

for (const plugin of plugins) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/task/impl/actor-walk-to-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type WalkToTarget = WalkToTargetType | (() => WalkToTargetType);
*
* @author jameskmonger
*/
export interface ActorWalkToTask<TActor extends Actor = Actor, TTarget extends WalkToTarget = Position> extends ActorTask<TActor> {
export interface ActorWalkToTask<TActor extends Actor = Actor> extends ActorTask<TActor> {
/**
* An optional function that is called when the actor arrives at the destination.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/engine/util/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function getStylingType(tag: string) {
}

// Thank you to the Apollo team for these values. :)
// biome-ignore lint/correctness/noUnusedVariables: Someone might want these one day!
const charWidths = [
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 7, 14, 9, 12, 12, 4, 5, 5, 10, 8,
4, 8, 4, 7, 9, 7, 9, 8, 8, 8, 9, 7, 9, 9, 4, 5, 7, 9, 7, 9, 14, 9, 8, 8, 8, 7, 7, 9, 8, 6, 8, 8, 7, 10, 9, 9, 8, 9, 8, 8, 6, 9, 8, 10,
Expand Down Expand Up @@ -71,7 +72,7 @@ export function wrapText(text: string, maxWidth: number, font?: number | string)
hidden = true;
currentTagIndex = currentLine.length + 1;
break;
case '>':
case '>': {
hidden = true;
const currentTag = currentLine.substring(currentTagIndex, currentLine.length);
currentTagIndex = -1;
Expand All @@ -91,6 +92,7 @@ export function wrapText(text: string, maxWidth: number, font?: number | string)
}
}
break;
}
case '@':
break;
case '\n':
Expand Down
12 changes: 4 additions & 8 deletions src/engine/world/actor/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export abstract class Actor {
public enqueueTask<T1>(taskClass: new (actor: Actor, arg1: T1) => Task, args: [T1]): void;
public enqueueTask<T>(taskClass: new (actor: Actor, ...args: T[]) => Task, args: T[]): void {
if (!this.active) {
logger.warn(`Attempted to instantiate task for inactive actor`);
logger.warn('Attempted to instantiate task for inactive actor');
return;
}

Expand All @@ -133,7 +133,7 @@ export abstract class Actor {
*/
public enqueueBaseTask(task: Task): void {
if (!this.active) {
logger.warn(`Attempted to enqueue task for inactive actor`);
logger.warn('Attempted to enqueue task for inactive actor');
return;
}

Expand Down Expand Up @@ -437,7 +437,7 @@ export abstract class Actor {

let valid = true;

if (!this.withinBounds(px, py)) {
if (isNpc(this) && !this.withinBounds(px, py)) {
valid = false;
}

Expand Down Expand Up @@ -473,7 +473,7 @@ export abstract class Actor {
px += movementDirection.deltaX;
py += movementDirection.deltaY;

if (!this.withinBounds(px, py)) {
if (isNpc(this) && !this.withinBounds(px, py)) {
valid = false;
}
}
Expand All @@ -488,10 +488,6 @@ export abstract class Actor {
}
}

public withinBounds(x: number, y: number): boolean {
return true;
}

/**
* Initialise the actor.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/engine/world/actor/dialogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ function parseDialogueTree(player: Player, npcParticipants: NpcParticipant[], di
}

if (isOptions) {
const options = (result as any[]).filter((option, index) => index % 2 === 0);
const trees = (result as any[]).filter((option, index) => index % 2 !== 0);
const options = (result as any[]).filter((_, index) => index % 2 === 0);
const trees = (result as any[]).filter((_, index) => index % 2 !== 0);
const optionsDialogueAction: OptionsDialogueAction = {
options: {},
tag: tag || '',
Expand Down Expand Up @@ -784,7 +784,7 @@ export async function itemSelectionDialogue(player: Player, type: 'COOKING' | 'M
widgetId = 309;
} else {
if (items.length > 5) {
throw new Error(`Too many items provided to the item selection action!`);
throw new Error('Too many items provided to the item selection action!');
}

widgetId = 301 + items.length;
Expand Down
2 changes: 1 addition & 1 deletion src/engine/world/actor/npc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class Npc extends Actor {

//This is useful so that we can tie into things like "spell casts" or events, or traps, etc to finish quests or whatever
public async processDeath(assailant: Actor, defender: Actor): Promise<void> {
return new Promise<void>(resolve => {
return new Promise<void>(() => {
const deathPosition = defender.position;

let deathAnim: number = animationIds.death;
Expand Down
10 changes: 5 additions & 5 deletions src/engine/world/actor/pathfinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class Pathfinding {
const highestY = position.y + searchRadius;

if (destinationX < lowestX || destinationX > highestX || destinationY < lowestY || destinationY > highestY) {
throw new Error(`Out of range.`);
throw new Error('Out of range.');
}

const destinationIndexX = destinationX - position.x + searchRadius;
Expand All @@ -138,10 +138,10 @@ export class Pathfinding {
const pointLen = searchRadius * 2;

if (pointLen <= 0) {
throw new Error(`Why is your search radius zero?`);
throw new Error('Why is your search radius zero?');
}

this.points = [...Array(pointLen)].map(e => Array(pointLen));
this.points = [...Array(pointLen)].map(() => Array(pointLen));

for (let x = 0; x < pointLen; x++) {
for (let y = 0; y < pointLen; y++) {
Expand Down Expand Up @@ -250,7 +250,7 @@ export class Pathfinding {
iterations++;

if (iterations > 1000) {
throw new Error(`Path iteration overflow, path can not be found.`);
throw new Error('Path iteration overflow, path can not be found.');
}

if (point === null) {
Expand Down Expand Up @@ -414,7 +414,7 @@ export class Pathfinding {
const globalTileFlags = globalAdjacencyForTile === null ? null : globalAdjacencyForTile & i;

return instancedTileFlags === null ? globalTileFlags === 0 : instancedTileFlags === 0;
} catch (error) {
} catch (_) {
logger.error(`Unable to calculate movement permission for local coordinates ${destinationLocalX},${destinationLocalY}.`);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/world/actor/player/achievements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const Achievements: { [key: string]: Achievement } = {
id: 'bury-bones',
name: 'Grave Digger',
description: 'Bury the bones of the dead.',
longDescription: `Bury the remains of a deceased enemy.`,
longDescription: 'Bury the remains of a deceased enemy.',
series: AchievementSeries.LUMBRIDGE,
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/engine/world/actor/player/dialogue-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class DialogueAction {
this.p.outgoingPackets.updateWidgetString(widgetId, textOffset + i, options.lines[i]);
}

return new Promise<DialogueAction>((resolve, reject) => {
return new Promise<DialogueAction>(resolve => {
this.p.interfaceState.openWidget(widgetId, {
slot: 'chatbox',
});
Expand Down
4 changes: 2 additions & 2 deletions src/engine/world/actor/player/player-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export function savePlayerData(player: Player): boolean {
try {
writeFileSync(filePath, JSON.stringify(playerSave, null, 4));
return true;
} catch (error) {
} catch (_) {
logger.error(`Error saving player data for ${player.username}.`);
return false;
}
Expand Down Expand Up @@ -177,7 +177,7 @@ export function loadPlayerSave(username: string): PlayerSave | null {
playerSave.position.level = 0;
}
return playerSave;
} catch (error) {
} catch (_) {
logger.error(`Malformed player save data for ${username}.`);
return null;
}
Expand Down
17 changes: 7 additions & 10 deletions src/engine/world/actor/player/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ export class Player extends Actor {
this.outgoingPackets.updateWidgetString(
widgets.welcomeScreenChildren.question,
1,
`Want to help RuneJS improve?\\nSend us a pull request over on Github!`,
'Want to help RuneJS improve?\\nSend us a pull request over on Github!',
);
this.outgoingPackets.updateWidgetString(
widgets.welcomeScreen,
13,
`You last logged in @red@${loginDaysStr}@bla@ from: @red@${this.lastAddress}`,
);
this.outgoingPackets.updateWidgetString(widgets.welcomeScreen, 16, `You have @yel@0 unread messages\\nin your message centre.`);
this.outgoingPackets.updateWidgetString(widgets.welcomeScreen, 16, 'You have @yel@0 unread messages\\nin your message centre.');
this.outgoingPackets.updateWidgetString(
widgets.welcomeScreen,
14,
Expand All @@ -259,7 +259,7 @@ export class Player extends Actor {
this.outgoingPackets.updateWidgetString(
widgets.welcomeScreen,
17,
`\\nYou do not have a Bank PIN.\\nPlease visit a bank if you would like one.`,
'\\nYou do not have a Bank PIN.\\nPlease visit a bank if you would like one.',
);
this.outgoingPackets.updateWidgetString(
widgets.welcomeScreen,
Expand Down Expand Up @@ -365,7 +365,7 @@ export class Player extends Actor {
}

public privateMessageReceived(fromPlayer: Player, messageBytes: number[]): void {
this.outgoingPackets.sendPrivateMessage(this.privateMessageIndex++, fromPlayer, messageBytes);
this.outgoingPackets.sendPrivateMessage(fromPlayer, messageBytes);
}

public addFriend(friendName: string): boolean {
Expand Down Expand Up @@ -418,9 +418,6 @@ export class Player extends Actor {
this.ignoreList.splice(index, 1);
return true;
}
public onNpcKill(npc: Npc) {
console.log('killed npc');
}
/**
* Should be fired whenever the player's chunk changes. This will fire off chunk updates for all chunks not
* already tracked by the player - all the new chunks that are coming into view.
Expand Down Expand Up @@ -711,7 +708,7 @@ export class Player extends Actor {
messages[i] = messages[i]?.trim() || '';
}

return await dialogue([this], [text => (messages as string[]).join(' ')]);
return await dialogue([this], [() => (messages as string[]).join(' ')]);
}

if (showInConsole) {
Expand Down Expand Up @@ -1122,7 +1119,7 @@ export class Player extends Actor {
}

if (!npc) {
logger.error(`NPC not found.`);
logger.error('NPC not found.');
return;
}

Expand Down Expand Up @@ -1166,7 +1163,7 @@ export class Player extends Actor {
if (event.slot !== undefined && event.item !== undefined) {
this.outgoingPackets.sendUpdateSingleWidgetItem(widgets.inventory, event.slot, event.item);
} else {
logger.error(`Inventory update event was missing slot or item.`, event);
logger.error('Inventory update event was missing slot or item.', event);
}
}
this.updateCarryWeight();
Expand Down
5 changes: 0 additions & 5 deletions src/engine/world/actor/player/private-messaging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ export enum PrivateChatMode {
}

export class PrivateMessaging {
public static friendAdded(player: Player, friendName: string): void {
friendName = friendName.toLowerCase();
const friend = activeWorld?.findPlayer(friendName);
}

public static friendRemoved(player: Player, friendName: string): void {
friendName = friendName.toLowerCase();
const playerPrivateChatMode = player.settings.privateChatMode;
Expand Down
Loading