Skip to content

Commit

Permalink
Turn on noUnusedParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
stwlam committed Mar 18, 2021
1 parent 79ef632 commit f1feb4a
Show file tree
Hide file tree
Showing 39 changed files with 323 additions and 486 deletions.
355 changes: 86 additions & 269 deletions .betterer.results

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion .betterer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default {
'stricter compilation': typescript('./tsconfig.json', {
strict: true,
noImplicitReturns: true,
noUnusedParameters: true,
}).include(
'./packs/scripts/*.ts',
'./packs/scripts/packman/*.ts',
Expand Down
15 changes: 6 additions & 9 deletions src/module/actor/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,12 @@ export class ActorPF2e extends Actor<ItemPF2e> {
}
}

/* -------------------------------------------- */

/**
* Apply rolled dice damage to the token or tokens which are currently controlled.
* This allows for damage to be scaled by a multiplier to account for healing, critical hits, or resistance
*
* @param {JQuery} roll The chat entry which contains the roll data
* @param {Number} multiplier A damage multiplier to apply to the rolled damage.
* @return {Promise}
* @param roll The chat entry which contains the roll data
* @param multiplier A damage multiplier to apply to the rolled damage.
*/
static async applyDamage(roll: JQuery, multiplier: number, attribute = 'attributes.hp', modifier = 0) {
if (canvas.tokens.controlled.length > 0) {
Expand Down Expand Up @@ -938,10 +935,10 @@ export class ActorPF2e extends Actor<ItemPF2e> {
/**
* Handle how changes to a Token attribute bar are applied to the Actor.
* This allows for game systems to override this behavior and deploy special logic.
* @param {string} attribute The attribute path
* @param {number} value The target attribute value
* @param {boolean} isDelta Whether the number represents a relative change (true) or an absolute change (false)
* @param {boolean} isBar Whether the new value is part of an attribute bar, or just a direct value
* @param attribute The attribute path
* @param value The target attribute value
* @param isDelta Whether the number represents a relative change (true) or an absolute change (false)
* @param isBar Whether the new value is part of an attribute bar, or just a direct value
*/
async modifyTokenAttribute(attribute: string, value: number, isDelta = false, isBar = true): Promise<this> {
if (value === undefined || value === null || Number.isNaN(value)) {
Expand Down
38 changes: 19 additions & 19 deletions src/module/actor/sheet/updated-npc-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { NPCSheetPF2e } from './npc';
import { DicePF2e } from '@scripts/dice';
import { ModifierPF2e, MODIFIER_TYPE } from '../../modifiers';
import { ActorPF2e } from '../base';
import { ItemPF2e } from '@item/base';

/**
* @category Other
Expand Down Expand Up @@ -256,7 +257,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
* If the creature has limits on how many times or how often it can use an ability
* (such as a spellcaster’s spells or a dragon’s Breath Weapon), in/decrease the damage by 4 instead.
*/
_applyAdjustmentToData(actorData, increase, adjustBackToNormal) {
_applyAdjustmentToData(actorData, increase: boolean, adjustBackToNormal: boolean) {
const positive = increase ? 1 : -1;
const mod = 2 * positive;

Expand Down Expand Up @@ -329,15 +330,15 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
}
}
} else if (item.type === 'action') {
let actionDescr = getProperty(item.data, 'description.value');
let actionDescr: string | undefined = getProperty(item.data, 'description.value');
if (actionDescr !== undefined) {
actionDescr = actionDescr.replace(/DC (\d+)+/g, (match, number) => {
actionDescr = actionDescr.replace(/DC (\d+)+/g, (_match, number) => {
return `DC ${parseInt(number, 10) + mod}`;
});
// Assuming that all abilities with damage in the description are damage attacks that cant be done each turn and as increase twice as much.
actionDescr = actionDescr.replace(
/(\d+)?d(\d+)([+-]\d+)?(\s+[a-z]+[\s.,])?/g,
(match, a, b, c, d) => {
(_match, a, b, c, d) => {
// match: '1d4+1 rounds.', a: 1, b: 4, c: '+1', d: ' rounds.'
const bonus = parseInt(c, 10);
if (d?.substring(1, 7) !== 'rounds') {
Expand Down Expand Up @@ -426,15 +427,14 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
* Toggle expansion of an attackEffect ability if it exists.
*
*/
expandAttackEffect(attackEffectName, event, triggerItem) {
expandAttackEffect(attackEffectName: string, event: JQuery.TriggeredEvent, triggerItem: ItemPF2e) {
const actionList = $(event.currentTarget).parents('form').find('.item.action-item');
let toggledAnything = false;
const mAbilities = CONFIG.PF2E.monsterAbilities();
console.log('PF2e System | mAbilities: ', mAbilities);
actionList.each((index, element) => {
actionList.each((_index, element) => {
// 'this' = element found
if ($(element).attr('data-item-name').trim().toLowerCase() === attackEffectName.trim().toLowerCase()) {
$(element).find('h4').click();
$(element).find('h4').trigger('click');
toggledAnything = true;
}
});
Expand All @@ -443,7 +443,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
if (newAbilityInfo) {
const newAction = {
name: attackEffectName,
type: 'action',
type: 'action' as const,
data: {
actionType: { value: newAbilityInfo.actionType },
actionCategory: { value: 'offensive' },
Expand All @@ -464,14 +464,14 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
}
}

triggerItem.actor.createOwnedItem(newAction, { displaySheet: false });
triggerItem.actor?.createOwnedItem(newAction, { displaySheet: false });
}
}
}

/* -------------------------------------------- */
/* Event Listeners and Handlers
/* -------------------------------------------- */
/* -------------------------------------------- */

/**
* Activate event listeners using the prepared sheet HTML
Expand All @@ -481,23 +481,23 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
super.activateListeners(html);
if (!this.options.editable) return;

html.find('.npc-detail-text textarea').focusout(async (event) => {
html.find('.npc-detail-text textarea').on('focusout', async (event) => {
event.target.style.height = '5px';
event.target.style.height = `${event.target.scrollHeight}px`;
});

html.find('.npc-detail-text textarea').each((index, element) => {
html.find('.npc-detail-text textarea').each((_index, element) => {
element.style.height = '5px';
element.style.height = `${element.scrollHeight}px`;
});

html.find<HTMLInputElement>('.isNPCEditable').change((ev) => {
this.actor.setFlag('pf2e', 'editNPC', { value: ev.target.checked });
html.find<HTMLInputElement>('.isNPCEditable').on('change', (event) => {
this.actor.setFlag('pf2e', 'editNPC', { value: event.target.checked });
});

// NPC Weapon Rolling

html.find('button.npc-damageroll').click((ev) => {
html.find('button.npc-damageroll').on('click', (ev) => {
ev.preventDefault();
ev.stopPropagation();

Expand All @@ -516,7 +516,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
}
});

html.find('button.npc-attackEffect').click((ev) => {
html.find('button.npc-attackEffect').on('click', (ev) => {
ev.preventDefault();
ev.stopPropagation();

Expand All @@ -541,7 +541,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
}
});

html.find('a.npc-elite-adjustment').click((e) => {
html.find('a.npc-elite-adjustment').on('click', (e) => {
e.preventDefault();
console.log(`PF2e System | Adding Elite adjustment to NPC`);
const eliteButton = $(e.currentTarget);
Expand All @@ -550,7 +550,7 @@ export class UpdatedNPCSheetPF2e extends NPCSheetPF2e {
weakButton.toggleClass('hidden');
this.npcAdjustment(eliteButton.hasClass('active'));
});
html.find('a.npc-weak-adjustment').click((e) => {
html.find('a.npc-weak-adjustment').on('click', (e) => {
e.preventDefault();
console.log(`PF2e System | Adding Weak adjustment to NPC`);
const weakButton = $(e.currentTarget);
Expand Down
2 changes: 1 addition & 1 deletion src/module/dc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ export function combineDCAdjustments(first: DCAdjustment, second: DCAdjustment):
*/
export function createDifficultyScale(dc: number, startAt: DCAdjustment): number[] {
const beginAtIndex = adjustmentScale.indexOf(startAt);
return adjustmentScale.filter((value, index) => index >= beginAtIndex).map((value) => adjustDC(dc, value));
return adjustmentScale.filter((_value, index) => index >= beginAtIndex).map((value) => adjustDC(dc, value));
}
2 changes: 1 addition & 1 deletion src/module/item/data-definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ export interface EffectDetailsData extends ItemDescriptionData {
};
start?: {
value: number;
initiative: number;
initiative: number | null;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/module/item/encumbrance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function calculateEncumbrance(
bonusBulkEncumbrance: number,
bonusBulkLimit: number,
combinedBulk: Bulk,
actorSize: Size = 'med',
_actorSize: Size = 'med',
): InventoryWeight {
const encumberedAt = Math.floor(strengthModifier + bonusBulkEncumbrance + 5);
const limit = Math.floor(strengthModifier + bonusBulkLimit + 10);
Expand Down
13 changes: 8 additions & 5 deletions src/module/item/runes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { isBlank, toNumber } from '../utils';
import { DamageDieSize } from '../system/damage/damage';
import { ArmorData, ArmorDetailsData, WeaponData, WeaponDetailsData } from './data-definitions';
import { PF2DiceModifier } from '../modifiers';
import { ConfigPF2e } from '@scripts/config';

type WeaponPropertyRuneType = keyof ConfigPF2e['PF2E']['weaponPropertyRunes'];

export function getPropertySlots(itemData: WeaponData | ArmorData): number {
let slots = 0;
Expand All @@ -15,12 +18,12 @@ export function getPropertySlots(itemData: WeaponData | ArmorData): number {
return slots;
}

export function getPropertyRunes(itemData: WeaponData | ArmorData, slots: number): string[] {
const runes = [];
export function getPropertyRunes(itemData: WeaponData | ArmorData, slots: number): WeaponPropertyRuneType[] {
const runes: WeaponPropertyRuneType[] = [];
type RuneIndex = 'propertyRune1' | 'propertyRune2' | 'propertyRune3' | 'propertyRune4';
for (let i = 1; i <= slots; i += 1) {
const rune = itemData.data[`propertyRune${i}` as RuneIndex]?.value;
if (!isBlank(rune)) {
const rune = itemData.data[`propertyRune${i}` as RuneIndex]?.value as WeaponPropertyRuneType | undefined;
if (rune && !isBlank(rune)) {
runes.push(rune);
}
}
Expand Down Expand Up @@ -65,7 +68,7 @@ interface RuneDiceModifier {
}

function toModifier(
rune,
rune: WeaponPropertyRuneType,
{ damageType = undefined, dieSize = 'd6', diceNumber = 1 }: RuneDiceModifier,
): PF2DiceModifier {
const traits = [];
Expand Down
2 changes: 1 addition & 1 deletion src/module/migrations/574-migrate-bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MigrationBase } from './base';

export class Migration574MigrateBulk extends MigrationBase {
static version = 0.574;
async updateItem(item: any, actor?: any) {
async updateItem(item: any) {
const itemName = item?.name?.trim();
if (['weapon', 'melee', 'armor', 'equipment', 'consumable', 'backpack'].includes(item.type)) {
// migrate stacked items
Expand Down
3 changes: 2 additions & 1 deletion src/module/migrations/578-migrate-item-image-paths.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { MigrationBase } from './base';
import { ItemDataPF2e } from '@item/data-definitions';

export class Migration578MigrateItemImagePaths extends MigrationBase {
static version = 0.578;
async updateItem(item: any, actor?: any) {
async updateItem(item: ItemDataPF2e) {
const itemImage = item.img;

// folder name change
Expand Down
2 changes: 1 addition & 1 deletion src/module/migrations/579-add-container-attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MigrationBase } from './base';

export class Migration579AddContainerAttributes extends MigrationBase {
static version = 0.579;
async updateItem(item: any, actor?: any) {
async updateItem(item: any) {
if (['weapon', 'melee', 'armor', 'equipment', 'consumable', 'backpack'].includes(item.type)) {
const itemName = item?.name?.trim();
if (itemName === 'Backpack') {
Expand Down
2 changes: 1 addition & 1 deletion src/module/migrations/580-add-item-rarity-and-level.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MigrationBase } from './base';

export class Migration580AddItemRarityAndLevel extends MigrationBase {
static version = 0.58;
async updateItem(item: any, actor?: any) {
async updateItem(item: any) {
item.data.rarity = { value: 'common' };

if (['treasure', 'backpack'].includes(item.type)) {
Expand Down
2 changes: 1 addition & 1 deletion src/module/migrations/583-add-hp-threshold-hardness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MigrationBase } from './base';

export class Migration583AddHpThresholdHardness extends MigrationBase {
static version = 0.583;
async updateItem(item: any, actor?: any) {
async updateItem(item: any) {
if (['weapon', 'melee', 'armor', 'equipment', 'consumable', 'backpack'].includes(item.type)) {
item.data.brokenThreshold = { value: 0 };
item.data.hp = { value: 0 };
Expand Down
2 changes: 1 addition & 1 deletion src/module/migrations/586-add-splash-damage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MigrationBase } from './base';

export class Migration586AddSplashDamage extends MigrationBase {
static version = 0.586;
async updateItem(item: any, actor?: any) {
async updateItem(item: any) {
if (['weapon', 'melee'].includes(item.type)) {
item.data.splashDamage = { value: '0' };
}
Expand Down
4 changes: 2 additions & 2 deletions src/module/migrations/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ export abstract class MigrationBase {
* Update the actor to the latest schema version.
* @param actor This should be effectively a `ActorDataPF2e` from the previous version.
*/
async updateActor(actor: any): Promise<void> {}
async updateActor(_actor: ActorDataPF2e): Promise<void> {}

/**
* Update the item to the latest schema version.
* @param item Item to update. This should be an `ItemData` from the previous version.
* @param actor If the item is part of an actor, this is set to the actor. For instance
* if you only want to update items that are on a npc you can do that here.
*/
async updateItem(item: ItemDataPF2e, actor?: ActorDataPF2e): Promise<void> {}
async updateItem(_item: ItemDataPF2e, _actor?: ActorDataPF2e): Promise<void> {}

/**
* Update the user to the latest schema version.
Expand Down
21 changes: 10 additions & 11 deletions src/module/packs/compendium-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ class CompendiumBrowser extends Application {
}

hookCompendiumList() {
Hooks.on('renderCompendiumDirectory', (app, html, data) => {
Hooks.on('renderCompendiumDirectory', (_app, html) => {
if (html.find('.compendium-browser-btn').length) {
console.error('Compendium Browser - Already hooked');
return;
Expand All @@ -805,13 +805,13 @@ class CompendiumBrowser extends Application {
target.append(importButton);

// Handle button clicks
importButton.click((ev) => {
importButton.on('click', (ev) => {
ev.preventDefault();
this.render(true);
});
});

Hooks.on('renderActorDirectory', (app, html, data) => {
Hooks.on('renderActorDirectory', (_app, html) => {
if (html.find('.bestiary-browser-btn').length) {
console.error('Compendium Browser - Already hooked');
return;
Expand All @@ -827,15 +827,15 @@ class CompendiumBrowser extends Application {
}

// Handle button clicks
bestiaryImportButton.click((ev) => {
bestiaryImportButton.on('click', (ev) => {
ev.preventDefault();
this.openTab('bestiary');
});
});
}

clearObject(obj) {
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => value));
clearObject(obj: object) {
return Object.fromEntries(Object.entries(obj).filter(([_key, value]) => value));
}

_getActionImg(action) {
Expand Down Expand Up @@ -863,7 +863,7 @@ class CompendiumBrowser extends Application {
);
}

async filterSpells(li) {
async filterSpells(li: JQuery) {
let counter = 0;
li.hide();
for (const spell of li) {
Expand All @@ -879,7 +879,7 @@ class CompendiumBrowser extends Application {
}
}

getFilterResult(element) {
getFilterResult(element: HTMLElement) {
if (this.sorters.text !== '') {
const searches = this.sorters.text.split(',');
for (const search of searches) {
Expand Down Expand Up @@ -926,13 +926,13 @@ class CompendiumBrowser extends Application {
return this.isWithinFilteredBounds(element);
}

isWithinFilteredBounds(element): boolean {
isWithinFilteredBounds(element: HTMLElement): boolean {
const rangeIdentifiers = Object.keys(this.ranges);

for (const range of rangeIdentifiers) {
const lowerBound = this.ranges[range].lowerBound;
const upperBound = this.ranges[range].upperBound;
const filter = +element.dataset[range];
const filter = Number(element.dataset[range] ?? 0);

if (filter < lowerBound || upperBound < filter) {
return false;
Expand Down Expand Up @@ -1001,4 +1001,3 @@ class CompendiumBrowser extends Application {
}

export const compendiumBrowser = new CompendiumBrowser();
// vim: ts=2 sw=2 et
Loading

0 comments on commit f1feb4a

Please sign in to comment.