Skip to content

Commit

Permalink
chore: better imports structure
Browse files Browse the repository at this point in the history
Made use of eslint and prettier plugins to format imports in the code and make it more readable.
  • Loading branch information
joamag committed Aug 27, 2024
1 parent a6e5b7f commit 30ec5de
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 22 deletions.
16 changes: 15 additions & 1 deletion frontends/web/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@
module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
parser: "@typescript-eslint/parser",
plugins: ["@typescript-eslint", "react-hooks"],
plugins: ["@typescript-eslint", "react-hooks", "import"],
rules: {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
"import/order": [
"error",
{
groups: [
"builtin",
"external",
"internal",
"parent",
"sibling",
"index"
],
"newlines-between": "always"
}
],
"no-constant-condition": [
"error",
{
Expand Down
1 change: 1 addition & 0 deletions frontends/web/.prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"plugins": ["prettier-plugin-organize-imports"],
"semi": true,
"trailingComma": "none",
"singleQuote": false,
Expand Down
1 change: 1 addition & 0 deletions frontends/web/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { startApp } from "emukit";

import { GameboyEmulator } from "./ts";

const BACKGROUNDS = [
Expand Down
2 changes: 2 additions & 0 deletions frontends/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
"buffer": "^6.0.3",
"emukit": "^0.10.9",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react-hooks": "^4.6.2",
"jszip": "^3.10.1",
"nodemon": "^3.1.4",
"parcel": "^2.12.0",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.0.0",
"process": "^0.11.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
5 changes: 3 additions & 2 deletions frontends/web/react/components/audio-gb/audio-gb.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Canvas, CanvasStructure, PixelFormat } from "emukit";
import React, {
FC,
useCallback,
Expand All @@ -6,8 +7,8 @@ import React, {
useRef,
useState
} from "react";
import { Canvas, CanvasStructure, PixelFormat } from "emukit";
import { WebglPlot, WebglLine, ColorRGBA } from "webgl-plot";
import { ColorRGBA, WebglLine, WebglPlot } from "webgl-plot";

import { GameboyEmulator } from "../../../ts";

import "./audio-gb.css";
Expand Down
5 changes: 3 additions & 2 deletions frontends/web/react/components/debug/debug.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, { FC, useCallback, useEffect, useState } from "react";
import { ButtonSwitch, Info, Pair } from "emukit";
import React, { FC, useCallback, useEffect, useState } from "react";

import { GameboyEmulator } from "../../../ts";
import { AudioGB } from "../audio-gb/audio-gb";
import { RegistersGB } from "../registers-gb/registers-gb";
import { TilesGB } from "../tiles-gb/tiles-gb";
import { GameboyEmulator } from "../../../ts";

import "./debug.css";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { FC, useEffect, useMemo, useState } from "react";

import { GameBoySpeed } from "../../../lib/boytacean";

import "./registers-gb.css";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC, useEffect, useMemo, useRef, useState } from "react";
import { ButtonSwitch, Emulator, Info, Pair, PanelTab } from "emukit";
import React, { FC, useEffect, useMemo, useRef, useState } from "react";

import { GameboyEmulator, SerialDevice, bufferToDataUrl } from "../../../ts";

import "./serial-section.css";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, useMemo } from "react";
import { TextInput } from "emukit";
import React, { FC, useMemo } from "react";

import "./test-section.css";

Expand Down
2 changes: 1 addition & 1 deletion frontends/web/react/components/tiles-gb/tiles-gb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC, useCallback, useEffect, useMemo, useRef } from "react";
import { Canvas, CanvasStructure, PixelFormat } from "emukit";
import React, { FC, useCallback, useEffect, useMemo, useRef } from "react";

import "./tiles-gb.css";

Expand Down
29 changes: 15 additions & 14 deletions frontends/web/ts/gb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { loadAsync } from "jszip";
import {
AudioSpecs,
base64ToBuffer,
Expand All @@ -20,29 +19,31 @@ import {
SectionInfo,
Size
} from "emukit";
import { PALETTES, PALETTES_MAP } from "./palettes";
import {
DebugAudio,
DebugGeneral,
DebugSettings,
HelpFaqs,
HelpKeyboard,
SerialSection,
TestSection
} from "../react";
import { loadAsync } from "jszip";

import {
Cartridge,
default as _wasm,
Cartridge,
ClockFrame,
GameBoy,
GameBoyMode,
GameBoySpeed,
Info,
PadKey,
StateManager,
ClockFrame
StateManager
} from "../lib/boytacean";
import info from "../package.json";
import {
DebugAudio,
DebugGeneral,
DebugSettings,
HelpFaqs,
HelpKeyboard,
SerialSection,
TestSection
} from "../react";

import { PALETTES, PALETTES_MAP } from "./palettes";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
declare const require: any;
Expand Down

0 comments on commit 30ec5de

Please sign in to comment.