add eslint and prettier

This commit is contained in:
Johannes Loher 2020-12-23 18:23:26 +01:00
parent 618146226b
commit 2ba687eb14
10 changed files with 775 additions and 37 deletions

View file

@ -0,0 +1,2 @@
// TODO: Actually add a type for data
export type DS4ItemDataType = unknown;

View file

@ -1,10 +1,14 @@
import { DS4ActorDataType } from "../actor/actor-data";
import { DS4Item } from "./item";
import { DS4ItemDataType } from "./item-data";
/**
* Extend the basic ItemSheet with some very simple modifications
* @extends {ItemSheet}
*/
export class DS4ItemSheet extends ItemSheet {
export class DS4ItemSheet extends ItemSheet<DS4ActorDataType, DS4Item> {
/** @override */
static get defaultOptions() {
static get defaultOptions(): FormApplicationOptions {
return mergeObject(super.defaultOptions, {
width: 530,
height: 400,
@ -14,7 +18,7 @@ export class DS4ItemSheet extends ItemSheet {
}
/** @override */
get template() {
get template(): string {
const path = "systems/ds4/templates/item";
return `${path}/${this.item.data.type}-sheet.hbs`;
}
@ -22,7 +26,7 @@ export class DS4ItemSheet extends ItemSheet {
/* -------------------------------------------- */
/** @override */
getData() {
getData(): ItemSheetData<DS4ItemDataType> {
const data = { ...super.getData(), config: CONFIG.DS4 };
console.log(data);
return data;
@ -31,7 +35,7 @@ export class DS4ItemSheet extends ItemSheet {
/* -------------------------------------------- */
/** @override */
setPosition(options = {}) {
setPosition(options = {}): unknown {
const position = super.setPosition(options);
const sheetBody = (this.element as JQuery).find(".sheet-body"); // TODO: Why is the cast necessary?
const bodyHeight = position.height - 192;
@ -42,7 +46,7 @@ export class DS4ItemSheet extends ItemSheet {
/* -------------------------------------------- */
/** @override */
activateListeners(html) {
activateListeners(html: JQuery): void {
super.activateListeners(html);
if (!this.options.editable) return;
@ -52,7 +56,7 @@ export class DS4ItemSheet extends ItemSheet {
html.find(".effect-edit").click((ev) => {
const li = $(ev.currentTarget).parents(".effect");
console.log(li.data("effectId"));
const effect = this.item.effects.get(li.data("effectId"));
const effect = this.item["effects"].get(li.data("effectId")); // TODO: replace ["..."]
effect.sheet.render(true);
});
@ -67,7 +71,7 @@ export class DS4ItemSheet extends ItemSheet {
* @param {Event} event The originating click event
* @private
*/
async _onEffectCreate(event) {
async _onEffectCreate(event: JQuery.ClickEvent): Promise<unknown> {
event.preventDefault();
const label = `New Effect`;

View file

@ -1,17 +1,19 @@
import { DS4ItemDataType } from "./item-data";
/**
* Extend the basic Item with some very simple modifications.
* @extends {Item}
*/
export class DS4Item extends Item {
export class DS4Item extends Item<DS4ItemDataType> {
/**
* Augment the basic Item data model with additional dynamic data.
*/
prepareData() {
prepareData(): void {
super.prepareData();
// Get the Item's data
const itemData = this.data;
const actorData = this.actor ? this.actor.data : {};
const data = itemData.data;
// const itemData = this.data;
// const actorData = this.actor ? this.actor.data : {};
// const data = itemData.data;
}
}