Skip to content

Commit

Permalink
Update linter
Browse files Browse the repository at this point in the history
  • Loading branch information
neki-dev committed Feb 16, 2024
1 parent 954eced commit 5af86c5
Show file tree
Hide file tree
Showing 144 changed files with 1,209 additions and 612 deletions.
40 changes: 37 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,51 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint"],
plugins: ["@typescript-eslint", "import"],
extends: [
"eslint:recommended",
"plugin:import/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
],
rules: {
// Basic
"no-multiple-empty-lines": ["error", { max: 1, maxBOF: 0, maxEOF: 1 }],
"object-curly-spacing": ["error", "always"],
"array-bracket-spacing": ["error", "never"],
"computed-property-spacing": ["error", "never"],
"comma-dangle": ["error", "always-multiline"],
"eol-last": ["error", "always"],
"no-trailing-spaces": "error",
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
// TypeScript
"@typescript-eslint/semi": "error",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-inferrable-types": "off",
// Import
"import/no-unresolved": "off",
"import/no-named-as-default-member": "off",
"import/no-named-as-default": "off",
"import/order": [
"warn",
{
groups: [
"builtin",
"external",
"parent",
"sibling",
"index",
"object",
"type",
"unknown",
],
alphabetize: {
order: "asc",
},
},
],
},
ignorePatterns: ["**/*.js", "**/__tests__/**", "**/__mocks__/**"],
ignorePatterns: ["**/*.js"],
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"start": "vite --host",
"build": "vite build",
"test": "jest",
"lint": "eslint \"./**/*.{js,ts,tsx}\" --ignore-path .gitignore --fix"
"lint": "eslint \"./**/*.{ts,tsx}\" --ignore-path .gitignore --fix"
},
"devDependencies": {
"@types/heap": "0.2.33",
Expand All @@ -37,6 +37,7 @@
"@vitejs/plugin-react": "4.2.1",
"alias-reuse": "2.0.0",
"eslint": "8.56.0",
"eslint-plugin-import": "2.29.1",
"jest": "29.7.0",
"jest-canvas-mock": "2.5.2",
"jest-environment-jsdom": "29.7.0",
Expand Down
17 changes: 8 additions & 9 deletions src/game/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import Phaser from 'phaser';

import { CONTAINER_ID, DEBUG_MODS, AUDIO_VOLUME } from './const';
import { GameDifficulty, GameState, GameSettings, GameScene, GameEvent,
} from './types';
import type {
IGame, GameStat, GameSavePayload } from './types';
import type { StorageSave } from '~lib/storage/types';
import type { IScreen } from '~scene/screen/types';
import type { IWorld } from '~scene/world/types';
import { registerShaders } from '~lib/shader';
import { Storage } from '~lib/storage';
import type { StorageSave } from '~lib/storage/types';
import { Tutorial } from '~lib/tutorial';
import { Utils } from '~lib/utils';
import { Gameover } from '~scene/gameover';
import { Menu } from '~scene/menu';
import { MenuPage } from '~scene/menu/types';
import { Screen } from '~scene/screen';
import type { IScreen } from '~scene/screen/types';
import { System } from '~scene/system';
import { World } from '~scene/world';
import type { IWorld } from '~scene/world/types';

import { CONTAINER_ID, DEBUG_MODS, AUDIO_VOLUME } from './const';
import type {
IGame, GameStat, GameSavePayload } from './types';
import { GameDifficulty, GameState, GameSettings, GameScene, GameEvent
} from './types';

export class Game extends Phaser.Game implements IGame {
public difficulty: GameDifficulty = GameDifficulty.NORMAL;
Expand Down
9 changes: 4 additions & 5 deletions src/game/scenes/gameover/interface/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { useClick, useGame } from 'phaser-react-ui';
import React, { useEffect, useRef } from 'react';

import type { GameStat, IGame } from '../../../types';
import { phrase } from '~lib/lang';
import { Tutorial } from '~lib/tutorial';
import { Overlay } from '~scene/system/interface/overlay';

import { Result } from './result';
import {
Wrapper, Label, Button, Head, IconRestart,
} from './styles';
import type { GameStat, IGame } from '../../../types';
import { phrase } from '~lib/lang';
import { Tutorial } from '~lib/tutorial';
import { Overlay } from '~scene/system/interface/overlay';

type Props = {
stat: GameStat
Expand Down
7 changes: 3 additions & 4 deletions src/game/scenes/gameover/interface/result/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useMemo } from 'react';

import type { GameStat } from '../../../../types';
import { phrase } from '~lib/lang';
import type { LangPhrase } from '~lib/lang/types';

import {
Wrapper, Item, Value, Label, Record,
} from './styles';
import type { GameStat } from '../../../../types';
import type { LangPhrase } from '~lib/lang/types';
import { phrase } from '~lib/lang';

type Props = {
stat: GameStat
Expand Down
3 changes: 1 addition & 2 deletions src/game/scenes/menu/interface/content/about-game/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';

import { phrase } from '~lib/lang';

import { Wrapper } from './styles';
import { phrase } from '~lib/lang';

export const AboutGame: React.FC = () => (
<Wrapper>
Expand Down
5 changes: 2 additions & 3 deletions src/game/scenes/menu/interface/content/controls/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';

import { CONTROLS } from '~lib/controls/const';
import { phrase } from '~lib/lang';

import {
Wrapper, Control, Keys, Key, Description,
} from './styles';
import { CONTROLS } from '~lib/controls/const';
import { phrase } from '~lib/lang';

export const Controls: React.FC = () => (
<Wrapper>
Expand Down
3 changes: 1 addition & 2 deletions src/game/scenes/menu/interface/content/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React from 'react';

import { MenuPage } from '~scene/menu/types';

import { AboutGame } from './about-game';
import { Controls } from './controls';
import { LoadGame } from './load-game';
import { NewGame } from './new-game';
import { SaveGame } from './save-game';
import { Settings } from './settings';
import { Wrapper } from './styles';
import { MenuPage } from '~scene/menu/types';

type Props = {
page?: MenuPage
Expand Down
5 changes: 2 additions & 3 deletions src/game/scenes/menu/interface/content/load-game/index.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { useGame } from 'phaser-react-ui';
import React, { useState } from 'react';

import { Wrapper, Empty } from './styles';
import type { IGame } from '../../../../../types';
import { phrase } from '~lib/lang';
import type { LangPhrase } from '~lib/lang/types';
import { phrase } from '~lib/lang';
import { Storage } from '~lib/storage';
import { Button } from '~scene/system/interface/button';
import { Confirm } from '~scene/system/interface/confirm';
import { Table } from '~scene/system/interface/table';

import { Wrapper, Empty } from './styles';

export const LoadGame: React.FC = () => {
const game = useGame<IGame>();

Expand Down
9 changes: 4 additions & 5 deletions src/game/scenes/menu/interface/content/new-game/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ import Phaser from 'phaser';
import { useGame } from 'phaser-react-ui';
import React, { useMemo, useState } from 'react';

import type { IGame } from '../../../../../types';
import { GameDifficulty } from '../../../../../types';
import { phrase } from '~lib/lang';
import { Button } from '~scene/system/interface/button';
import { LevelPlanet } from '~scene/world/level/types';

import { Param } from './param';
import { Record } from './record';
import { Wrapper, Params } from './styles';
import type { IGame } from '../../../../../types';
import { phrase } from '~lib/lang';
import { Button } from '~scene/system/interface/button';
import { LevelPlanet } from '~scene/world/level/types';

export const NewGame: React.FC = () => {
const game = useGame<IGame>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';

import { phrase } from '~lib/lang';

import {
Wrapper, Amount, Icon, Label, Value,
} from './styles';
import { phrase } from '~lib/lang';

type Props = {
value: number
Expand Down
11 changes: 5 additions & 6 deletions src/game/scenes/menu/interface/content/save-game/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { useGame } from 'phaser-react-ui';
import type { ChangeEvent } from 'react';
import React, {
useRef, useEffect, useState,
} from 'react';

import { MAX_GAME_SAVES } from '../../../../../const';
import { Input, Limit, Wrapper } from './styles';
import type { IGame } from '../../../../../types';
import { phrase } from '~lib/lang';
import type { ChangeEvent } from 'react';

import type { LangPhrase } from '~lib/lang/types';
import { Storage } from '~lib/storage';
import type { StorageSave } from '~lib/storage/types';
import { phrase } from '~lib/lang';
import { Storage } from '~lib/storage';
import { Button } from '~scene/system/interface/button';
import { Confirm } from '~scene/system/interface/confirm';
import { Table } from '~scene/system/interface/table';

import { Input, Limit, Wrapper } from './styles';

export const SaveGame: React.FC = () => {
const game = useGame<IGame>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useGame } from 'phaser-react-ui';
import React, { useMemo, useState } from 'react';

import type { GameSettings, IGame } from '../../../../../../types';
import { InterfaceTextColor } from '~lib/interface/types';
import type { LangPhrase } from '~lib/lang/types';
import { InterfaceTextColor } from '~lib/interface/types';
import { Setting } from '~scene/system/interface/setting';

type Props = {
Expand Down
5 changes: 2 additions & 3 deletions src/game/scenes/menu/interface/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, { useEffect, useState } from 'react';

import { Tutorial } from '~lib/tutorial';
import { Overlay } from '~scene/system/interface/overlay';

import { Content } from './content';
import { Copyright } from './copyright';
import { Navigation } from './navigation';
import {
Wrapper, Logotype, Sidebar, Main,
} from './styles';
import type { MenuPage } from '../types';
import { Tutorial } from '~lib/tutorial';
import { Overlay } from '~scene/system/interface/overlay';

type Props = {
defaultPage?: MenuPage
Expand Down
9 changes: 4 additions & 5 deletions src/game/scenes/menu/interface/navigation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { useGame } from 'phaser-react-ui';
import React, { useMemo, useState } from 'react';

import type { IGame } from '../../../../types';
import { GameState } from '../../../../types';
import { phrase } from '~lib/lang';
import { Wrapper, Item, Space } from './styles';
import type { IGame } from '../../../../types';
import type { LangPhrase } from '~lib/lang/types';
import { Tutorial } from '~lib/tutorial';
import type { MenuItem } from '~scene/menu/types';
import { phrase } from '~lib/lang';
import { Tutorial } from '~lib/tutorial';
import { MenuPage } from '~scene/menu/types';
import { Confirm } from '~scene/system/interface/confirm';

import { Wrapper, Item, Space } from './styles';

type Props = {
page?: MenuPage
onSelect: (page: MenuPage) => void
Expand Down
9 changes: 4 additions & 5 deletions src/game/scenes/screen/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import VirtualJoystick from 'phaser3-rex-plugins/plugins/virtualjoystick';

import { Scene } from '..';
import { GameScene } from '../../types';
import { Assets } from '~lib/assets';
import { INTERFACE_SCALE } from '~lib/interface/const';
import type { LangPhrase } from '~lib/lang/types';

import { ScreenUI } from './interface';
import type { IScreen } from './types';
import { ScreenAudio, ScreenEvent } from './types';
import type { IScreen } from './types';
import type { LangPhrase } from '~lib/lang/types';
import { Assets } from '~lib/assets';
import { INTERFACE_SCALE } from '~lib/interface/const';

Assets.RegisterAudio(ScreenAudio);

Expand Down
9 changes: 4 additions & 5 deletions src/game/scenes/screen/interface/builder/building/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React from 'react';

import { phrase } from '~lib/lang';
import type { LangPhrase } from '~lib/lang/types';
import { Hint } from '~scene/system/interface/hint';
import type { BuildingVariant } from '~scene/world/entities/building/types';

import { Preview } from './preview';
import {
Container, Info, Name, Text,
} from './styles';
import type { LangPhrase } from '~lib/lang/types';
import type { BuildingVariant } from '~scene/world/entities/building/types';
import { phrase } from '~lib/lang';
import { Hint } from '~scene/system/interface/hint';

type Props = {
variant: BuildingVariant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import {
import React, { useRef, useState } from 'react';

import { GameScene } from '../../../../../../types';
import { Cost } from '~scene/system/interface/cost';
import { BUILDINGS } from '~scene/world/entities/building/factory/const';
import type { BuildingVariant } from '~scene/world/entities/building/types';
import type { IWorld } from '~scene/world/types';

import {
Container, Number, Image, Info, Frame,
} from './styles';
import type { BuildingVariant } from '~scene/world/entities/building/types';
import type { IWorld } from '~scene/world/types';
import { Cost } from '~scene/system/interface/cost';
import { BUILDINGS } from '~scene/world/entities/building/factory/const';

type Props = {
number: number
Expand Down
15 changes: 7 additions & 8 deletions src/game/scenes/screen/interface/builder/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { useGame, useScene, useSceneUpdate } from 'phaser-react-ui';
import React, { useEffect, useMemo, useState } from 'react';

import type { IGame } from '../../../../types';
import { GameScene } from '../../../../types';
import { phrase } from '~lib/lang';
import { Building } from './building';
import {
Category, Label, Variants, Wrapper,
} from './styles';
import type { IGame } from '../../../../types';
import type { LangPhrase } from '~lib/lang/types';
import type { IWorld } from '~scene/world/types';
import { phrase } from '~lib/lang';
import { Tutorial } from '~lib/tutorial';
import { TutorialStep } from '~lib/tutorial/types';
import { Utils } from '~lib/utils';
import { BUILDINGS } from '~scene/world/entities/building/factory/const';
import { BuildingVariant, BuildingCategory } from '~scene/world/entities/building/types';
import type { IWorld } from '~scene/world/types';

import { Building } from './building';
import {
Category, Label, Variants, Wrapper,
} from './styles';

export const Builder: React.FC = () => {
const game = useGame<IGame>();
Expand Down
Loading

0 comments on commit 5af86c5

Please sign in to comment.