Skip to content

Commit

Permalink
wip linter
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed Jan 1, 2025
1 parent 1b0eef3 commit cd15fc1
Show file tree
Hide file tree
Showing 65 changed files with 712 additions and 606 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,15 @@ jobs:

- name: Install UI packages
run: cd ui && bun install

eslint:
runs-on: ubuntu-latest
steps:
- name: Setup repository
uses: actions/checkout@v4

- name: install bun
uses: oven-sh/setup-bun@v2

- name: run linter
run: bun run lint
8 changes: 8 additions & 0 deletions mobile-frontend/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// https://docs.expo.dev/guides/using-eslint/
module.exports = {
extends: ["expo", "prettier"],
plugins: ["prettier"],
rules: {
"prettier/prettier": "error",
},
};
Binary file modified mobile-frontend/bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions mobile-frontend/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import "reflect-metadata";

import 'react-native-gesture-handler';

global.Buffer = require('buffer').Buffer;
import "react-native-gesture-handler";

import "@azure/core-asynciterator-polyfill";

import { registerRootComponent } from "expo";

import App from "./src/App";

global.Buffer = require("buffer").Buffer;

// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
// It also ensures that whether you load the app in Expo Go or in a native build,
// the environment is set up appropriately
Expand Down
7 changes: 7 additions & 0 deletions mobile-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"main": "index.js",
"private": true,
"scripts": {
"lint": "expo lint",
"fix": "eslint . --fix",
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
Expand Down Expand Up @@ -36,6 +38,8 @@
"d3": "^7.9.0",
"date-fns": "^3.6.0",
"decimal.js": "^10.4.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"ethers": "^6.13.1",
"events": "^3.3.0",
"expo": "51.0.14",
Expand All @@ -59,6 +63,7 @@
"graphql": "^16.9.0",
"lodash": "^4.17.21",
"path": "^0.12.7",
"prettier": "^3.4.2",
"react": "18.3.1",
"react-dom": "18.3.1",
"react-native": "0.74.2",
Expand All @@ -85,6 +90,8 @@
"@types/d3": "^7.4.3",
"@types/lodash": "^4.17.7",
"@types/react": "~18.3.3",
"eslint": "^8.57.0",
"eslint-config-expo": "^7.0.0",
"typescript": "^5.5.3"
}
}
2 changes: 1 addition & 1 deletion mobile-frontend/shims/fs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
readFile: () => {
throw new Error('fs.readFile unsupported');
throw new Error("fs.readFile unsupported");
},
};
2 changes: 1 addition & 1 deletion mobile-frontend/shims/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ module.exports = {
return {
on: () => {},
};
}
},
};
2 changes: 1 addition & 1 deletion mobile-frontend/shims/https.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
Server: class Server {},
};
};
4 changes: 2 additions & 2 deletions mobile-frontend/shims/perf_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const start = Date.now();
module.exports = {
performance: {
now: () => {
return (Date.now() - start);
return Date.now() - start;
},
}
},
};
8 changes: 4 additions & 4 deletions mobile-frontend/shims/timers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
/**
* A workaround to inconsistent setInterval/clearInternval in [tarn.js](https://github.com/Vincit/tarn.js/blob/e33d223831367a264db33e35d4c9381a089e539c/src/Pool.ts#L5)
*/
const timers = require('timers-browserify');
const timers = require("timers-browserify");

function clearTimeout(timer) {
if (typeof timer === 'number') {
if (typeof timer === "number") {
globalThis.clearTimeout(timer);
return;
}
timers.clearTimeout(timer);
}

function clearInterval(timer) {
if (typeof timer === 'number') {
if (typeof timer === "number") {
globalThis.clearInterval(timer);
return;
}
Expand All @@ -25,4 +25,4 @@ module.exports = {
...timers,
clearTimeout,
clearInterval,
};
};
3 changes: 1 addition & 2 deletions mobile-frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { View } from "react-native";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { SafeAreaProvider } from "react-native-safe-area-context";
import {
ApolloClient,
ApolloProvider,
Expand Down Expand Up @@ -154,7 +154,6 @@ const App: FC = () => {
presentation: "modal",
}}
/>

</Stack.Navigator>
</NavigationContainer>
</GestureHandlerRootView>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {

import * as SecureStore from "expo-secure-store";

class ReactNativeEncryptedStoreService implements PlatformEncryptedStoreService {
class ReactNativeEncryptedStoreService
implements PlatformEncryptedStoreService
{
private static RULES = new Map<EncryptedStoreRule, number>([
[EncryptedStoreRule.AfterFirstUnlock, SecureStore.AFTER_FIRST_UNLOCK],
[
Expand All @@ -31,7 +33,7 @@ class ReactNativeEncryptedStoreService implements PlatformEncryptedStoreService
public async setItem(
key: string,
value: string,
rule: EncryptedStoreRule
rule: EncryptedStoreRule,
): Promise<void> {
return SecureStore.setItem(key, value, {
keychainAccessible: ReactNativeEncryptedStoreService.RULES.get(rule)!,
Expand Down
6 changes: 3 additions & 3 deletions mobile-frontend/src/backend/ReactNativeSqliteService.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { PlatformSqliteService } from '@postero/core';
import ExpoSQLiteDialect from '@expo/knex-expo-sqlite-dialect';
import { PlatformSqliteService } from "@postero/core";
import ExpoSQLiteDialect from "@expo/knex-expo-sqlite-dialect";

class ReactNativeSqliteService implements PlatformSqliteService {
public async getKnexConfig() {
return {
client: ExpoSQLiteDialect,
connection: {
filename: 'postero.db',
filename: "postero.db",
},
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { WindowManagerService } from '@postero/core';
import { WindowManagerService } from "@postero/core";

class ReactNativeWindowManagerService implements WindowManagerService {
}
class ReactNativeWindowManagerService implements WindowManagerService {}

export default ReactNativeWindowManagerService;
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { Injectable } from "@nestjs/common";
import { IBrowserBridge } from "@postero/core";

@Injectable()
class ReactNativeBrowserBridge implements IBrowserBridge {

}
class ReactNativeBrowserBridge implements IBrowserBridge {}

export default ReactNativeBrowserBridge;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Injectable } from "@nestjs/common";

@Injectable()
class ReactNativeBrowserLinkService {
}
class ReactNativeBrowserLinkService {}

export default ReactNativeBrowserLinkService;
4 changes: 2 additions & 2 deletions mobile-frontend/src/backend/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import bootstrapBackend, { Backend } from "@postero/core";
import ReactNativePlatformModule from './ReactNativePlatformModule';
import ReactNativePlatformModule from "./ReactNativePlatformModule";

const bootstrap = async (): Promise<Backend> => {
const proc = process as any;

if (!global.Buffer) {
global.Buffer = require('buffer/').Buffer;
global.Buffer = require("buffer/").Buffer;
}

Object.assign(proc, {
Expand Down
16 changes: 8 additions & 8 deletions mobile-frontend/src/backend/window-manager/ReactNativeWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ class ElectronWindow implements IWindow {

private readonly eventEmitter = new Emittery();

public async init(type: WindowType, params?: any, parent?: IWindow): Promise<void> {
public async init(
type: WindowType,
params?: any,
parent?: IWindow,
): Promise<void> {
this.frame = false;
this.state = WindowState.Foreground;
}
Expand All @@ -38,11 +42,7 @@ class ElectronWindow implements IWindow {
return this.eventEmitter.on(eventName, listener);
}

public onContextMenu(event: ContextMenuEventData): void {
public onContextMenu(event: ContextMenuEventData): void {}

}

public close(): void {

}
}
public close(): void {}
}
2 changes: 1 addition & 1 deletion mobile-frontend/src/graphql/LocalLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class LocalLink extends ApolloLink {

public request(
operation: Operation,
forward?: NextLink
forward?: NextLink,
): Observable<FetchResult> | null {
return new Observable((observer) => {
setTimeout(() => {
Expand Down
12 changes: 6 additions & 6 deletions mobile-frontend/src/graphql/apollo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ export const getApolloClient = (backend: Backend) => {
);
},
subscriptionLink,
localLink
localLink,
);

const apolloClient = new ApolloClient({
cache: new InMemoryCache(),
link: splitLink,
defaultOptions: {
watchQuery: {
fetchPolicy: 'no-cache',
errorPolicy: 'ignore',
fetchPolicy: "no-cache",
errorPolicy: "ignore",
},
query: {
fetchPolicy: 'no-cache',
errorPolicy: 'all',
fetchPolicy: "no-cache",
errorPolicy: "all",
},
}
},
});

return apolloClient;
Expand Down
3 changes: 1 addition & 2 deletions mobile-frontend/src/icons/WalletIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const WalletIcon: FC<Props> = ({ color }) => {
/>
</Svg>
);
}
};

export default WalletIcon;

21 changes: 8 additions & 13 deletions mobile-frontend/src/movements/gql-types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import { gql } from '@apollo/client';
import BN from 'bn.js';
import { gql } from "@apollo/client";
import BN from "bn.js";

export const GET_MOVEMENTS = gql`
query GetMovements(
$walletAddress: Bytes!,
) {
movements(
walletAddress: $walletAddress
) {
query GetMovements($walletAddress: Bytes!) {
movements(walletAddress: $walletAddress) {
totalCount
pageInfo {
prevCursor
Expand Down Expand Up @@ -53,20 +49,19 @@ export const GET_MOVEMENTS = gql`
}
`;


export interface GqlAbstractTransaction {
version: string;
hash: string;
}

export interface GqlBlockMetadataTransaction extends GqlAbstractTransaction {
__typename: 'BlockMetadataTransaction';
__typename: "BlockMetadataTransaction";
epoch: string;
timestamp: string;
}

export interface GqlUserTransaction extends GqlAbstractTransaction {
__typename: 'UserTransaction';
__typename: "UserTransaction";
moduleAddress: string;
moduleName: string;
functionName: string;
Expand All @@ -78,14 +73,14 @@ export interface GqlUserTransaction extends GqlAbstractTransaction {
}

export interface GqlScriptUserTransaction extends GqlAbstractTransaction {
__typename: 'ScriptUserTransaction';
__typename: "ScriptUserTransaction";
success: boolean;
sender: string;
timestamp: string;
}

export interface GqlGenesisTransaction extends GqlAbstractTransaction {
__typename: 'GenesisTransaction';
__typename: "GenesisTransaction";
}

export type GqlTransaction =
Expand Down
4 changes: 2 additions & 2 deletions mobile-frontend/src/movements/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { gqlMovementMapper } from "./mappers";
import { Movement } from "./types";

export const useMovements = (
walletAddress: string
walletAddress: string,
): {
loading: boolean;
total?: number;
Expand All @@ -31,7 +31,7 @@ export const useMovements = (
if (res.data) {
const { movements } = res.data;
setMovements(
movements.edges.map((edge) => gqlMovementMapper(edge.node))
movements.edges.map((edge) => gqlMovementMapper(edge.node)),
);
}
} finally {
Expand Down
2 changes: 1 addition & 1 deletion mobile-frontend/src/movements/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./hooks";
export * from "./types";
export * from "./types";
Loading

0 comments on commit cd15fc1

Please sign in to comment.