Skip to content

Commit

Permalink
Add dprint to project (#826)
Browse files Browse the repository at this point in the history
* add dprint to project

* dprint formatting, part 1

* dprint formatting, part 2

* remove prettier
  • Loading branch information
gustav87 authored Sep 2, 2024
1 parent 4e88264 commit d197a41
Show file tree
Hide file tree
Showing 47 changed files with 1,338 additions and 1,509 deletions.
7 changes: 0 additions & 7 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ module.exports = {
es2022: true,
node: true,
},
//plugins: [
// "prettier"
//],
extends: [
"eslint:recommended",
"plugin:vue/essential",
"plugin:vuetify/base",
// "plugin:vuetify/recommended",
// "plugin:prettier/recommended",
"@vue/typescript/recommended",
// "@vue/prettier/@typescript-eslint"
// "@vue/typescript/recommended",
// "@vue/prettier/@typescript-eslint",
"plugin:lodash/recommended",
],
rules: {
// "prettier/prettier": "warn",
"arrow-parens": ["warn", "always"],
"camelcase": "off",
"comma-dangle": "off",
Expand Down
5 changes: 0 additions & 5 deletions .prettierrc

This file was deleted.

21 changes: 21 additions & 0 deletions dprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"lineWidth": 999,
"typescript": {
"indentWidth": 2,
"quoteStyle": "preferDouble",
"newLineKind": "auto",
"nextControlFlowPosition": "maintain",
"module.sortImportDeclarations": "maintain"
},
"excludes": [
"**/node_modules",
"**/yarn.lock",
"**/*.js",
"src/locales/data.ts",
"components.d.ts",
".eslintrc.cjs"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.88.10.wasm"
]
}
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"build:dev": "rimraf ./dist && vite build",
"lint": "eslint --no-fix src/",
"lint:fix": "eslint --fix src/",
"format": "node_modules/.bin/prettier --write .",
"generate-locales": "tsx scripts/generate-locales.ts"
"generate-locales": "tsx scripts/generate-locales.ts",
"dprint": "dprint check",
"dprint:fix": "dprint fmt"
},
"dependencies": {
"@fontsource-variable/inter": "~5.0.16",
Expand Down Expand Up @@ -59,25 +60,21 @@
"@types/google-spreadsheet": "^3.3.0",
"@types/lodash": "^4.14.191",
"@types/node": "^20.11.30",
"@types/prettier": "^2.7.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-vue2": "^2.3.1",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.2",
"deepmerge": "^4.2.2",
"dotenv": "^16.0.3",
"dprint": "^0.47.2",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-plugin-lodash": "^7.4.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-vue": "^9.26.0",
"eslint-plugin-vuetify": "^1.1.0",
"google-spreadsheet": "^3.2.0",
"http-server": "^14.1.1",
"lodash.set": "^4.3.2",
"prettier": "^2.8.1",
"rimraf": "^5.0.0",
"sass": "~1.32.13",
"terser": "^5.29.2",
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const constants = {
ongoingMatchesRefreshInterval: 30000,
queueDataRefreshInterval: 10000
queueDataRefreshInterval: 10000,
};
export default constants;
2 changes: 1 addition & 1 deletion src/helpers/date-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ export const dateToCurrentTimeDate = (endDateString: string): string => {
now.setMonth(endDate.getMonth());
now.setFullYear(endDate.getFullYear());
return now.toISOString();
};
};
30 changes: 14 additions & 16 deletions src/helpers/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { useI18n } from "vue-i18n-bridge";
// got it from here: https://www.petermorlion.com/iterating-a-typescript-enum/
export const enumKeys = <
O extends Record<string, unknown>,
K extends keyof O = keyof O
>(
obj: O
): K[] => {
K extends keyof O = keyof O,
>(obj: O): K[] => {
return Object.keys(obj).filter((k) => Number.isNaN(+k)) as K[];
};

Expand All @@ -32,23 +30,23 @@ export const racesWithTotal: Race[] = [
];

export const authorizedFetch = async (method: string, url: RequestInfo | URL, token: string, body?: BodyInit | null): Promise<Response> => {
return await fetch(url, {
method: method,
body: body,
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${token}`
},
});
};
return await fetch(url, {
method: method,
body: body,
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
});
};

export const authDownload = (url: string, token: string, fileName: string) => {
fetch(url, {
method: "GET",
headers: {
"Authorization": `Bearer ${token}`
}
"Authorization": `Bearer ${token}`,
},
})
.then((response) => {
if (!response.ok) {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/profile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ERaceEnum } from "@/store/types";
import { RaceWinsOnMap, WinLossesOnMap, RaceStat } from "@/store/player/types";
import { RaceStat, RaceWinsOnMap, WinLossesOnMap } from "@/store/player/types";

export function defaultStatsTab(raceWinsOnMap: RaceWinsOnMap[]): string {
let maxRace = ERaceEnum.TOTAL;
Expand All @@ -13,7 +13,7 @@ export function defaultStatsTab(raceWinsOnMap: RaceWinsOnMap[]): string {
s.winLossesOnMap.forEach((w: WinLossesOnMap) => {
const gamesOfRace = w.winLosses
.map((wl: RaceStat) => wl.games)
.reduce((a: number, b:number) => a + b, 0);
.reduce((a: number, b: number) => a + b, 0);

if (maxGames < gamesOfRace) {
maxRace = s.race;
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/url-functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { EAvatarCategory } from "@/store/types";
export function getAvatarUrl(
category: EAvatarCategory,
picId: number,
isClassic: boolean
isClassic: boolean,
) {
if (picId == undefined || picId == null) {
return `${INGAME_STATIC_RESOURCES_URL}icons/raceAvatars/STARTER_${Math.floor(Math.random() * 5) + 1}.jpg?v=2`;
Expand Down
6 changes: 3 additions & 3 deletions src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ const en = {
NeonCity: "Neon City",
HarvestOfSorrow: "Harvest of Sorrow",
TwilightRuins: "Twilight Ruins",
//MarketSquare: "Market Square",
//SanctuaryLV: "Sanctuary LV",
// MarketSquare: "Market Square",
// SanctuaryLV: "Sanctuary LV",
Rockslide: "Rockslide",
//Ferocity: "Ferocity",
// Ferocity: "Ferocity",
FrozenMarshlands: "Frozen Marshlands",
TastaCastleGardens: "Tasta Castle Gardens",

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import App from "./App.vue";
import router from "./router";
import vuetify from "./plugins/vuetify";
import VueI18n from "vue-i18n";
import { createI18n, castToVueI18n } from "vue-i18n-bridge";
import { castToVueI18n, createI18n } from "vue-i18n-bridge";
import languages from "@/locales/languages";
import VueCookies from "vue-cookies";
import { createPinia, PiniaVuePlugin } from "pinia";
Expand Down
13 changes: 6 additions & 7 deletions src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export default new Vuetify({
},
light: {
"w3-race-bg": "#e9e9e9",
}
}
},
},
},
icons: {
iconfont: 'mdiSvg', // 'mdi' || 'mdiSvg' || 'md' || 'fa' || 'fa4' || 'faSvg'
iconfont: "mdiSvg", // 'mdi' || 'mdiSvg' || 'md' || 'fa' || 'fa4' || 'faSvg'
values: {
trovo: {
component: TrovoIcon,
Expand All @@ -32,12 +32,11 @@ export default new Vuetify({
w3info: {
component: W3infoIcon,
},
}
}
},
},
});


export const useVuetify = () => {
const vm = getCurrentInstance();
return vm!.proxy?.$vuetify || undefined;
};
};
46 changes: 23 additions & 23 deletions src/router/types.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
export enum EAdminRouteName {
LIVE_QUEUE_DATA = "Admin - Live Queue Data",
BANNED_PLAYERS = "Admin - Banned Players",
SMURF_CHECKER = "Admin - Smurf Checker",
GLOBAL_MUTE = "Admin - Global Mute",
LOUNGE_MUTE = "Admin - Lounge Mute",
VIEW_GAME_CHAT = "Admin - View Game Chat",
PROXY_SETTINGS = "Admin - Proxy Settings",
NEWS = "Admin - News",
LOADING_SCREEN_TIPS = "Admin - Loading Screen Tips",
MESSAGE_OF_THE_DAY = "Admin - Message Of The Day",
ASSIGN_PORTRAITS = "Admin - Assign Portraits",
MANAGE_PORTRAITS = "Admin - Manage Portraits",
MANAGE_ALIBABA_FILES = "Admin - Manage Alibaba Files",
MANAGE_S3_FILES = "Admin - Manage S3 Files",
MANAGE_MAPS = "Admin - Manage Maps",
MANAGE_TOURNAMENTS = "Admin - Manage Tournaments",
MANAGE_PERMISSIONS = "Admin - Manage Permissions",
VIEW_SERVER_LOGS = "Admin - View Server Logs",
SERVER_LOG = "Admin - Server Log",
LIVE_QUEUE_DATA = "Admin - Live Queue Data",
BANNED_PLAYERS = "Admin - Banned Players",
SMURF_CHECKER = "Admin - Smurf Checker",
GLOBAL_MUTE = "Admin - Global Mute",
LOUNGE_MUTE = "Admin - Lounge Mute",
VIEW_GAME_CHAT = "Admin - View Game Chat",
PROXY_SETTINGS = "Admin - Proxy Settings",
NEWS = "Admin - News",
LOADING_SCREEN_TIPS = "Admin - Loading Screen Tips",
MESSAGE_OF_THE_DAY = "Admin - Message Of The Day",
ASSIGN_PORTRAITS = "Admin - Assign Portraits",
MANAGE_PORTRAITS = "Admin - Manage Portraits",
MANAGE_ALIBABA_FILES = "Admin - Manage Alibaba Files",
MANAGE_S3_FILES = "Admin - Manage S3 Files",
MANAGE_MAPS = "Admin - Manage Maps",
MANAGE_TOURNAMENTS = "Admin - Manage Tournaments",
MANAGE_PERMISSIONS = "Admin - Manage Permissions",
VIEW_SERVER_LOGS = "Admin - View Server Logs",
SERVER_LOG = "Admin - Server Log",
}

export enum EStatisticsRouteName {
PLAYER_ACTIVITY = "Statistics - Player Activity",
MMR = "Statistics - MMR",
WINRATES = "Statistics - Winrates",
HEROES = "Statistics - Heroes",
PLAYER_ACTIVITY = "Statistics - Player Activity",
MMR = "Statistics - MMR",
WINRATES = "Statistics - Winrates",
HEROES = "Statistics - Heroes",
}
7 changes: 2 additions & 5 deletions src/services/AuthorizationService.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { W3cToken, TwitchToken, BnetOAuthRegion } from "@/store/oauth/types";
import { BnetOAuthRegion, TwitchToken, W3cToken } from "@/store/oauth/types";
import { IDENTIFICATION_URL, REDIRECT_URL } from "@/main";
import Vue from "vue";

const w3CAuth = "W3ChampionsJWT";
const w3CAuthRegion = "W3ChampionsAuthRegion";

export default class AuthorizationService {
public static async authorize(
code: string,
region: BnetOAuthRegion = BnetOAuthRegion.eu
): Promise<W3cToken> {
public static async authorize(code: string, region: BnetOAuthRegion = BnetOAuthRegion.eu): Promise<W3cToken> {
const url = `${IDENTIFICATION_URL}api/oauth/token?code=${code}&redirectUri=${REDIRECT_URL}&region=${region}`;
const response = await fetch(url, {
method: "GET",
Expand Down
Loading

0 comments on commit d197a41

Please sign in to comment.