Add ESLint and Prettier configuration across monorepo

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-10-24 12:35:32 +00:00
parent 367ca51005
commit f50ddb0512
11 changed files with 5657 additions and 8 deletions

39
.eslintrc.json Normal file
View File

@@ -0,0 +1,39 @@
{
"root": true,
"env": {
"node": true,
"es2022": true
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
"sourceType": "module",
"project": "./tsconfig.json"
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
},
"ignorePatterns": [
"node_modules/",
"dist/",
"cache/",
"artifacts/",
"typechain-types/",
"coverage/",
".nyc_output/",
"web/"
]
}

3
.gitignore vendored
View File

@@ -54,6 +54,9 @@ lerna-debug.log*
.vscode/
.idea/
# Linting
.eslintcache
# Next.js (applies to any package path)
.next/
out/

14
.prettierignore Normal file
View File

@@ -0,0 +1,14 @@
node_modules/
dist/
cache/
artifacts/
typechain-types/
coverage/
.nyc_output/
.next/
out/
.vercel/
package-lock.json
*.log
*.db
*.sqlite

10
.prettierrc.json Normal file
View File

@@ -0,0 +1,10 @@
{
"semi": true,
"trailingComma": "es5",
"singleQuote": false,
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"arrowParens": "always",
"endOfLine": "lf"
}

View File

@@ -34,6 +34,43 @@ This project implements comprehensive input validation and sanitization to preve
All API endpoints validate inputs against strict schemas with detailed error messages. See [docs/VALIDATION.md](./docs/VALIDATION.md) for complete documentation.
## Code Quality
This project uses ESLint and Prettier to maintain consistent code style and catch common issues:
- **ESLint**: Configured for both Node.js/Hardhat scripts (TypeScript) and Next.js app
- **Prettier**: Shared formatting config across the monorepo
### Linting & Formatting
```bash
# Run linters across the entire monorepo
npm run lint
# Fix auto-fixable linting issues
npm run lint:fix
# Format all code with Prettier
npm run format
# Check if code is properly formatted
npm run format:check
```
For the web package specifically:
```bash
cd web
npm run lint # ESLint for Next.js app
npm run lint:fix # Auto-fix issues
npm run format # Format with Prettier
```
Configuration files:
- Root ESLint: `.eslintrc.json` (TypeScript + Node.js)
- Web ESLint: `web/.eslintrc.json` (Next.js)
- Prettier: `.prettierrc.json` (shared)
## Setup
1. Install deps
@@ -69,10 +106,17 @@ If you plan to use the included web UI (`web/`), set:
- `bind:youtube` bind a YouTube videoId to a previously registered master file
- `verify:youtube` verify a YouTube URL/ID via on-chain binding + manifest
- `start:api` start the Express API server (default port 3001)
- `lint` run ESLint on both root and web packages
- `lint:fix` automatically fix ESLint issues where possible
- `format` format all code with Prettier
- `format:check` check if code is formatted correctly
- Web: from `web/` workspace
- `npm run dev` start Next.js dev server on :3000
- `npm run build && npm start` production build/start
- `npm run prisma:generate` generate Prisma Client for web (uses root schema)
- `npm run lint` run ESLint on web package
- `npm run lint:fix` automatically fix ESLint issues in web package
- `npm run format` format web code with Prettier
## Quickstart

1050
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,15 @@
"db:generate": "prisma generate",
"db:migrate": "prisma migrate dev --name init",
"db:studio": "prisma studio",
"db:verify-indexes": "ts-node scripts/verify-indexes.ts"
"db:verify-indexes": "ts-node scripts/verify-indexes.ts",
"lint": "npm run lint:root && npm run lint:web",
"lint:root": "eslint . --ext .ts,.js",
"lint:web": "cd web && npm run lint",
"lint:fix": "npm run lint:fix:root && npm run lint:fix:web",
"lint:fix:root": "eslint . --ext .ts,.js --fix",
"lint:fix:web": "cd web && npm run lint:fix",
"format": "prettier --write \"**/*.{ts,js,json,md}\"",
"format:check": "prettier --check \"**/*.{ts,js,json,md}\""
},
"devDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
@@ -44,12 +52,18 @@
"@types/multer": "^1.4.12",
"@types/node": "^20.12.12",
"@types/sinon": "^17.0.4",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.5.0",
"dotenv": "^16.4.5",
"eslint": "^8.57.1",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"ethers": "^6.13.3",
"hardhat": "^2.22.7",
"hardhat-gas-reporter": "^1.0.10",
"nyc": "^17.1.0",
"prettier": "^3.6.2",
"prisma": "^6.17.0",
"sinon": "^21.0.0",
"solidity-coverage": "^0.8.16",

8
web/.eslintrc.json Normal file
View File

@@ -0,0 +1,8 @@
{
"root": true,
"extends": [
"next/core-web-vitals",
"prettier"
],
"rules": {}
}

View File

@@ -11,6 +11,13 @@ const nextConfig = {
turbopack: {
root: __dirname,
},
// During build, lint but don't fail on pre-existing warnings/errors
// This allows gradual ESLint adoption while still catching new issues in CI
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors. Fix errors and remove this option.
ignoreDuringBuilds: true,
},
};
export default nextConfig;

4465
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,10 @@
"dev": "next dev -p 3000",
"build": "next build",
"start": "next start -p 3000",
"lint": "next lint",
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
"lint:fix": "eslint . --ext .ts,.tsx,.js,.jsx --fix",
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md,css}\"",
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md,css}\"",
"prisma:generate": "prisma generate --schema ../prisma/schema.prisma --generator client-web",
"postinstall": "prisma generate --schema ../prisma/schema.prisma --generator client-web"
},
@@ -26,6 +29,10 @@
"@types/qrcode": "^1.5.5",
"@types/react": "18.2.74",
"@types/react-dom": "18.2.25",
"eslint": "^8.57.1",
"eslint-config-next": "^15.5.6",
"eslint-config-prettier": "^10.1.8",
"prettier": "^3.6.2",
"prisma": "^6.17.0",
"typescript": "5.6.3"
}