Skip to content
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

build: enable consistent type imports rule #24

Closed
wants to merge 2 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ module.exports = {
plugins: ['@deities'],
rules: {
'@typescript-eslint/array-type': [2, { default: 'generic' }],
'@typescript-eslint/consistent-type-imports': [
'error',
{
disallowTypeAnnotations: false,
fixStyle: 'separate-type-imports',
prefer: 'type-imports',
},
],
'@typescript-eslint/no-restricted-imports': [
2,
{
Expand Down
26 changes: 12 additions & 14 deletions apollo/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Skill,
} from '@deities/athena/info/Skill.tsx';
import { Lightning } from '@deities/athena/info/Tile.tsx';
import { Ability, getUnitInfo, Weapon } from '@deities/athena/info/Unit.tsx';
import type { Weapon } from '@deities/athena/info/Unit.tsx';
import { Ability, getUnitInfo } from '@deities/athena/info/Unit.tsx';
import { getDeterministicUnitName } from '@deities/athena/info/UnitNames.tsx';
import calculateDamage from '@deities/athena/lib/calculateDamage.tsx';
import calculateFunds from '@deities/athena/lib/calculateFunds.tsx';
Expand All @@ -25,7 +26,7 @@ import getRescuableVectors from '@deities/athena/lib/getRescuableVectors.tsx';
import getSabotageableVectors from '@deities/athena/lib/getSabotageableVectors.tsx';
import getUnitsToRefill from '@deities/athena/lib/getUnitsToRefill.tsx';
import { AIBehavior } from '@deities/athena/map/AIBehavior.tsx';
import Building from '@deities/athena/map/Building.tsx';
import type Building from '@deities/athena/map/Building.tsx';
import {
BuildingCover,
Charge,
Expand All @@ -34,19 +35,16 @@ import {
MinDamage,
RaisedCounterAttack,
} from '@deities/athena/map/Configuration.tsx';
import {
DynamicPlayerID,
PlayerID,
resolveDynamicPlayerID,
} from '@deities/athena/map/Player.tsx';
import { Teams } from '@deities/athena/map/Team.tsx';
import Unit from '@deities/athena/map/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import MapData from '@deities/athena/MapData.tsx';
import type { DynamicPlayerID, PlayerID } from '@deities/athena/map/Player.tsx';
import { resolveDynamicPlayerID } from '@deities/athena/map/Player.tsx';
import type { Teams } from '@deities/athena/map/Team.tsx';
import type Unit from '@deities/athena/map/Unit.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import { getPathCost, moveable } from '@deities/athena/Radius.tsx';
import { VisionT } from '@deities/athena/Vision.tsx';
import ImmutableMap from '@nkzw/immutable-map';
import { ActionResponse } from './ActionResponse.tsx';
import type { VisionT } from '@deities/athena/Vision.tsx';
import type ImmutableMap from '@nkzw/immutable-map';
import type { ActionResponse } from './ActionResponse.tsx';
import applyActionResponse from './actions/applyActionResponse.tsx';

export type MutateActionResponseFn = (action: ActionResponse) => ActionResponse;
Expand Down
23 changes: 12 additions & 11 deletions apollo/ActionResponse.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Skill } from '@deities/athena/info/Skill.tsx';
import Building from '@deities/athena/map/Building.tsx';
import { DynamicPlayerID, PlayerID } from '@deities/athena/map/Player.tsx';
import { Reward } from '@deities/athena/map/Reward.tsx';
import { Teams } from '@deities/athena/map/Team.tsx';
import Unit, { DryUnit } from '@deities/athena/map/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import { WinCondition } from '@deities/athena/WinConditions.tsx';
import ImmutableMap from '@nkzw/immutable-map';
import { GameOverActionResponses } from './GameOver.tsx';
import { HiddenActionResponse } from './HiddenAction.tsx';
import type { Skill } from '@deities/athena/info/Skill.tsx';
import type Building from '@deities/athena/map/Building.tsx';
import type { DynamicPlayerID, PlayerID } from '@deities/athena/map/Player.tsx';
import type { Reward } from '@deities/athena/map/Reward.tsx';
import type { Teams } from '@deities/athena/map/Team.tsx';
import type { DryUnit } from '@deities/athena/map/Unit.tsx';
import type Unit from '@deities/athena/map/Unit.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type { WinCondition } from '@deities/athena/WinConditions.tsx';
import type ImmutableMap from '@nkzw/immutable-map';
import type { GameOverActionResponses } from './GameOver.tsx';
import type { HiddenActionResponse } from './HiddenAction.tsx';

export type MoveActionResponse = Readonly<{
completed?: boolean;
Expand Down
5 changes: 3 additions & 2 deletions apollo/CharacterMessage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getUnitInfoOrThrow, UnitInfo } from '@deities/athena/info/Unit.tsx';
import { DynamicPlayerID } from '@deities/athena/map/Player.tsx';
import type { UnitInfo } from '@deities/athena/info/Unit.tsx';
import { getUnitInfoOrThrow } from '@deities/athena/info/Unit.tsx';
import type { DynamicPlayerID } from '@deities/athena/map/Player.tsx';

export default function CharacterMessage(
unit: UnitInfo | number,
Expand Down
6 changes: 3 additions & 3 deletions apollo/Condition.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getUnitInfo } from '@deities/athena/info/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import MapData from '@deities/athena/MapData.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import { WinCriteria } from '@deities/athena/WinConditions.tsx';
import UnknownTypeError from '@deities/hephaestus/UnknownTypeError.tsx';
import { ActionResponse } from './ActionResponse.tsx';
import type { ActionResponse } from './ActionResponse.tsx';
import transformEffectValue from './lib/transformEffectValue.tsx';

export type WinConditionID = 'win' | 'lose' | 'draw' | number;
Expand Down
31 changes: 14 additions & 17 deletions apollo/Effects.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
import {
PlayerIDs,
PlayerIDSet,
toPlayerIDs,
} from '@deities/athena/map/Player.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { Actions, executeEffect } from './Action.tsx';
import { ActionResponse, ActionResponseType } from './ActionResponse.tsx';
import type { PlayerIDs, PlayerIDSet } from '@deities/athena/map/Player.tsx';
import { toPlayerIDs } from '@deities/athena/map/Player.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { Actions } from './Action.tsx';
import { executeEffect } from './Action.tsx';
import type { ActionResponse, ActionResponseType } from './ActionResponse.tsx';
import validateAction from './actions/validateAction.tsx';
import {
Conditions,
evaluateCondition,
validateCondition,
} from './Condition.tsx';
import type { Conditions } from './Condition.tsx';
import { evaluateCondition, validateCondition } from './Condition.tsx';
import type {
EncodedActionResponseType,
EncodedActions,
EncodedConditions,
} from './EncodedActions.tsx';
import {
decodeActionID,
decodeActions,
decodeCondition,
encodeActionID,
encodeActions,
encodeCondition,
EncodedActionResponseType,
EncodedActions,
EncodedConditions,
} from './EncodedActions.tsx';
import transformEffectValue from './lib/transformEffectValue.tsx';
import { GameStateWithEffects } from './Types.tsx';
import type { GameStateWithEffects } from './Types.tsx';

export type Effect = Readonly<{
actions: Actions;
Expand Down
15 changes: 7 additions & 8 deletions apollo/GameOver.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import matchesPlayerList from '@deities/athena/lib/matchesPlayerList.tsx';
import { AllowedMisses } from '@deities/athena/map/Configuration.tsx';
import type Player from '@deities/athena/map/Player.tsx';
import {
PlayerID,
resolveDynamicPlayerID,
} from '@deities/athena/map/Player.tsx';
import MapData from '@deities/athena/MapData.tsx';
import type { PlayerID } from '@deities/athena/map/Player.tsx';
import { resolveDynamicPlayerID } from '@deities/athena/map/Player.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import Vision from '@deities/athena/Vision.tsx';
import { WinCondition, WinCriteria } from '@deities/athena/WinConditions.tsx';
import type { WinCondition } from '@deities/athena/WinConditions.tsx';
import { WinCriteria } from '@deities/athena/WinConditions.tsx';
import UnknownTypeError from '@deities/hephaestus/UnknownTypeError.tsx';
import { EndTurnAction } from './action-mutators/ActionMutators.tsx';
import { execute } from './Action.tsx';
import {
import type {
ActionResponse,
AttackBuildingActionResponse,
AttackUnitActionResponse,
Expand All @@ -22,7 +21,7 @@ import checkWinConditions, {
shouldCheckDefaultWinConditions,
} from './lib/checkWinCondition.tsx';
import { processRewards } from './lib/processRewards.tsx';
import { GameState, MutableGameState } from './Types.tsx';
import type { GameState, MutableGameState } from './Types.tsx';

export type AttackUnitGameOverActionResponse = Readonly<{
fromPlayer: PlayerID;
Expand Down
15 changes: 8 additions & 7 deletions apollo/HiddenAction.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import updatePlayer from '@deities/athena/lib/updatePlayer.tsx';
import Building from '@deities/athena/map/Building.tsx';
import { PlayerID } from '@deities/athena/map/Player.tsx';
import Unit, { DryUnit } from '@deities/athena/map/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { VisionT } from '@deities/athena/Vision.tsx';
import { AttackDirection } from './attack-direction/getAttackDirection.tsx';
import type Building from '@deities/athena/map/Building.tsx';
import type { PlayerID } from '@deities/athena/map/Player.tsx';
import type { DryUnit } from '@deities/athena/map/Unit.tsx';
import type Unit from '@deities/athena/map/Unit.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { VisionT } from '@deities/athena/Vision.tsx';
import type { AttackDirection } from './attack-direction/getAttackDirection.tsx';

export type HiddenMoveActionResponse = Readonly<{
completed?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion apollo/MapMetadata.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Effects } from './Effects.tsx';
import type { Effects } from './Effects.tsx';

export type MapMetadata = Readonly<{
effects?: Effects;
Expand Down
20 changes: 11 additions & 9 deletions apollo/Types.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import Building, { PlainBuilding } from '@deities/athena/map/Building.tsx';
import { PlainEntitiesList } from '@deities/athena/map/PlainMap.tsx';
import Unit, { PlainUnit } from '@deities/athena/map/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import MapData from '@deities/athena/MapData.tsx';
import ImmutableMap from '@nkzw/immutable-map';
import { ActionResponse } from './ActionResponse.tsx';
import { Effects } from './Effects.tsx';
import { EncodedActionResponse } from './EncodedActions.tsx';
import type { PlainBuilding } from '@deities/athena/map/Building.tsx';
import type Building from '@deities/athena/map/Building.tsx';
import type { PlainEntitiesList } from '@deities/athena/map/PlainMap.tsx';
import type { PlainUnit } from '@deities/athena/map/Unit.tsx';
import type Unit from '@deities/athena/map/Unit.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type ImmutableMap from '@nkzw/immutable-map';
import type { ActionResponse } from './ActionResponse.tsx';
import type { Effects } from './Effects.tsx';
import type { EncodedActionResponse } from './EncodedActions.tsx';

export type GameStateEntry = readonly [ActionResponse, MapData];
export type GameState = ReadonlyArray<GameStateEntry>;
Expand Down
6 changes: 3 additions & 3 deletions apollo/action-mutators/ActionMutators.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Skill } from '@deities/athena/info/Skill.tsx';
import { PlayerID } from '@deities/athena/map/Player.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import type { Skill } from '@deities/athena/info/Skill.tsx';
import type { PlayerID } from '@deities/athena/map/Player.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';

export const MoveAction = (
from: Vector,
Expand Down
6 changes: 3 additions & 3 deletions apollo/actions/applyActionResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import {
HealAmount,
MaxHealth,
} from '@deities/athena/map/Configuration.tsx';
import MapData from '@deities/athena/MapData.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import toggleLightningTile from '@deities/athena/mutation/toggleLightningTile.tsx';
import writeTile from '@deities/athena/mutation/writeTile.tsx';
import { VisionT } from '@deities/athena/Vision.tsx';
import type { VisionT } from '@deities/athena/Vision.tsx';
import UnknownTypeError from '@deities/hephaestus/UnknownTypeError.tsx';
import { ActionResponse } from '../ActionResponse.tsx';
import type { ActionResponse } from '../ActionResponse.tsx';
import { applyGameOverActionResponse } from '../GameOver.tsx';
import { applyHiddenActionResponse } from '../HiddenAction.tsx';
import applyEndTurnActionResponse from './applyEndTurnActionResponse.tsx';
Expand Down
4 changes: 2 additions & 2 deletions apollo/actions/applyEndTurnActionResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
isHumanPlayer,
resolveDynamicPlayerID,
} from '@deities/athena/map/Player.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { EndTurnActionResponse } from '../ActionResponse.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { EndTurnActionResponse } from '../ActionResponse.tsx';
import getColorName from '../lib/getColorName.tsx';
import nameGenerator from '../lib/nameGenerator.tsx';

Expand Down
18 changes: 10 additions & 8 deletions apollo/actions/encodeGameActionResponse.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import Building, { PlainBuilding } from '@deities/athena/map/Building.tsx';
import { PlainEntitiesList } from '@deities/athena/map/PlainMap.tsx';
import type { PlainBuilding } from '@deities/athena/map/Building.tsx';
import type Building from '@deities/athena/map/Building.tsx';
import type { PlainEntitiesList } from '@deities/athena/map/PlainMap.tsx';
import { encodeEntities } from '@deities/athena/map/Serialization.tsx';
import Unit, { PlainUnit } from '@deities/athena/map/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { VisionT } from '@deities/athena/Vision.tsx';
import type { PlainUnit } from '@deities/athena/map/Unit.tsx';
import type Unit from '@deities/athena/map/Unit.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { VisionT } from '@deities/athena/Vision.tsx';
import ImmutableMap from '@nkzw/immutable-map';
import { ActionResponse } from '../ActionResponse.tsx';
import type { ActionResponse } from '../ActionResponse.tsx';
import { encodeActionResponse } from '../EncodedActions.tsx';
import computeVisibleActions from '../lib/computeVisibleActions.tsx';
import getVisibleEntities from '../lib/getVisibleEntities.tsx';
import {
import type {
EncodedGameActionResponse,
EncodedGameActionResponseItem,
GameState,
Expand Down
13 changes: 7 additions & 6 deletions apollo/actions/executeGameAction.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import MapData from '@deities/athena/MapData.tsx';
import { VisionT } from '@deities/athena/Vision.tsx';
import { Action, execute, MutateActionResponseFn } from '../Action.tsx';
import { ActionResponse } from '../ActionResponse.tsx';
import { Effects } from '../Effects.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { VisionT } from '@deities/athena/Vision.tsx';
import type { Action, MutateActionResponseFn } from '../Action.tsx';
import { execute } from '../Action.tsx';
import type { ActionResponse } from '../ActionResponse.tsx';
import type { Effects } from '../Effects.tsx';
import applyConditions from '../lib/applyConditions.tsx';
import gameHasEnded from '../lib/gameHasEnded.tsx';
import { GameState } from '../Types.tsx';
import type { GameState } from '../Types.tsx';

type AIType = {
act(map: MapData): MapData | null;
Expand Down
2 changes: 1 addition & 1 deletion apollo/actions/validateAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getUnitInfo } from '@deities/athena/info/Unit.tsx';
import { MaxMessageLength } from '@deities/athena/map/Configuration.tsx';
import { toDynamicPlayerID } from '@deities/athena/map/Player.tsx';
import sanitizeText from '@deities/hephaestus/sanitizeText.tsx';
import { Action } from '../Action.tsx';
import type { Action } from '../Action.tsx';

export default function validateAction(action: Action) {
if (action.type !== 'CharacterMessageEffect') {
Expand Down
2 changes: 1 addition & 1 deletion apollo/attack-direction/getAttackDirection.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SpriteVector from '@deities/athena/map/SpriteVector.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';

export type PlainAttackDirection = 0 | 1 | 2 | 3;

Expand Down
11 changes: 6 additions & 5 deletions apollo/lib/applyConditions.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PlayerID } from '@deities/athena/map/Player.tsx';
import MapData from '@deities/athena/MapData.tsx';
import { ActionResponse } from '../ActionResponse.tsx';
import { applyEffects, Effects } from '../Effects.tsx';
import type { PlayerID } from '@deities/athena/map/Player.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { ActionResponse } from '../ActionResponse.tsx';
import type { Effects } from '../Effects.tsx';
import { applyEffects } from '../Effects.tsx';
import { checkGameOverConditions } from '../GameOver.tsx';
import { GameState, GameStateWithEffects } from '../Types.tsx';
import type { GameState, GameStateWithEffects } from '../Types.tsx';

const getLosingPlayer = (gameState: GameState): PlayerID | null => {
for (const [actionResponse, map] of gameState) {
Expand Down
15 changes: 8 additions & 7 deletions apollo/lib/checkWinCondition.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import matchesPlayerList from '@deities/athena/lib/matchesPlayerList.tsx';
import Entity from '@deities/athena/map/Entity.tsx';
import { PlayerID, PlayerIDSet } from '@deities/athena/map/Player.tsx';
import Unit, { TransportedUnit } from '@deities/athena/map/Unit.tsx';
import Vector from '@deities/athena/map/Vector.tsx';
import MapData from '@deities/athena/MapData.tsx';
import type Entity from '@deities/athena/map/Entity.tsx';
import type { PlayerID, PlayerIDSet } from '@deities/athena/map/Player.tsx';
import type { TransportedUnit } from '@deities/athena/map/Unit.tsx';
import type Unit from '@deities/athena/map/Unit.tsx';
import type Vector from '@deities/athena/map/Vector.tsx';
import type MapData from '@deities/athena/MapData.tsx';
import type { WinCondition } from '@deities/athena/WinConditions.tsx';
import {
onlyHasDefaultWinCondition,
WinCondition,
WinCriteria,
} from '@deities/athena/WinConditions.tsx';
import isPresent from '@deities/hephaestus/isPresent.tsx';
import { ActionResponse } from '../ActionResponse.tsx';
import type { ActionResponse } from '../ActionResponse.tsx';

const destructiveActions = new Set([
'AttackUnit',
Expand Down
Loading