Skip to content

Commit

Permalink
Implement Linting, TS Config + CI (#48)
Browse files Browse the repository at this point in the history
* Add trade page w/ new layout

* Add recent swaps to explorer page

* Add swaps component

* Add PairSelector component

* Setup eslint, prettier + tsconfig

* Cleanup backup files

* Add ci workflow

* Add pnpm version

* Remove unknown option for ci.yml

* Fix linting issues

* Add disable rules for older files

* Cleanup files

* Fix lint warnings for now

* Fix strict lints

---------

Co-authored-by: Lucas Meier <lucas@cronokirby.com>
  • Loading branch information
JasonMHasperhoven and cronokirby authored Sep 10, 2024
1 parent 11df3ae commit 7393891
Show file tree
Hide file tree
Showing 69 changed files with 1,854 additions and 679 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: CI
on:
workflow_call:
workflow_dispatch:
pull_request:
push:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- id: lint
uses: buildjet/cache@v4
with:
path: .next
key: $${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-lint
restore-keys: $${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
- uses: pnpm/action-setup@v4
- uses: buildjet/setup-node@v4
with:
node-version: "18"
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm lint:strict

build:
name: Build
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v4
- id: build
uses: buildjet/cache@v4
with:
path: .next
key: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-built
restore-keys: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
- uses: pnpm/action-setup@v4
- uses: buildjet/setup-node@v4
with:
node-version: "18"
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm build

# test:
# name: test
# runs-on: buildjet-4vcpu-ubuntu-2204
# steps:
# - uses: actions/checkout@v4
# - id: tested
# uses: buildjet/cache@v4
# with:
# path: .next
# key: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-test
# restore-keys: ${{ hashFiles('pnpm-lock.yaml') }}-${{ github.ref }}-${{ github.sha }}-compiled
# - uses: pnpm/action-setup@v4
# - uses: buildjet/setup-node@v4
# with:
# node-version: "22"
# cache: "pnpm"
# - run: pnpm install --frozen-lockfile
# - run: pnpm test
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
/build

# misc
.vscode
.idea
.DS_Store
.vscode

Expand All @@ -36,3 +38,5 @@ yarn-error.log*
# webpack
/dist
.vercel

tsconfig.tsbuildinfo
31 changes: 31 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import eslintConfig from 'configs/eslint';
import { FlatCompat } from '@eslint/eslintrc';
import { fileURLToPath } from 'url';
import path from 'path';

// mimic CommonJS variables -- not needed if using CommonJS
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

const compat = new FlatCompat({
baseDirectory: __dirname,
});

const excludePlugins = eslintConfig.flatMap(config => Object.keys(config.plugins || {}));

export default [
...compat
.extends('next/core-web-vitals')
.filter(config =>
Object.keys(config.plugins || {}).every(plugin => !excludePlugins.includes(plugin)),
),

...eslintConfig.filter(config => config.name !== 'custom:turbo-config'),

{
name: 'ignore-old-ts-files',
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
},
},
];
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
8 changes: 7 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ const nextConfig = {
return config;
},
output: "standalone",
eslint: {
ignoreDuringBuilds: true,
},
typescript: {
ignoreBuildErrors: true,
},
};

export default nextConfig;
export default nextConfig;
19 changes: 17 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
"engines": {
"node": ">=18"
},
"packageManager": "pnpm@9.7.0+sha512.dc09430156b427f5ecfc79888899e1c39d2d690f004be70e05230b72cb173d96839587545d09429b55ac3c429c801b4dc3c0e002f653830a420fa2dd4e3cf9cf",
"scripts": {
"build": "next build",
"dev": "next dev",
"start": "next start",
"lint": "next lint"
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint:strict": "tsc --noEmit && pnpm lint --max-warnings 0",
"lint:strict2": "tsc --noEmit && pnpm lint --max-warnings 0"
},
"dependencies": {
"@bufbuild/protobuf": "^1.10.0",
Expand All @@ -29,6 +33,8 @@
"@penumbra-zone/wasm": "^26.2.0",
"@radix-ui/react-icons": "^1.3.0",
"@styled-icons/octicons": "^10.47.0",
"@tsconfig/strictest": "^2.0.5",
"@tsconfig/vite-react": "^3.0.2",
"@vercel/analytics": "^1.3.1",
"@vercel/speed-insights": "^1.0.12",
"bech32": "^2.0.0",
Expand All @@ -38,6 +44,8 @@
"chartjs-chart-financial": "^0.2.1",
"chartjs-plugin-annotation": "^3.0.1",
"chartjs-plugin-zoom": "^2.0.1",
"configs": "https://github.com/prax-wallet/configs.git#main",
"date-fns": "^3.6.0",
"echarts": "^5.5.1",
"echarts-for-react": "^3.0.2",
"framer-motion": "^11.3.31",
Expand All @@ -59,15 +67,22 @@
"@babel/preset-env": "^7.25.4",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@chakra-ui/react-types": "^2.0.6",
"@eslint/js": "^9.10.0",
"@types/date-fns": "^2.6.0",
"@types/lodash": "^4.17.7",
"@types/node": "^22.5.4",
"@types/pg": "^8.11.8",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/react-outside-click-handler": "^1.3.3",
"babel-loader": "^9.1.3",
"eslint": "8.57.0",
"eslint-config-next": "14.2.3",
"eslint-plugin-react": "^7.35.2",
"globals": "^15.9.0",
"ts-loader": "^9.5.1",
"typescript": "^5.5.4"
"typescript": "^5.5.4",
"typescript-eslint": "^8.4.0"
}
}
Loading

0 comments on commit 7393891

Please sign in to comment.