Skip to content

Commit

Permalink
Merge pull request #155 from SmartInvoiceXYZ/154-dapp-refactor-23
Browse files Browse the repository at this point in the history
dApp Refactor '23
  • Loading branch information
scottrepreneur authored Mar 14, 2024
2 parents 3adcca0 + 4810580 commit 5e96d87
Show file tree
Hide file tree
Showing 323 changed files with 55,980 additions and 41,403 deletions.
68 changes: 57 additions & 11 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,82 @@
"node": true,
"es6": true
},
"extends": ["airbnb", "prettier", "plugin:mocha/recommended"],
"extends": [
"airbnb",
"plugin:mocha/recommended",
"plugin:prettier/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 8,
"ecmaVersion": 2023,
"sourceType": "module"
},
"plugins": ["simple-import-sort", "mocha"],
"settings": {},
"plugins": [
"prettier",
"simple-import-sort",
"react",
"mocha",
"react-hooks"
],
"rules": {
// defaults
"no-console": "warn",
"no-unused-vars": "off",
// Prefer non-default exports
"import/no-default-export": "error",
"import/prefer-default-export": "off",

// Auto-sort imports
"sort-imports": "off",
"import/order": "off",
"simple-import-sort/imports": "off",
"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",

// Allow props spreading
"react/jsx-props-no-spreading": "off",
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],

// disable prop-types
"react/prop-types": "off",
// REACT
"react/prop-types": "off", // disable prop-types
"react/require-default-props": "off", // disable require default props
"react/react-in-jsx-scope": "off", // react in jsx scope
"react/jsx-filename-extension": [2, { "extensions": [".ts", ".tsx"] }],

// TS
"@typescript-eslint/no-explicit-any": "warn", // disable explicit any
"@typescript-eslint/no-unused-vars": ["warn"], // ts no unused vars

// disable form label
"jsx-a11y/label-has-associated-control": "off"
"jsx-a11y/label-has-associated-control": "off",

// leverage prettier
"prettier/prettier": "error"
},
"ignorePatterns": [
"**/node_modules/*",
"dist/*",
"tmp/*",
".next",
"packages/subgraph/**",
"packages/contracts/test/*",
"packages/subgraph/subgraph.template.yaml"
]
],
"settings": {
"import/resolver": {
"typescript": {
"project": ["tsconfig.base.json", "packages/**/tsconfig.json"]
},
"node": {
"project": ["tsconfig.base.json", "packages/**/tsconfig.json"]
}
}
}
}
54 changes: 54 additions & 0 deletions .github/workflows/dapp-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: DApp CI

on:
pull_request:
branches:
- main
- develop
paths:
- packages/dapp/**
push:
branches:
- main
- develop
paths:
- packages/dapp/**

jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0

- name: Set up node using nvm
uses: dcodeIO/setup-node-nvm@v5
with:
node-version: 18

# - name: "Copy config"
# run: |
# mv ./evm/.env.github ./evm/.env
# echo "::debug::$(less .env)"

- name: Install the dependencies
run: pnpm install

- name: Lint the code
run: pnpm dapp:lint

- name: Add lint summary
run: |
echo "## Lint results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
- name: Test the code and generate the coverage report
run: pnpm dapp:test

- name: Add test summary
run: |
echo "## Test results" >> $GITHUB_STEP_SUMMARY
echo "✅ Passed" >> $GITHUB_STEP_SUMMARY
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ packages/subgraph/src/types
# firebase tmp
.firebase/

/packages/contracts/flat/
/packages/dapp/.next/
**/flat/
**/.next/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/gallium
lts/iron
73 changes: 72 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,72 @@
packages/subgraph/subgraph.template.yaml
# dependencies
node_modules
.pnp
.pnp.js

# testing
coverage
lib-cov
coverage.json

# production
build
build/Release
generated
cache

# Generated files
.docusaurus
.cache-loader

# environment variables
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.env

# logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# swap
*.sw[a-z]

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# optional npm cache directory
.npm

# yarn Integrity file
.yarn-integrity

# editor
.history
.vscode

# misc
.DS_Store

# subgraph
packages/subgraph/src/types

# yarn version
.yarn*

# firebase tmp
.firebase/

/packages/contracts/flat/
/packages/dapp/.next/

# next.js
.next
packages/subgraph/subgraph.template.yaml
4 changes: 3 additions & 1 deletion .sample-env
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#### CONTRACTS

INFURA_PROJECT_ID=
PRIVATE_KEY=
ETHERSCAN_API_KEY=
COINMARKETCAP_API_KEY=
CURRENCY=
POLYGONSCAN_API_KEY=
POLYGONSCAN_API_KEY=
9 changes: 0 additions & 9 deletions config-overrides.js

This file was deleted.

34 changes: 34 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable import/no-default-export */
import type { Config } from 'jest';
import nextJest from 'next/jest.js';

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './packages/dapp',
});

const config: Config = {
coverageProvider: 'v8',
projects: [
{
preset: 'ts-jest',
rootDir: './packages/dapp',
setupFilesAfterEnv: ['<rootDir>/test/setupTests.ts'],
testEnvironment: 'jsdom',
testMatch: ['<rootDir>/test/**/*.test.(ts|tsx|js|jsx)'],
transform: {
'^.+\\.(js|jsx|ts|tsx)$': [
'ts-jest',
{
tsconfig: '<rootDir>/tsconfig.test.json',
},
],
},
transformIgnorePatterns: ['node_modules/(?!(viem|isows)/)'],
},
],
verbose: true,
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config);
62 changes: 37 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,29 @@
"ethereum",
"smart-invoice",
"escrow",
"workspaces",
"yarn"
"workspaces"
],
"private": true,
"scripts": {
"subgraph:auth": "yarn workspace @smart-invoice/subgraph auth",
"subgraph:codegen": "yarn workspace @smart-invoice/subgraph codegen",
"subgraph:build": "yarn workspace @smart-invoice/subgraph build",
"subgraph:deploy-kovan": "yarn workspace @smart-invoice/subgraph deploy-kovan",
"subgraph:deploy-rinkeby": "yarn workspace @smart-invoice/subgraph deploy-rinkeby",
"dapp:dev": "yarn workspace @smart-invoice/dapp dev",
"dapp:start": "yarn workspace @smart-invoice/dapp start",
"dapp:build": "yarn workspace @smart-invoice/dapp build",
"docs:start": "yarn workspace @smart-invoice/docs start",
"docs:build": "yarn workspace @smart-invoice/docs build",
"contracts:build": "yarn workspace @smart-invoice/contracts build",
"contracts:lint": "yarn workspace @smart-invoice/contracts lint",
"contracts:test": "yarn workspace @smart-invoice/contracts test",
"contracts:deploy-factory": "yarn workspace @smart-invoice/contracts deploy-factory",
"lint": "eslint --ignore-path .gitignore \"./packages/**/*.{ts,tsx,js,jsx}\"",
"format": "prettier --ignore-path .gitignore --write \"{*,**/*}.{ts,tsx,js,jsx,json,md,sol}\"",
"subgraph:auth": "pnpm --filter @smart-invoice/subgraph auth",
"subgraph:codegen": "pnpm --filter @smart-invoice/subgraph codegen",
"subgraph:build": "pnpm --filter @smart-invoice/subgraph build",
"subgraph:deploy-kovan": "pnpm --filter @smart-invoice/subgraph deploy-kovan",
"subgraph:deploy-rinkeby": "pnpm --filter @smart-invoice/subgraph deploy-rinkeby",
"dapp:build": "pnpm --filter @smart-invoice/dapp build",
"dapp:dev": "pnpm --filter @smart-invoice/dapp dev",
"dapp:start": "pnpm --filter @smart-invoice/dapp start",
"dapp:test": "pnpm --filter @smart-invoice/dapp test",
"dapp:lint": "pnpm --filter @smart-invoice/dapp lint",
"dapp:format": "pnpm --filter @smart-invoice/dapp format",
"docs:start": "pnpm --filter @smart-invoice/docs start",
"docs:build": "pnpm --filter @smart-invoice/docs build",
"contracts:build": "pnpm --filter @smart-invoice/contracts build",
"contracts:lint": "pnpm --filter @smart-invoice/contracts lint",
"contracts:test": "pnpm --filter @smart-invoice/contracts test",
"contracts:deploy-factory": "pnpm --filter @smart-invoice/contracts deploy-factory",
"lint": "eslint --ignore-path .prettierignore \"./packages/**/*.{ts,tsx,js,jsx}\"",
"format": "prettier --ignore-path .prettierignore --write \"{*,**/*}.{ts,tsx,js,jsx,json,md,sol}\"",
"prepare": "husky install"
},
"workspaces": {
Expand All @@ -45,25 +47,31 @@
"license": "MIT",
"devDependencies": {
"@babel/eslint-parser": "^7.23.3",
"@typescript-eslint/parser": "^6.7.0",
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.2",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.17.0",
"async-prompt": "^1.0.1",
"dotenv": "^8.2.0",
"eslint": "^8.51.0",
"dotenv": "^16.3.1",
"eslint": "^8.56.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-mocha": "^10.2.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"ethers": "^5.1.0",
"husky": "^6.0.0",
"it-all": "^1.0.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3",
"prettier-plugin-solidity": "^1.1.3",
"typescript": "^4.9.5"
"prettier": "^3.1.1",
"prettier-plugin-solidity": "^1.3.1",
"typescript": "^5.3.2"
},
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
Expand All @@ -73,5 +81,9 @@
"*.{json,md,sol}": [
"prettier --write"
]
},
"dependencies": {
"lodash": "^4.17.21",
"next": "14.0.1"
}
}
3 changes: 3 additions & 0 deletions packages/constants/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["../../.eslintrc.json"]
}
Loading

0 comments on commit 5e96d87

Please sign in to comment.