Skip to content

Commit

Permalink
* update linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorMurphy21 committed Jan 24, 2024
1 parent 949bc67 commit 1fd6b32
Show file tree
Hide file tree
Showing 33 changed files with 74 additions and 55 deletions.
1 change: 1 addition & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module.exports = {
parser: '@typescript-eslint/parser'
},
rules: {
'@typescript-eslint/consistent-type-imports': ['error'],
'@typescript-eslint/no-unused-vars': ['off'],
'@typescript-eslint/no-unsafe-assignment': ['off'],
'vue/multi-word-component-names': ['off'],
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/lobby/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ import { useGameStore } from '@/stores/game.js';
import { mapState } from 'pinia';
import { defineComponent } from 'vue';
import { SettableOptions } from ':common/options';
import type { SettableOptions } from ':common/options';
type NumericKeyOfOptions = {
[K in keyof SettableOptions]: SettableOptions[K] extends number ? K : never;
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/lobby/PlayerCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script lang="ts">
import { defineComponent, type PropType } from 'vue';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';
export default defineComponent({
props: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/lobby/PlayerList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import PlayerCard from '@/components/lobby/PlayerCard.vue';
import { useRoomStore } from '@/stores/room.js';
import { mapState } from 'pinia';
import { defineComponent } from 'vue';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';
export default defineComponent({
components: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/responseMatching/MatchingSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { useRoomStore } from '@/stores/room.js';
import { useGameStore } from '@/stores/game.js';
import { mapState } from 'pinia';
import { defineComponent } from 'vue';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';
const click = new AudioWrap(ClickMp3);
Expand Down
3 changes: 2 additions & 1 deletion client/src/directives/tooltip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DirectiveBinding, nextTick } from 'vue';
import type { DirectiveBinding } from 'vue';
import { nextTick } from 'vue';
import { Tooltip } from 'bootstrap';
import { useSettingsStore } from '@/stores/settings.js';

Expand Down
3 changes: 2 additions & 1 deletion client/src/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createWebHistory, createRouter, RouteLocation } from 'vue-router';
import type { RouteLocation } from 'vue-router';
import { createWebHistory, createRouter } from 'vue-router';
import Home from '@/views/Home.vue';
const Game = () => import('@/views/Game.vue');
const About = () => import('@/views/About.vue');
Expand Down
2 changes: 1 addition & 1 deletion client/src/socket/socket.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import io from 'socket.io-client';
import { TypedClientSocket } from ':common/socketioTypes';
import type { TypedClientSocket } from ':common/socketioTypes';

let socket: TypedClientSocket;
if (process.env.NODE_ENV !== 'production') {
Expand Down
8 changes: 5 additions & 3 deletions client/src/stores/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import socket from '@/socket/socket.js';
import { useRoomStore } from '@/stores/room.js';
import { defineStore } from 'pinia';
import {
import type {
Player,
Match as ServerMatch,
PollName,
Expand All @@ -12,8 +12,10 @@ import {
Responses,
MidgameConnectData
} from ':common/stateTypes';
import { defaultOptions, Options, VisibleOptions } from ':common/options';
import { isOk, isSuccess, Result } from ':common/result';
import type { Options, VisibleOptions } from ':common/options';
import { defaultOptions } from ':common/options';
import type { Result } from ':common/result';
import { isOk } from ':common/result';

type Scene =
| 'lobby'
Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import router from '@/router/index.js';
import socket from '@/socket/socket.js';
import { defineStore } from 'pinia';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';

interface State {
players: Player[];
Expand Down
2 changes: 1 addition & 1 deletion client/src/types/shims-vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// noinspection JSUnusedGlobalSymbols

declare module '*.vue' {
import { defineComponent } from 'vue';
import type { defineComponent } from 'vue';
const Component: ReturnType<typeof defineComponent>;
export default Component;
}
2 changes: 1 addition & 1 deletion client/src/types/vue-i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* you need to import the some interfaces
*/
import { DefineLocaleMessage, DefineDateTimeFormat, DefineNumberFormat } from 'vue-i18n';
import en from '@/locales/en';
import type en from '@/locales/en';

type LocaleMessage = typeof en;

Expand Down
1 change: 1 addition & 0 deletions server/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = {
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'@typescript-eslint/consistent-type-imports': ['error'],
'prettier/prettier': 2
},
ignorePatterns: ['/*', '!/src', '!/tests']
Expand Down
6 changes: 4 additions & 2 deletions server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/**
* Module dependencies.
*/
import express, { Express, Request, Response } from 'express';
import type { Express, Request, Response } from 'express';
import express from 'express';

import cors from 'cors';
import path from 'path';
Expand Down Expand Up @@ -48,7 +49,8 @@ const server = http.createServer(app);
* Create socket server
*/

import { TypedServer, TypedSocket } from ':common/socketioTypes';
import type { TypedSocket } from ':common/socketioTypes';
import { TypedServer } from ':common/socketioTypes';
const io = new TypedServer(server, {
cors: {
origin: ['http://localhost:8080', 'http://localhost:5001'],
Expand Down
3 changes: 2 additions & 1 deletion server/src/logger/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import winston, { LogEntry } from 'winston';
import type { LogEntry } from 'winston';
import winston from 'winston';
import WinstonCloudWatch from 'winston-cloudwatch';

const logger = winston.createLogger({
Expand Down
16 changes: 10 additions & 6 deletions server/src/routes/gameHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { getRoomById, Room } from '../state/rooms';
import type { Room } from '../state/rooms';
import { getRoomById } from '../state/rooms';
import { GameState } from '../state/gameState';
import { z } from 'zod';
import logger from '../logger/logger';

/*** handler validation schemas ***/
import { isErr, isOk, isSuccess, Result } from ':common/result';
import { SettableOptions, getSettableOptionsSchema, getVisibleOptionsSchema } from ':common/options';
import { PollName, zPollName } from ':common/stateTypes';
import { TypedServer, TypedSocket } from ':common/socketioTypes';
import { Responses } from ':common/stateTypes';
import type { Result } from ':common/result';
import { isErr, isOk, isSuccess } from ':common/result';
import type { SettableOptions } from ':common/options';
import { getSettableOptionsSchema, getVisibleOptionsSchema } from ':common/options';
import type { PollName } from ':common/stateTypes';
import { zPollName } from ':common/stateTypes';
import type { TypedServer, TypedSocket } from ':common/socketioTypes';
import type { Responses } from ':common/stateTypes';

const registerGameHandlers = (io: TypedServer, socket: TypedSocket) => {
/*** GAME STATE ENDPOINTS ***/
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/registerHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerRoomHandlers } from './roomHandlers';
import { registerGameHandlers } from './gameHandlers';
import { TypedServer, TypedSocket } from ':common/socketioTypes';
import type { TypedServer, TypedSocket } from ':common/socketioTypes';

export function registerHandlers(io: TypedServer, socket: TypedSocket) {
registerRoomHandlers(io, socket);
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/roomHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import logger from '../logger/logger';
import { midgameJoin } from './gameHandlers';
import { isErr } from ':common/result';
import { z } from 'zod';
import { TypedServer, TypedSocket } from ':common/socketioTypes';
import type { TypedServer, TypedSocket } from ':common/socketioTypes';

/*** handler validation schemas ***/
const roomSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/roomService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { roomService } from '../state/rooms';
import logger from '../logger/logger';
import { TypedServer } from ':common/socketioTypes';
import type { TypedServer } from ':common/socketioTypes';
// 1 minute
const TIMEOUT = 60 * 1000;
// 1 second
Expand Down
10 changes: 6 additions & 4 deletions server/src/state/gameState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { Prompts } from './prompts';
import { getCorrections, stringMatch } from './matchUtils';
import { PollService } from './pollService';
import logger from '../logger/logger';
import { Room } from './rooms';
import { Err, Info, Ok, Result, Success, VoidResult, Warn } from ':common/result';
import { defaultOptions, getVisibleOptionsSchema, Options, VisibleOptions } from ':common/options';
import {
import type { Room } from './rooms';
import type { Result, VoidResult } from ':common/result';
import { Err, Info, Ok, Success, Warn } from ':common/result';
import type { Options, VisibleOptions } from ':common/options';
import { defaultOptions, getVisibleOptionsSchema } from ':common/options';
import type {
Match,
MidgameConnectData,
PollName,
Expand Down
7 changes: 4 additions & 3 deletions server/src/state/pollService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { GameState } from './gameState';
import { Err, Ok, Result, Warn } from ':common/result';
import { PollName, Stage } from ':common/stateTypes';
import type { GameState } from './gameState';
import type { Result } from ':common/result';
import { Err, Ok, Warn } from ':common/result';
import type { PollName, Stage } from ':common/stateTypes';
import logger from '../logger/logger';

type Poll = {
Expand Down
5 changes: 3 additions & 2 deletions server/src/state/rooms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { GameState } from './gameState';
import parameterize from 'parameterize';
import locale from 'locale';
import { Info, isErr, Ok, Result, Success, VoidResult, Warn } from ':common/result';
import { Player } from ':common/stateTypes';
import type { Result, VoidResult } from ':common/result';
import { Info, isErr, Ok, Success, Warn } from ':common/result';
import type { Player } from ':common/stateTypes';

export type Room = {
name: string;
Expand Down
2 changes: 1 addition & 1 deletion server/tests/routes/createjoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { io as ioc } from 'socket.io-client';
import { type AddressInfo } from 'node:net';
import { registerHandlers } from '../../src/routes/registerHandlers';
import { assert } from 'chai';
import { TypedClientSocket } from ':common/socketioTypes';
import type { TypedClientSocket } from ':common/socketioTypes';

describe('Validation tests', () => {
let io: Server;
Expand Down
4 changes: 2 additions & 2 deletions server/tests/routes/lobby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { io as ioc } from 'socket.io-client';
import { type AddressInfo } from 'node:net';
import { registerHandlers } from '../../src/routes/registerHandlers';
import { assert } from 'chai';
import { Player } from ':common/stateTypes';
import { TypedClientSocket } from ':common/socketioTypes';
import type { Player } from ':common/stateTypes';
import type { TypedClientSocket } from ':common/socketioTypes';

describe('lobby tests', () => {
let io: Server, clientSocket1: TypedClientSocket, clientSocket2: TypedClientSocket;
Expand Down
2 changes: 1 addition & 1 deletion server/tests/routes/promptResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { io as ioc } from 'socket.io-client';
import { type AddressInfo } from 'node:net';
import { registerHandlers } from '../../src/routes/registerHandlers';
import { assert } from 'chai';
import { TypedClientSocket } from ':common/socketioTypes';
import type { TypedClientSocket } from ':common/socketioTypes';

describe('promptResponse tests', () => {
const roomName = 'room';
Expand Down
4 changes: 2 additions & 2 deletions server/tests/routes/responseSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { io as ioc } from 'socket.io-client';
import { type AddressInfo } from 'node:net';
import { registerHandlers } from '../../src/routes/registerHandlers';
import { assert } from 'chai';
import { Player } from ':common/stateTypes';
import { TypedClientSocket } from ':common/socketioTypes';
import type { Player } from ':common/stateTypes';
import type { TypedClientSocket } from ':common/socketioTypes';

const SHARED_RESPONSE = 'sharedResponse';
const C1_RESPONSE = 'c1Response';
Expand Down
4 changes: 2 additions & 2 deletions server/tests/state/autoMatch.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { GameState } from '../../src/state/gameState';
import { Room } from '../../src/state/rooms';
import { Player } from ':common/stateTypes';
import type { Room } from '../../src/state/rooms';
import type { Player } from ':common/stateTypes';

describe('Automatch tests', () => {
const selectorId = 'selector';
Expand Down
4 changes: 2 additions & 2 deletions server/tests/state/completeCallbacks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GameState } from '../../src/state/gameState';
import { assert } from 'chai';
import { Room } from '../../src/state/rooms';
import { Player } from ':common/stateTypes';
import type { Room } from '../../src/state/rooms';
import type { Player } from ':common/stateTypes';

describe('Complete callback tests', () => {
let players: Player[];
Expand Down
7 changes: 4 additions & 3 deletions server/tests/state/pollService.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PollService } from '../../src/state/pollService';
import { Room } from '../../src/state/rooms';
import type { Room } from '../../src/state/rooms';
import { GameState } from '../../src/state/gameState';
import { assert } from 'chai';
import { isErr, Result } from ':common/result';
import { Player } from ':common/stateTypes';
import type { Result } from ':common/result';
import { isErr } from ':common/result';
import type { Player } from ':common/stateTypes';

describe('PollVote tests', () => {
it('unregistered poll', () => {
Expand Down
4 changes: 2 additions & 2 deletions server/tests/state/selectionAccepts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'chai';
import { GameState } from '../../src/state/gameState';
import { Room } from '../../src/state/rooms';
import type { Room } from '../../src/state/rooms';
import { isErr, isSuccess } from ':common/result';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';

describe('Selection Accepting tests', () => {
const selectorId = 'selector';
Expand Down
4 changes: 2 additions & 2 deletions server/tests/state/selectionRotation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Room } from '../../src/state/rooms';
import type { Room } from '../../src/state/rooms';
import { GameState } from '../../src/state/gameState';
import { assert } from 'chai';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';

describe('Selection Rotation tests', () => {
let players: Player[];
Expand Down
2 changes: 1 addition & 1 deletion server/tests/state/sikeDispute.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GameState } from '../../src/state/gameState';
import { assert } from 'chai';
import { isErr, isSuccess } from ':common/result';
import { Player } from ':common/stateTypes';
import type { Player } from ':common/stateTypes';

describe('Sike Dispute tests', () => {
const selectorId = '0';
Expand Down
7 changes: 4 additions & 3 deletions server/tests/state/voteSkipPrompt.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { GameState } from '../../src/state/gameState';
import { assert } from 'chai';
import { Room } from '../../src/state/rooms';
import { isOk, Result } from ':common/result';
import { Player } from ':common/stateTypes';
import type { Room } from '../../src/state/rooms';
import type { Result } from ':common/result';
import { isOk } from ':common/result';
import type { Player } from ':common/stateTypes';

describe('voteSkipPrompt tests', () => {
// must be even
Expand Down

0 comments on commit 1fd6b32

Please sign in to comment.