refactor: prefer type imports and sort imports

This commit is contained in:
Johannes Loher 2022-02-17 00:55:22 +01:00
parent 8d2cff77d7
commit 9cffa4df04
49 changed files with 124 additions and 105 deletions

View file

@ -6,5 +6,11 @@
"eslint.nodePath": ".yarn/sdks",
"prettier.prettierPath": ".yarn/sdks/prettier/index.js",
"typescript.tsdk": ".yarn/sdks/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
"typescript.enablePromptUseWorkspaceTsdk": true,
"importSorter.generalConfiguration.sortOnBeforeSave": true,
"importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.type": "newLineEachExpressionAfterCountLimitExceptIfOnlyOne",
"importSorter.importStringConfiguration.maximumNumberOfImportExpressionsPerLine.count": 120,
"importSorter.importStringConfiguration.tabSize": 4,
"importSorter.importStringConfiguration.quoteMark": "double",
"importSorter.importStringConfiguration.trailingComma": "multiLine"
}

View file

@ -2,9 +2,10 @@
//
// SPDX-License-Identifier: MIT
import { CooldownDuration, DS4SpellDataSourceData } from "../../../src/item/spell/spell-data-source";
import { calculateSpellPrice } from "../../../src/item/spell/calculate-spell-price";
import type { CooldownDuration, DS4SpellDataSourceData } from "../../../src/item/spell/spell-data-source";
const defaultData: DS4SpellDataSourceData = {
description: "",
equipped: false,

View file

@ -4,7 +4,8 @@
import { DS4Actor } from "./actor/actor";
import { getGame } from "./helpers";
import { DS4Item } from "./item/item";
import type { DS4Item } from "./item/item";
declare global {
interface DocumentClassConfig {

View file

@ -5,9 +5,10 @@
//
// SPDX-License-Identifier: MIT
import { ModifiableDataBaseTotal, ResourceDataBaseTotalMax } from "../common/common-data";
import { DS4 } from "../config";
import type { ModifiableDataBaseTotal, ResourceDataBaseTotalMax } from "../common/common-data";
export interface DS4ActorDataPropertiesDataBase {
attributes: DS4ActorDataPropertiesDataAttributes;
traits: DS4ActorDataPropertiesDataTraits;

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4CharacterDataProperties } from "./character/character-data-properties";
import { DS4CreatureDataProperties } from "./creature/creature-data-properties";
import type { DS4CharacterDataProperties } from "./character/character-data-properties";
import type { DS4CreatureDataProperties } from "./creature/creature-data-properties";
declare global {
interface DataConfig {

View file

@ -5,9 +5,10 @@
//
// SPDX-License-Identifier: MIT
import { ModifiableData, ModifiableDataBase, ResourceData } from "../common/common-data";
import { DS4 } from "../config";
import type { ModifiableData, ModifiableDataBase, ResourceData } from "../common/common-data";
export interface DS4ActorDataSourceDataBase {
attributes: DS4ActorDataSourceDataAttributes;
traits: DS4ActorDataSourceDataTraits;

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4CharacterDataSource } from "./character/character-data-source";
import { DS4CreatureDataSource } from "./creature/creature-data-source";
import type { DS4CharacterDataSource } from "./character/character-data-source";
import type { DS4CreatureDataSource } from "./creature/creature-data-source";
declare global {
interface SourceConfig {

View file

@ -6,15 +6,17 @@
// SPDX-License-Identifier: MIT
import { DS4ActiveEffect } from "../active-effect";
import { ModifiableDataBaseTotal } from "../common/common-data";
import { DS4 } from "../config";
import { getCanvas, getGame } from "../helpers";
import { DS4Settings, getDS4Settings } from "../settings";
import { getDS4Settings } from "../settings";
import notifications from "../ui/notifications";
import { enforce } from "../utils";
import { isCheck } from "./actor-data-properties-base";
import type { ModifiableDataBaseTotal } from "../common/common-data";
import type { DS4Settings } from "../settings";
import type { DS4Item } from "../item/item";
/**
* The base sheet class for all {@link DS4Actor}s.
*/

View file

@ -3,17 +3,18 @@
//
// SPDX-License-Identifier: MIT
import { ModifiableDataBaseTotal } from "../common/common-data";
import { DS4 } from "../config";
import { getGame } from "../helpers";
import { DS4ArmorDataProperties } from "../item/armor/armor-data-properties";
import { DS4Item } from "../item/item";
import { ItemType } from "../item/item-data-source";
import { DS4ShieldDataProperties } from "../item/shield/shield-data-properties";
import { createCheckRoll } from "../rolls/check-factory";
import { Check } from "./actor-data-properties-base";
import { isAttribute, isTrait } from "./actor-data-source-base";
import type { ModifiableDataBaseTotal } from "../common/common-data";
import type { DS4ArmorDataProperties } from "../item/armor/armor-data-properties";
import type { DS4Item } from "../item/item";
import type { ItemType } from "../item/item-data-source";
import type { DS4ShieldDataProperties } from "../item/shield/shield-data-properties";
import type { Check } from "./actor-data-properties-base";
declare global {
interface DocumentClassConfig {
Actor: typeof DS4Actor;

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ActorDataPropertiesDataBase } from "../actor-data-properties-base";
import {
import type { DS4ActorDataPropertiesDataBase } from "../actor-data-properties-base";
import type {
DS4CharacterDataSourceDataBaseInfo,
DS4CharacterDataSourceDataCurrency,
DS4CharacterDataSourceDataProfile,

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { UsableResource } from "../../common/common-data";
import { DS4ActorDataSourceDataBase } from "../actor-data-source-base";
import type { UsableResource } from "../../common/common-data";
import type { DS4ActorDataSourceDataBase } from "../actor-data-source-base";
export interface DS4CharacterDataSource {
type: "character";

View file

@ -2,9 +2,10 @@
//
// SPDX-License-Identifier: MIT
import { ItemType } from "../../item/item-data-source";
import { DS4Actor } from "../actor";
import type { ItemType } from "../../item/item-data-source";
export class DS4Character extends DS4Actor {
/** @override */
prepareFinalDerivedData(): void {

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ActorDataPropertiesDataBase } from "../actor-data-properties-base";
import { DS4CreatureDataSourceDataBaseInfo } from "./creature-data-source";
import type { DS4ActorDataPropertiesDataBase } from "../actor-data-properties-base";
import type { DS4CreatureDataSourceDataBaseInfo } from "./creature-data-source";
export interface DS4CreatureDataProperties {
type: "creature";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4 } from "../../config";
import { DS4ActorDataSourceDataBase } from "../actor-data-source-base";
import type { DS4 } from "../../config";
import type { DS4ActorDataSourceDataBase } from "../actor-data-source-base";
export interface DS4CreatureDataSource {
type: "creature";

View file

@ -2,9 +2,10 @@
//
// SPDX-License-Identifier: MIT
import { ItemType } from "../../item/item-data-source";
import { DS4Actor } from "../actor";
import type { ItemType } from "../../item/item-data-source";
export class DS4Creature extends DS4Actor {
/** @override */
get ownableItemTypes(): Array<ItemType> {

View file

@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT
import "../scss/ds4.scss";
import registerForHooks from "./hooks/hooks";
registerForHooks();

View file

@ -5,18 +5,17 @@
// SPDX-License-Identifier: MIT
import { DS4ActiveEffect } from "../active-effect";
import { DS4Actor } from "../actor/actor";
import { DS4ActorProxy } from "../actor/proxy";
import { DS4CharacterActorSheet } from "../actor/character/character-sheet";
import { DS4CreatureActorSheet } from "../actor/creature/creature-sheet";
import { DS4ActorProxy } from "../actor/proxy";
import { DS4ChatMessage } from "../chat-message";
import { DS4 } from "../config";
import { preloadFonts as preloadFonts } from "../fonts";
import { preloadFonts } from "../fonts";
import registerHandlebarsHelpers from "../handlebars/handlebars-helpers";
import registerHandlebarsPartials from "../handlebars/handlebars-partials";
import { getGame } from "../helpers";
import { DS4Item } from "../item/item";
import { DS4ItemSheet } from "../item/item-sheet";
import { DS4ItemProxy } from "../item/proxy";
import logger from "../logger";
import { macros } from "../macros/macros";
import { migration } from "../migrations";
@ -26,7 +25,9 @@ import { DS4Roll } from "../rolls/roll";
import registerSlayingDiceModifier from "../rolls/slaying-dice-modifier";
import { registerSystemSettings } from "../settings";
import { DS4TokenDocument } from "../token-document";
import { DS4ItemProxy } from "../item/proxy";
import type { DS4Actor } from "../actor/actor";
import type { DS4Item } from "../item/item";
export default function registerForInitHook(): void {
Hooks.once("init", init);

View file

@ -20,9 +20,7 @@ export default function registerForRenderHooks(): void {
* @param html - The {@link JQuery} representing the HTML of the application.
*/
function selectTargetInputOnFocus(app: Application, html: JQuery) {
$(html)
.find("input")
.on("focus", (ev: JQuery.FocusEvent<HTMLInputElement>) => {
ev.currentTarget.select();
});
html.find("input").on("focus", (ev: JQuery.FocusEvent<HTMLInputElement>) => {
ev.currentTarget.select();
});
}

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4AlphabetDataSourceData } from "./alphabet-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4AlphabetDataSourceData } from "./alphabet-data-source";
export interface DS4AlphabetDataProperties {
type: "alphabet";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataSourceDataBase } from "../item-data-source-base";
import type { DS4ItemDataSourceDataBase } from "../item-data-source-base";
export interface DS4AlphabetDataSource {
type: "alphabet";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4ArmorDataSourceData } from "./armor-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4ArmorDataSourceData } from "./armor-data-source";
export interface DS4ArmorDataProperties {
type: "armor";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4 } from "../../config";
import {
import type { DS4 } from "../../config";
import type {
DS4ItemDataSourceDataBase,
DS4ItemDataSourceDataEquipable,
DS4ItemDataSourceDataPhysical,

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4EquipmentDataSourceData } from "./equipment-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4EquipmentDataSourceData } from "./equipment-data-source";
export interface DS4EquipmentDataProperties {
type: "equipment";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import {
import type {
DS4ItemDataSourceDataBase,
DS4ItemDataSourceDataEquipable,
DS4ItemDataSourceDataPhysical,

View file

@ -2,17 +2,17 @@
//
// SPDX-License-Identifier: MIT
import { DS4AlphabetDataProperties } from "./alphabet/alphabet-data-properties";
import { DS4ArmorDataProperties } from "./armor/armor-data-properties";
import { DS4EquipmentDataProperties } from "./equipment/equipment-data-properties";
import { DS4LanguageDataProperties } from "./language/language-data-properties";
import { DS4LootDataProperties } from "./loot/loot-data-properties";
import { DS4RacialAbilityDataProperties } from "./racial-ability/racial-ability-data-properties";
import { DS4ShieldDataProperties } from "./shield/shield-data-properties";
import { DS4SpecialCreatureAbilityDataProperties } from "./special-creature-ability/special-creature-ability-data-properties";
import { DS4SpellDataProperties } from "./spell/spell-data-properties";
import { DS4TalentDataProperties } from "./talent/talent-data-properties";
import { DS4WeaponDataProperties } from "./weapon/weapon-data-properties";
import type { DS4AlphabetDataProperties } from "./alphabet/alphabet-data-properties";
import type { DS4ArmorDataProperties } from "./armor/armor-data-properties";
import type { DS4EquipmentDataProperties } from "./equipment/equipment-data-properties";
import type { DS4LanguageDataProperties } from "./language/language-data-properties";
import type { DS4LootDataProperties } from "./loot/loot-data-properties";
import type { DS4RacialAbilityDataProperties } from "./racial-ability/racial-ability-data-properties";
import type { DS4ShieldDataProperties } from "./shield/shield-data-properties";
import type { DS4SpecialCreatureAbilityDataProperties } from "./special-creature-ability/special-creature-ability-data-properties";
import type { DS4SpellDataProperties } from "./spell/spell-data-properties";
import type { DS4TalentDataProperties } from "./talent/talent-data-properties";
import type { DS4WeaponDataProperties } from "./weapon/weapon-data-properties";
declare global {
interface DataConfig {

View file

@ -4,7 +4,7 @@
//
// SPDX-License-Identifier: MIT
import { DS4 } from "../config";
import type { DS4 } from "../config";
export interface DS4ItemDataSourceDataBase {
description: string;

View file

@ -2,18 +2,18 @@
//
// SPDX-License-Identifier: MIT
import { DS4 } from "../config";
import { DS4AlphabetDataSource } from "./alphabet/alphabet-data-source";
import { DS4ArmorDataSource } from "./armor/armor-data-source";
import { DS4EquipmentDataSource } from "./equipment/equipment-data-source";
import { DS4LanguageDataSource } from "./language/language-data-source";
import { DS4LootDataSource } from "./loot/loot-data-source";
import { DS4RacialAbilityDataSource } from "./racial-ability/racial-ability-data-source";
import { DS4ShieldDataSource } from "./shield/shield-data-source";
import { DS4SpecialCreatureAbilityDataSource } from "./special-creature-ability/special-creature-ability-data-source";
import { DS4SpellDataSource } from "./spell/spell-data-source";
import { DS4TalentDataSource } from "./talent/talent-data-source";
import { DS4WeaponDataSource } from "./weapon/weapon-data-source";
import type { DS4 } from "../config";
import type { DS4AlphabetDataSource } from "./alphabet/alphabet-data-source";
import type { DS4ArmorDataSource } from "./armor/armor-data-source";
import type { DS4EquipmentDataSource } from "./equipment/equipment-data-source";
import type { DS4LanguageDataSource } from "./language/language-data-source";
import type { DS4LootDataSource } from "./loot/loot-data-source";
import type { DS4RacialAbilityDataSource } from "./racial-ability/racial-ability-data-source";
import type { DS4ShieldDataSource } from "./shield/shield-data-source";
import type { DS4SpecialCreatureAbilityDataSource } from "./special-creature-ability/special-creature-ability-data-source";
import type { DS4SpellDataSource } from "./spell/spell-data-source";
import type { DS4TalentDataSource } from "./talent/talent-data-source";
import type { DS4WeaponDataSource } from "./weapon/weapon-data-source";
declare global {
interface SourceConfig {

View file

@ -4,7 +4,8 @@
// SPDX-License-Identifier: MIT
import { getGame } from "../helpers";
import { ItemType } from "./item-data-source";
import type { ItemType } from "./item-data-source";
declare global {
interface DocumentClassConfig {

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4LanguageDataSourceData } from "./language-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4LanguageDataSourceData } from "./language-data-source";
export interface DS4LanguageDataProperties {
type: "language";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataSourceDataBase } from "../item-data-source-base";
import type { DS4ItemDataSourceDataBase } from "../item-data-source-base";
export interface DS4LanguageDataSource {
type: "language";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4LootDataSourceData } from "./loot-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4LootDataSourceData } from "./loot-data-source";
export interface DS4LootDataProperties {
type: "loot";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataSourceDataBase, DS4ItemDataSourceDataPhysical } from "../item-data-source-base";
import type { DS4ItemDataSourceDataBase, DS4ItemDataSourceDataPhysical } from "../item-data-source-base";
export interface DS4LootDataSource {
type: "loot";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4RacialAbilityDataSourceData } from "./racial-ability-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4RacialAbilityDataSourceData } from "./racial-ability-data-source";
export interface DS4RacialAbilityDataProperties {
type: "racialAbility";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataSourceDataBase } from "../item-data-source-base";
import type { DS4ItemDataSourceDataBase } from "../item-data-source-base";
export interface DS4RacialAbilityDataSource {
type: "racialAbility";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4ShieldDataSourceData } from "./shield-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4ShieldDataSourceData } from "./shield-data-source";
export interface DS4ShieldDataProperties {
type: "shield";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import {
import type {
DS4ItemDataSourceDataBase,
DS4ItemDataSourceDataEquipable,
DS4ItemDataSourceDataPhysical,

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4SpecialCreatureAbilityDataSourceData } from "./special-creature-ability-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4SpecialCreatureAbilityDataSourceData } from "./special-creature-ability-data-source";
export interface DS4SpecialCreatureAbilityDataProperties {
type: "specialCreatureAbility";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataSourceDataBase } from "../item-data-source-base";
import type { DS4ItemDataSourceDataBase } from "../item-data-source-base";
export interface DS4SpecialCreatureAbilityDataSource {
type: "specialCreatureAbility";

View file

@ -2,7 +2,7 @@
//
// SPDX-License-Identifier: MIT
import { CooldownDuration, DS4SpellDataSourceData } from "./spell-data-source";
import type { CooldownDuration, DS4SpellDataSourceData } from "./spell-data-source";
export function calculateSpellPrice(data: DS4SpellDataSourceData): number | null {
const spellPriceFactor = calculateSpellPriceFactor(data.cooldownDuration);

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4SpellDataSourceData } from "./spell-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4SpellDataSourceData } from "./spell-data-source";
export interface DS4SpellDataProperties {
type: "spell";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4 } from "../../config";
import { DS4ItemDataSourceDataBase, DS4ItemDataSourceDataEquipable } from "../item-data-source-base";
import type { DS4 } from "../../config";
import type { DS4ItemDataSourceDataBase, DS4ItemDataSourceDataEquipable } from "../item-data-source-base";
export interface DS4SpellDataSource {
type: "spell";

View file

@ -2,9 +2,9 @@
//
// SPDX-License-Identifier: MIT
import { ModifiableDataBaseTotalMax } from "../../common/common-data";
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4TalentDataSourceData } from "./talent-data-source";
import type { ModifiableDataBaseTotalMax } from "../../common/common-data";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4TalentDataSourceData } from "./talent-data-source";
export interface DS4TalentDataProperties {
type: "talent";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { ModifiableDataBaseMax } from "../../common/common-data";
import { DS4ItemDataSourceDataBase } from "../item-data-source-base";
import type { ModifiableDataBaseMax } from "../../common/common-data";
import type { DS4ItemDataSourceDataBase } from "../item-data-source-base";
export interface DS4TalentDataSource {
type: "talent";

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import { DS4WeaponDataSourceData } from "./weapon-data-source";
import type { DS4ItemDataPropertiesDataRollable } from "../item-data-properties-base";
import type { DS4WeaponDataSourceData } from "./weapon-data-source";
interface DS4WeaponDataPropertiesData extends DS4WeaponDataSourceData, DS4ItemDataPropertiesDataRollable {}

View file

@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: MIT
import { DS4 } from "../../config";
import {
import type { DS4 } from "../../config";
import type {
DS4ItemDataSourceDataBase,
DS4ItemDataSourceDataEquipable,
DS4ItemDataSourceDataPhysical,

View file

@ -7,7 +7,8 @@ import { getGame } from "../../helpers";
import { createCheckRoll } from "../../rolls/check-factory";
import notifications from "../../ui/notifications";
import { DS4Item } from "../item";
import { AttackType } from "./weapon-data-source";
import type { AttackType } from "./weapon-data-source";
export class DS4Weapon extends DS4Item {
/** @override */

View file

@ -2,9 +2,10 @@
//
// SPDX-License-Identifier: MIT
import { DS4Actor } from "../actor/actor";
import { getCanvas, getGame } from "../helpers";
import type { DS4Actor } from "../actor/actor";
/**
* Gets the currently active actor and token based on how {@link ChatMessage}
* determines the current speaker.

View file

@ -2,12 +2,12 @@
//
// SPDX-License-Identifier: MIT
import { Check } from "../actor/actor-data-properties-base";
import { DS4 } from "../config";
import { getGame } from "../helpers";
import notifications from "../ui/notifications";
import { getActiveActorAndToken } from "./helpers";
import type { Check } from "../actor/actor-data-properties-base";
/**
* Creates a macro from a check drop.
* Get an existing roll check macro if one exists, otherwise create a new one.

View file

@ -8,7 +8,8 @@
"forceConsistentCasingInFileNames": true,
"strict": true,
"noUncheckedIndexedAccess": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"importsNotUsedAsValues": "error"
},
"include": ["src"]
}