Skip to content

Commit

Permalink
feat(sdk): biome setup for lint and formatting and precommit hook for…
Browse files Browse the repository at this point in the history
… SDK
  • Loading branch information
ga-reth committed Dec 2, 2024
1 parent 5810fed commit e40ff39
Show file tree
Hide file tree
Showing 6 changed files with 1,053 additions and 890 deletions.
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,11 @@ repos:
entry: .pre-commit/run_solhint.sh
types: [ file, solidity ]
require_serial: true

- id: run-sdk-checks
name: run-sdk-checks
language: script
entry: .pre-commit/run_sdk_checks.sh
files: ^sdk/.*\.(ts|tsx)$
types: [ file, ts ]
pass_filenames: true
30 changes: 30 additions & 0 deletions .pre-commit/run_sdk_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# get dir
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# nav to sdk dir
SDK_DIR="$SCRIPT_DIR/../sdk"

# when running pre-commit, files are passed as args
# when running git hook, find ourselves
if [ $# -eq 0 ]; then
TS_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep "^sdk.*\.\(ts\|tsx\)$" || true)
else
TS_FILES="$@"
fi

if [ -n "$TS_FILES" ]; then
echo "Running SDK checks..."
cd "$SDK_DIR"

# clean + build
echo "Building SDK..."
pnpm build:clean

# precommit checks (Biome)
echo "Running SDK checks..."
pnpm precommit

echo "SDK checks completed..."
fi
35 changes: 35 additions & 0 deletions sdk/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist", "tsconfig.json", "tsconfig.*.json"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"formatWithErrors": false,
"indentWidth": 2,
"lineWidth": 80
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"trailingCommas": "all",
"semicolons": "asNeeded"
}
}
}
9 changes: 4 additions & 5 deletions sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
"scripts": {
"clean": "rm -rf dist",
"build": "tsc -p tsconfig.build.json",
"build:clean": "pnpm clean && pnpm build"
"build:clean": "pnpm clean && pnpm build",
"precommit": "biome check --write"
},
"files": [
"src/*",
"dist/*"
],
"files": ["src/*", "dist/*"],
"engines": {
"node": "22.x"
},
"devDependencies": {
"@biomejs/biome": "1.9.4",
"typescript": "5.7.2"
}
}
91 changes: 91 additions & 0 deletions sdk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e40ff39

Please sign in to comment.