Skip to content

Commit 89af306

Browse files
committed
add eslint to pre commit, add pre commit to test pipeline, lint
1 parent e0125bf commit 89af306

File tree

6 files changed

+58
-71
lines changed

6 files changed

+58
-71
lines changed

.github/workflows/ci.yaml

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,35 @@ jobs:
2525
with:
2626
python-version: "3.12"
2727

28-
- name: Install Next.js dependencies
28+
- name: Install dependencies
2929
run: |
30-
cd nextjs
31-
npm ci
30+
pip install pre-commit
31+
cd nextjs && npm ci
3232
33-
- name: Run ESLint
34-
run: |
35-
cd nextjs
36-
npm run lint
33+
- name: Run pre-commit
34+
run: pre-commit run --all-files
35+
36+
template-checks:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Python
43+
uses: actions/setup-python@v5
44+
with:
45+
python-version: "3.12"
3746

3847
- name: Verify setup script syntax
39-
run: |
40-
python -m py_compile setup_project.py
48+
run: python -m py_compile setup_project.py
4149

4250
- name: Verify template config is valid JSON
43-
run: |
44-
python -c "import json; json.load(open('template.config.json'))"
51+
run: python -c "import json; json.load(open('template.config.json'))"
4552

46-
- name: Check for template variable consistency
53+
- name: Check template variable consistency
4754
run: |
48-
echo "Checking that all template variables in code have mappings in setup script..."
49-
# Extract variables from setup_project.py
55+
echo "Checking template variables..."
5056
grep -oP '"\{\{[A-Z_]+\}\}"' setup_project.py | sort -u > /tmp/defined_vars.txt
51-
# Extract variables used in codebase (excluding setup files and templates dir for this check)
5257
grep -roh '\{\{[A-Z_]*\}\}' --include="*.py" --include="*.yaml" --include="*.ts" --include="*.tsx" --include="*.conf" --include="Makefile" . 2>/dev/null | \
53-
grep -v "\.State\." | \
54-
sort -u | \
55-
sed 's/^/"/;s/$/"/' > /tmp/used_vars.txt || true
56-
# Compare (used vars should be subset of defined vars)
57-
echo "Defined variables:"
58-
cat /tmp/defined_vars.txt
59-
echo ""
60-
echo "Used variables:"
61-
cat /tmp/used_vars.txt
58+
grep -v "\.State\." | sort -u | sed 's/^/"/;s/$/"/' > /tmp/used_vars.txt || true
59+
echo "Defined: $(cat /tmp/defined_vars.txt | wc -l) | Used: $(cat /tmp/used_vars.txt | wc -l)"

.github/workflows/pre-commit.yaml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ repos:
1919
types: [file]
2020
files: '\.(js|jsx|ts|tsx|json|yaml|md|css|html)$'
2121

22+
# eslint for nextjs
23+
- repo: local
24+
hooks:
25+
- id: eslint
26+
name: eslint
27+
entry: bash -c 'cd nextjs && npm run lint'
28+
language: system
29+
files: '\.(js|jsx|ts|tsx)$'
30+
pass_filenames: false
31+
2232
# python linter and formatter
2333
- repo: https://github.com/psf/black
2434
rev: 25.1.0

nextjs/src/app/(auth)/register/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useRouter, useSearchParams } from "next/navigation";
1414
import { useState } from "react";
1515

1616
export default function RegisterPage() {
17-
const { loading, error, clearError, refreshUser } = useAuth();
17+
const { error, clearError, refreshUser } = useAuth();
1818
const [email, setEmail] = useState("");
1919
const [password, setPassword] = useState("");
2020
const [passwordConfirm, setPasswordConfirm] = useState("");

nextjs/src/app/(dashboard)/dashboard/settings/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { useRouter } from "next/navigation";
2323
import { useState } from "react";
2424

2525
export default function SettingsPage() {
26-
const { user, refreshUser } = useAuth();
26+
const { user } = useAuth();
2727
const router = useRouter();
2828

2929
// Change password state

templates/workflows/test.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,30 @@ on:
1111
- develop
1212

1313
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "lts/hydrogen"
24+
25+
- name: Set up Python
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: "3.12"
29+
30+
- name: Install dependencies
31+
run: |
32+
pip install pre-commit
33+
cd nextjs && npm ci
34+
35+
- name: Run pre-commit
36+
run: pre-commit run --all-files
37+
1438
test:
1539
runs-on: ubuntu-latest
1640
steps:

0 commit comments

Comments
 (0)