install and configure eslint, bow before eslint

This commit is contained in:
2023-10-12 17:20:28 +02:00
parent b6bf355750
commit eb78ce7b6f
13 changed files with 1739 additions and 155 deletions
BIN
View File
Binary file not shown.
+1534 -28
View File
File diff suppressed because it is too large Load Diff
+28 -3
View File
@@ -2,18 +2,43 @@
"name": "discipleofland", "name": "discipleofland",
"version": "0.0.1", "version": "0.0.1",
"private": true, "private": true,
"type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build && cp -r CNAME dist/CNAME", "build": "vite build && cp -r CNAME dist/CNAME",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
"sass": "^1.67.0",
"typescript": "^5.2.2",
"vue": "^3.3.4" "vue": "^3.3.4"
}, },
"devDependencies": { "devDependencies": {
"sass": "^1.67.0",
"typescript": "^5.2.2",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vitejs/plugin-vue": "^4.2.3", "@vitejs/plugin-vue": "^4.2.3",
"vite": "^4.3.9" "@vue/eslint-config-typescript": "^12.0.0",
"eslint": "^8.51.0",
"eslint-plugin-vue": "^9.17.0",
"vite": "^4.3.9",
"vue-eslint-parser": "^9.3.2",
"vite-plugin-eslint": "^1.8.1"
},
"eslintConfig": {
"root": true,
"parser": "vue-eslint-parser",
"extends": [
"plugin:vue/strongly-recommended",
"eslint:recommended",
"@vue/typescript/recommended"
],
"plugins": ["@typescript-eslint"],
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2020
},
"ignorePatterns": [
"dist/"
]
} }
} }
+10 -9
View File
@@ -1,4 +1,5 @@
<template> <template>
<div>
<nav> <nav>
<div class="current-eorzea-time"> <div class="current-eorzea-time">
{{ eorzeaTime.getPrettyTime() }} {{ eorzeaTime.getPrettyTime() }}
@@ -6,12 +7,12 @@
</nav> </nav>
<main> <main>
<SortedNodeList <SortedNodeList
:nodes="nodes" :nodes="nodes as Node[]"
:zones="zones" :zones="zones"
:eorzeaTime="eorzeaTime" :eorzea-time="eorzeaTime"
/> />
</main> </main>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@@ -59,8 +60,8 @@ export default defineComponent({
this.eorzeaTime = new EorzeaTime(); this.eorzeaTime = new EorzeaTime();
}, 500); }, 500);
const aetheryteData = await fetch("/data/aetherytes.json") const aetheryteData: Response | null = await fetch("/data/aetherytes.json")
.catch(() => { .catch((): null => {
return null; return null;
}); });
if (aetheryteData === null) { if (aetheryteData === null) {
@@ -73,8 +74,8 @@ export default defineComponent({
this.aetherytes.push(new Aetheryte(aetheryteData)); this.aetherytes.push(new Aetheryte(aetheryteData));
} }
const itemData = await fetch("/data/items.json") const itemData: Response | null = await fetch("/data/items.json")
.catch(() => { .catch((): null => {
return null; return null;
}); });
if (itemData === null) { if (itemData === null) {
@@ -88,8 +89,8 @@ export default defineComponent({
this.items[itemId] = new Item(itemId, itemData); this.items[itemId] = new Item(itemId, itemData);
} }
const zoneData = await fetch("/data/zones.json") const zoneData: Response | null = await fetch("/data/zones.json")
.catch(() => { .catch((): null => {
return null; return null;
}); });
if (zoneData === null) { if (zoneData === null) {
+29 -8
View File
@@ -1,6 +1,10 @@
<template> <template>
<article class="node"> <article class="node">
<div class="timer">{{ gatheringNode.isActive(eorzeaTime) ? 'Active' : prettyTimer(gatheringNode.getSecondsToNextActiveTime(eorzeaTime)) }}</div> <div class="timer">
{{
gatheringNode.isActive(eorzeaTime) ? 'Active' : prettyTimer(gatheringNode.getSecondsToNextActiveTime(eorzeaTime))
}}
</div>
<div class="job"> <div class="job">
<div class="icon"> <div class="icon">
<img <img
@@ -13,19 +17,27 @@
</div> </div>
<div class="aetheryte"> <div class="aetheryte">
<span class="icon"> <span class="icon">
<img src="https://xivapi.com/img-misc/mappy/aetheryte.png" alt="Aetheryte icon" draggable="false"> <img
src="https://xivapi.com/img-misc/mappy/aetheryte.png"
alt="Aetheryte icon"
draggable="false"
>
</span> </span>
<div class="info"> <div class="info">
<span>{{ zones[gatheringNode.nearestAetheryte.position.zone]?.name?.en }}</span> <span>{{ zones[gatheringNode.nearestAetheryte.position.zone]?.name?.en }}</span>
<span>{{ gatheringNode.nearestAetheryte.name }}</span> <span>{{ gatheringNode.nearestAetheryte.name.en }}</span>
<span>{{ gatheringNode.nearestAetheryte.position.x }}, {{ gatheringNode.nearestAetheryte.position.y }}</span> <span>{{ gatheringNode.nearestAetheryte.position.x }}, {{ gatheringNode.nearestAetheryte.position.y }}</span>
</div> </div>
</div> </div>
<div class="items"> <div class="items">
<span v-for="item in gatheringNode.items">{{ item.name }} (lv. {{ item.level }})</span> <span
v-for="item in gatheringNode.items"
:key="item.name"
>
{{ item.name }} (lv. {{ item.level }})
</span>
</div> </div>
</article>
</article>
</template> </template>
<script lang="ts"> <script lang="ts">
@@ -71,6 +83,7 @@ export default defineComponent({
border: 1px solid #fff; border: 1px solid #fff;
padding: 0.5rem; padding: 0.5rem;
border-radius: 0.25rem; border-radius: 0.25rem;
.timer { .timer {
min-width: 7rem; min-width: 7rem;
font-size: 2rem; font-size: 2rem;
@@ -78,19 +91,23 @@ export default defineComponent({
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.job { .job {
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
.icon { .icon {
width: 3rem; width: 3rem;
height: 3rem; height: 3rem;
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
} }
} }
.aetheryte { .aetheryte {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@@ -100,15 +117,18 @@ export default defineComponent({
font-size: 1.5rem; font-size: 1.5rem;
border-radius: 0.75rem; border-radius: 0.75rem;
padding: 0.35rem 1rem; padding: 0.35rem 1rem;
background-color: rgba(0,0,0, 0.2); background-color: rgba(0, 0, 0, 0.2);
.icon { .icon {
width: 3rem; width: 3rem;
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: fill; object-fit: fill;
} }
} }
.info { .info {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@@ -117,6 +137,7 @@ export default defineComponent({
gap: 0.1rem; gap: 0.1rem;
} }
} }
.items { .items {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
+7 -6
View File
@@ -1,12 +1,13 @@
<template> <template>
<div class="node-list"> <div class="node-list">
<GatheringNode <GatheringNode
v-for="node in displayNodes" v-for="node in displayNodes"
:gathering-node="node" :key="`${node.location.x}-${node.location.y}-${node.location.zone}`"
:eorzeaTime="eorzeaTime" :gathering-node="node as Node"
:eorzea-time="eorzeaTime"
:zones="zones" :zones="zones"
/> />
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
@@ -55,10 +56,10 @@ export default defineComponent(
}), }),
methods: { methods: {
sortListByTime() { sortListByTime() {
this.displayNodes.sort((a, b) => { this.displayNodes.sort((a, b): number => {
const aSeconds = a.getSecondsToNextActiveTime(this.eorzeaTime); const aSeconds = a.getSecondsToNextActiveTime(this.eorzeaTime);
const bSeconds = b.getSecondsToNextActiveTime(this.eorzeaTime); const bSeconds = b.getSecondsToNextActiveTime(this.eorzeaTime);
if (aSeconds === bSeconds) return a; if (aSeconds === bSeconds) return 1;
return aSeconds - bSeconds; return aSeconds - bSeconds;
}); });
}, },
+2 -2
View File
@@ -6,10 +6,10 @@ export default class Aetheryte {
} }
constructor( constructor(
data: any, data: {position: {x: number, y: number, zone: string}, name: {en: string}}
) { ) {
this.position = data.position; this.position = data.position;
this.name = data.name.en; this.name = data.name;
} }
+10 -5
View File
@@ -3,13 +3,18 @@ export default class Item {
readonly id: string; readonly id: string;
readonly name: string; readonly name: string;
readonly level: number; readonly level: number;
readonly scripType: ScripType; readonly scripType: ScripType | null;
constructor(id: string, data: any) { constructor(id: string, data: {[key: string]: number | string | undefined}) {
this.id = id; this.id = id;
this.name = data?.name; this.name = data?.name as string;
this.level = data?.level; this.level = data?.level as number;
this.scripType = data?.scripType ? ScripType[data.scripType.toUpperCase()] : null; const scripType: string | undefined = data?.scripType as string;
if (scripType != undefined) {
this.scripType = typeof data?.scripType === "string" ? scripType.toUpperCase() as ScripType : null;
} else {
this.scripType = null;
}
} }
} }
+2 -2
View File
@@ -1,5 +1,5 @@
import {Job} from "../enums/Job"; import {Job} from "@/enums/Job";
import {NodeType} from "../enums/NodeType"; import {NodeType} from "@/enums/NodeType";
import Item from "./Item"; import Item from "./Item";
import Aetheryte from "./Aetheryte"; import Aetheryte from "./Aetheryte";
import TimeRange from "./TimeRange"; import TimeRange from "./TimeRange";
+4 -2
View File
@@ -4,8 +4,10 @@ export default class Zone {
en: string, en: string,
} }
constructor(data: any) { constructor(data: {name: {en: string}}) {
this.name = data.name; this.name = {
en: data.name.en
};
} }
} }
+1 -1
View File
@@ -11,7 +11,7 @@ export default class EorzeaTime {
*/ */
readonly eorzeaDate: Date; readonly eorzeaDate: Date;
private constructor(realDate: Date = new Date()) { public constructor(realDate: Date = new Date()) {
this.realDate = realDate; this.realDate = realDate;
this.eorzeaDate = new Date(realDate.getTime() * (3600 / 175)); this.eorzeaDate = new Date(realDate.getTime() * (3600 / 175));
} }
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"moduleResolution": "Node",
"strict": true,
"jsx": "preserve",
"resolveJsonModule": true,
"isolatedModules": true,
"esModuleInterop": true,
"lib": ["ESNext", "DOM"],
"skipLibCheck": true,
"noEmit": true,
"allowJs": true,
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
}
+2
View File
@@ -2,11 +2,13 @@ import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite' import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue' import vue from '@vitejs/plugin-vue'
import eslintPlugin from 'vite-plugin-eslint'
// https://vitejs.dev/config/ // https://vitejs.dev/config/
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
vue(), vue(),
eslintPlugin(),
], ],
resolve: { resolve: {
alias: { alias: {