From 2211113e24f2e388f4bde75de7dc74c6895127d7 Mon Sep 17 00:00:00 2001 From: Steven Snoeijen Date: Sun, 24 Jul 2022 16:34:11 +0200 Subject: [PATCH] refactor: format all src files feat: add --- .eslintrc.js | 27 +- package-lock.json | 46 +++ package.json | 1 + src/components/pixi/PixiApplication.vue | 192 ++++----- src/components/pixi/PixiViewport.vue | 9 +- src/components/pixi/types.ts | 6 +- .../worldeditor/AnimatorPreview.vue | 89 ++-- src/game/Constants.tsx | 10 +- src/game/Engine.ts | 185 +++++---- src/game/EntityFactory.ts | 138 ++++--- src/game/EntityHelper.ts | 143 +++---- src/game/EventBus.ts | 56 ++- src/game/Events.ts | 6 +- src/game/GameTime.ts | 14 +- src/game/Input.ts | 124 +++--- src/game/Optional.ts | 2 +- src/game/__tests__/utils.ts | 47 ++- src/game/ai/behaviortree/Tree.ts | 14 +- src/game/ai/behaviortree/nodes/Node.spec.ts | 153 ++++--- src/game/ai/behaviortree/nodes/Node.ts | 116 +++--- .../ai/behaviortree/nodes/core/Always.spec.ts | 21 +- src/game/ai/behaviortree/nodes/core/Always.ts | 12 +- .../behaviortree/nodes/core/Inventer.spec.ts | 72 ++-- .../ai/behaviortree/nodes/core/Inventer.ts | 30 +- .../behaviortree/nodes/core/Parallel.spec.ts | 108 ++--- .../ai/behaviortree/nodes/core/Parallel.ts | 61 +-- .../behaviortree/nodes/core/Selector.spec.ts | 94 ++--- .../ai/behaviortree/nodes/core/Selector.ts | 42 +- .../behaviortree/nodes/core/Sequence.spec.ts | 74 ++-- .../ai/behaviortree/nodes/core/Sequence.ts | 36 +- .../ai/behaviortree/nodes/core/Timer.spec.ts | 231 ++++++----- src/game/ai/behaviortree/nodes/core/Timer.ts | 86 ++-- src/game/ai/behaviortree/nodes/core/index.ts | 2 +- .../behaviortree/nodes/entity/Attack.spec.ts | 38 +- .../ai/behaviortree/nodes/entity/Attack.ts | 22 +- .../nodes/entity/EntityNode.spec.ts | 40 +- .../behaviortree/nodes/entity/EntityNode.ts | 22 +- .../behaviortree/nodes/entity/Follow.spec.ts | 61 +-- .../ai/behaviortree/nodes/entity/Follow.ts | 26 +- .../nodes/entity/HasTarget.spec.ts | 59 ++- .../ai/behaviortree/nodes/entity/HasTarget.ts | 26 +- .../nodes/entity/IsControlledBy.ts | 37 +- .../nodes/entity/IsControlledByAi.ts | 10 +- .../nodes/entity/IsControlledByPlayer.ts | 10 +- .../nodes/entity/IsEnemyInAggroRange.spec.ts | 14 +- .../nodes/entity/IsEnemyInAggroRange.ts | 14 +- .../nodes/entity/IsEnemyInAttackRange.spec.ts | 12 +- .../nodes/entity/IsEnemyInAttackRange.ts | 11 +- .../nodes/entity/IsEnemyInRange.spec.ts | 121 +++--- .../nodes/entity/IsEnemyInRange.ts | 50 ++- .../nodes/entity/IsMoving.spec.ts | 55 +-- .../ai/behaviortree/nodes/entity/IsMoving.ts | 33 +- .../nodes/entity/SetTarget.spec.ts | 59 ++- .../ai/behaviortree/nodes/entity/SetTarget.ts | 22 +- .../nodes/entity/UnsetTarget.spec.ts | 75 ++-- .../behaviortree/nodes/entity/UnsetTarget.ts | 28 +- .../ai/behaviortree/nodes/entity/index.ts | 2 +- .../behaviortree/nodes/entity/utils.spec.ts | 58 +-- .../ai/behaviortree/nodes/entity/utils.ts | 28 +- src/game/ai/pathfinding.spec.ts | 380 +++++++++--------- src/game/ai/pathfinding.ts | 293 +++++++------- src/game/animation/Animation.ts | 6 +- src/game/animation/AnimationManager.ts | 10 +- src/game/animation/Animator.ts | 12 +- src/game/animation/Model.ts | 10 +- src/game/animation/utils.ts | 176 +++++--- src/game/env.d.ts | 6 +- src/game/levels/BehaviorTreeLevel.ts | 158 ++++---- src/game/levels/Level.ts | 19 +- src/game/levels/PathFindingLevel.ts | 74 ++-- src/game/levels/RandomUnitsLevel.ts | 79 ++-- src/game/levels/utils.spec.ts | 28 +- src/game/levels/utils.ts | 72 ++-- src/game/math/IPosition.ts | 5 +- src/game/math/ISize.ts | 6 +- src/game/math/Vector2.spec.ts | 251 ++++++------ src/game/math/Vector2.ts | 200 ++++----- src/game/math/collision/Bounds.ts | 55 ++- src/game/systems/AttackComponent.spec.ts | 32 +- src/game/systems/AttackComponent.ts | 30 +- src/game/systems/ControlledComponent.ts | 11 +- src/game/systems/DefaultAttributes.ts | 6 +- src/game/systems/GameTimeSystem.ts | 8 +- src/game/systems/InputSystem.ts | 97 ++--- src/game/systems/PixiJsSystem.ts | 12 +- src/game/systems/SizeComponent.ts | 16 +- src/game/systems/TeamComponent.ts | 11 +- src/game/systems/TransformComponent.ts | 36 +- src/game/systems/ai/BehaviorTreeComponent.ts | 12 +- src/game/systems/ai/BehaviorTreeSystem.ts | 28 +- src/game/systems/ai/TargetComponent.ts | 12 +- src/game/systems/ai/TargetSystem.ts | 46 +-- src/game/systems/alive/AliveComponent.ts | 12 +- src/game/systems/alive/AliveSystem.ts | 74 ++-- .../systems/health/HealthComponent.spec.ts | 20 +- src/game/systems/health/HealthComponent.ts | 26 +- src/game/systems/health/HealthSystem.ts | 65 +-- src/game/systems/health/utils.ts | 16 +- .../systems/movement/CollidableComponent.ts | 2 +- src/game/systems/movement/FollowComponent.ts | 10 +- src/game/systems/movement/FollowSystem.ts | 99 ++--- src/game/systems/movement/MovableComponent.ts | 10 +- .../systems/movement/MovePathComponent.ts | 12 +- src/game/systems/movement/MovePathSystem.ts | 126 +++--- .../movement/MovePositionDirectComponent.ts | 10 +- .../movement/MovePositionDirectSystem.ts | 138 ++++--- .../MoveTransformVelocityComponent.ts | 22 +- .../systems/movement/MoveVelocityComponent.ts | 24 +- .../systems/movement/MoveVelocitySystem.ts | 52 +-- .../player/PlayerMovementKeysComponent.ts | 2 +- .../player/PlayerMovementKeysSystem.ts | 115 +++--- .../player/PlayerMovementMouseComponent.ts | 2 +- .../player/PlayerMovementMouseSystem.ts | 115 +++--- src/game/systems/render/AssetComponent.ts | 12 +- src/game/systems/render/GridSystem.ts | 78 ++-- src/game/systems/render/MapSystem.ts | 59 ++- .../render/graphics/GraphicsComponent.ts | 14 +- .../systems/render/graphics/GraphicsSystem.ts | 211 +++++----- .../render/sprite/AnimatedSpriteComponent.ts | 19 +- .../systems/render/sprite/SpriteComponent.ts | 12 +- .../systems/render/sprite/SpriteSystem.ts | 119 +++--- src/game/systems/render/sprite/utils.ts | 42 +- .../selection/PlayerSelectionSystem.ts | 273 +++++++------ .../systems/selection/SelectableComponent.ts | 12 +- src/game/systems/utils/index.spec.ts | 100 +++-- src/game/systems/utils/index.ts | 41 +- src/game/systems/utils/transform.spec.ts | 170 ++++---- src/game/systems/utils/transform.ts | 87 ++-- src/game/utils.spec.ts | 208 +++++----- src/game/utils.ts | 86 ++-- src/index.css | 2 +- src/shims-vue.d.ts | 10 +- src/types/global.d.ts | 8 +- src/views/GameView.vue | 8 +- 134 files changed, 4167 insertions(+), 3733 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 0e772df..68c0cd9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -2,17 +2,40 @@ require('@rushstack/eslint-patch/modern-module-resolution'); module.exports = { + env: { + browser: true, + node: true, + }, + globals: { + document: false, + }, extends: [ 'eslint:recommended', 'plugin:vue/vue3-essential', '@vue/eslint-config-typescript', ], - plugins: ['import'], + plugins: ['import', 'unused-imports'], rules: { 'max-len': ['warn', { code: 80, ignorePattern: '^import\\W.*' }], quotes: ['warn', 'single'], semi: ['warn', 'always'], - 'import/order': ['warn'], + 'import/order': [ + 'warn', + { + 'newlines-between': 'always', + }, + ], 'spaced-comment': ['warn', 'always'], + 'unused-imports/no-unused-imports': 'warn', + 'no-unused-vars': 'off', + 'unused-imports/no-unused-vars': [ + 'warn', + { + vars: 'all', + varsIgnorePattern: '^_', + args: 'after-used', + argsIgnorePattern: '^_', + }, + ], }, }; diff --git a/package-lock.json b/package-lock.json index 791bbee..3a0c2b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "autoprefixer": "^10.4.7", "eslint": "^8.20.0", "eslint-plugin-import": "^2.26.0", + "eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-vue": "^9.2.0", "gh-pages": "^3.2.3", "jest": "^28.1.3", @@ -4510,6 +4511,27 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true }, + "node_modules/eslint-plugin-unused-imports": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz", + "integrity": "sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==", + "dev": true, + "dependencies": { + "eslint-rule-composer": "^0.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^5.0.0", + "eslint": "^8.0.0" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + } + } + }, "node_modules/eslint-plugin-vue": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.2.0.tgz", @@ -4531,6 +4553,15 @@ "eslint": "^6.2.0 || ^7.0.0 || ^8.0.0" } }, + "node_modules/eslint-rule-composer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", + "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", + "dev": true, + "engines": { + "node": ">=4.0.0" + } + }, "node_modules/eslint-scope": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", @@ -13154,6 +13185,15 @@ } } }, + "eslint-plugin-unused-imports": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-2.0.0.tgz", + "integrity": "sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==", + "dev": true, + "requires": { + "eslint-rule-composer": "^0.3.0" + } + }, "eslint-plugin-vue": { "version": "9.2.0", "resolved": "https://registry.npmjs.org/eslint-plugin-vue/-/eslint-plugin-vue-9.2.0.tgz", @@ -13169,6 +13209,12 @@ "xml-name-validator": "^4.0.0" } }, + "eslint-rule-composer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", + "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", + "dev": true + }, "eslint-scope": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", diff --git a/package.json b/package.json index 1deb044..dc3ec42 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "autoprefixer": "^10.4.7", "eslint": "^8.20.0", "eslint-plugin-import": "^2.26.0", + "eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-vue": "^9.2.0", "gh-pages": "^3.2.3", "jest": "^28.1.3", diff --git a/src/components/pixi/PixiApplication.vue b/src/components/pixi/PixiApplication.vue index 769d7ab..7660361 100644 --- a/src/components/pixi/PixiApplication.vue +++ b/src/components/pixi/PixiApplication.vue @@ -1,11 +1,11 @@ \ No newline at end of file + diff --git a/src/components/pixi/PixiViewport.vue b/src/components/pixi/PixiViewport.vue index 57a1a1f..5b238d4 100644 --- a/src/components/pixi/PixiViewport.vue +++ b/src/components/pixi/PixiViewport.vue @@ -15,7 +15,7 @@ const props = defineProps({ type: Number, required: false, }, - /** @default window.innerHeight */ + /** @default window.innerHeight */ screenHeight: { type: Number, required: false, @@ -48,7 +48,7 @@ const props = defineProps({ }, forceHitArea: { type: PIXI.Rectangle as PropType, - required: false + required: false, }, /** @default false */ noTicker: { @@ -63,7 +63,6 @@ const props = defineProps({ disableOnContextMenu: { type: Boolean, required: false, - }, /** @default document.body */ divWheel: { @@ -102,6 +101,6 @@ onUnmounted(() => { }); defineExpose({ - viewport + viewport, }); - \ No newline at end of file + diff --git a/src/components/pixi/types.ts b/src/components/pixi/types.ts index 39383e1..29613bb 100644 --- a/src/components/pixi/types.ts +++ b/src/components/pixi/types.ts @@ -2,9 +2,9 @@ import { Viewport } from 'pixi-viewport'; import * as PIXI from 'pixi.js'; export type PixiApplicationInstance = { - application: PIXI.Application; + application: PIXI.Application; }; export type PixiViewportInstance = { - viewport: Viewport, -} \ No newline at end of file + viewport: Viewport; +}; diff --git a/src/components/worldeditor/AnimatorPreview.vue b/src/components/worldeditor/AnimatorPreview.vue index 98a26b9..8147deb 100644 --- a/src/components/worldeditor/AnimatorPreview.vue +++ b/src/components/worldeditor/AnimatorPreview.vue @@ -4,23 +4,34 @@
- @@ -31,8 +42,12 @@ :screen-height="application.view.height" :interaction="application.renderer.plugins.interaction" :wheel="{ - center: new PIXI.Point(application.view.width / 2, application.view.height / 2) - }"/> + center: new PIXI.Point( + application.view.width / 2, + application.view.height / 2 + ), + }" + />
@@ -40,33 +55,45 @@