Skip to content

Commit 8c9df51

Browse files
committed
feat: boring setups stuff
1 parent 735f9d4 commit 8c9df51

File tree

12 files changed

+4398
-1
lines changed

12 files changed

+4398
-1
lines changed

.env.example

Whitespace-only changes.

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Code Quality
2+
on: [push, pull_request]
3+
4+
jobs:
5+
lint:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
10+
- uses: actions/setup-node@v4
11+
with:
12+
node-version: 22
13+
cache: 'npm'
14+
15+
- run: npm ci
16+
17+
# ✅ Type check
18+
- run: npx tsc --noEmit
19+
20+
# ✅ Linting
21+
- run: npm run lint
22+
23+
# ✅ Prettier formatting check
24+
- run: npm run format -- --check .

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Node
2+
node_modules/
3+
dist/
4+
.env
5+
.env.local
6+
coverage/
7+
# Logs
8+
*.log
9+
npm-debug.log*
10+
# IDE
11+
.vscode/
12+
.idea/
13+
.DS_Store

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
npx lint-staged

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v22.0.0

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100
6+
}

README.md

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,167 @@
1-
# bobatalks
1+
# 🌸 BobaTalks Flowers Bot
2+
3+
A UW Blueprint x BobaTalks project that automates the **Flowers** tradition — letting students celebrate wins through a Discord bot and displaying approved posts on the BobaTalks website.
4+
5+
---
6+
7+
## 🧭 Overview
8+
9+
This project includes:
10+
11+
- **Discord Bot** – Collects "Flowers" submissions and handles moderation.
12+
- **Web App (Next.js)** – Displays approved Flowers on the BobaTalks site.
13+
- **Database (Supabase)** – Stores submissions and approvals securely.
14+
- **CI/CD** – Enforces code quality and consistency through GitHub Actions.
15+
16+
---
17+
18+
## ⚙️ Tech Stack
19+
20+
| Layer | Technology |
21+
| ------------ | ----------------------------------------------- |
22+
| Bot | Node.js + TypeScript + discord.js |
23+
| Web | Next.js 15 + Tailwind CSS |
24+
| Database | Supabase (PostgreSQL) |
25+
| CI/CD | GitHub Actions |
26+
| Code Quality | ESLint, Prettier, Husky, TypeScript strict mode |
27+
28+
---
29+
30+
## ✅ Local Setup Checklist
31+
32+
| Check | Command | Expected Result |
33+
| ---------------------- | ----------------------------------- | ----------------------------------- |
34+
| Node.js installed | `node -v` | ≥ 22.x |
35+
| npm installed | `npm -v` | shows a version number |
36+
| Dependencies installed | `npm ci` | completes without errors |
37+
| Linting passes | `npm run lint` | no errors or warnings |
38+
| Formatting passes | `npm run format -- --check .` | no changed files |
39+
| TypeScript clean | `npx tsc --noEmit` | no type errors |
40+
| Precommit works | `git commit -m "test: husky check"` | runs precommit checks automatically |
41+
42+
---
43+
44+
## 🧑‍💻 Getting Started
45+
46+
### 1️⃣ Clone the repository
47+
48+
```bash
49+
git clone https://github.com/uwblueprint/bobatalks-flowers.git
50+
cd bobatalks-flowers
51+
```
52+
53+
### 2️⃣ Install dependencies
54+
55+
```bash
56+
npm ci
57+
```
58+
59+
### 3️⃣ Set up environment variables
60+
61+
```bash
62+
cp .env.example .env
63+
```
64+
65+
_Fill in the placeholder values_
66+
67+
### 4️⃣ Run code quality checks locally
68+
69+
```bash
70+
npm run lint
71+
npm run format -- --check .
72+
npx tsc --noEmit
73+
```
74+
75+
If these three pass, your setup is perfect ✅.
76+
77+
---
78+
79+
## 🥪 Verifying Pre-commit Hooks
80+
81+
We use **Husky** + **lint-staged** to enforce formatting before commits.
82+
83+
Test it:
84+
85+
```bash
86+
git add .
87+
git commit -m "test: check husky hook"
88+
```
89+
90+
Expected: Prettier and ESLint run automatically before committing.
91+
92+
If hooks don’t run:
93+
94+
```bash
95+
npx husky install
96+
```
97+
98+
---
99+
100+
## 🧱 Continuous Integration (CI)
101+
102+
Every push and PR triggers **GitHub Actions** to run:
103+
104+
- ✅ Linting (`npm run lint`)
105+
- ✅ Formatting check (`npm run format -- --check .`)
106+
- ✅ TypeScript check (`npx tsc --noEmit`)
107+
108+
PRs can’t be merged unless these checks pass.
109+
110+
To simulate CI locally:
111+
112+
```bash
113+
npm ci
114+
npm run lint
115+
npm run format -- --check .
116+
npx tsc --noEmit
117+
```
118+
119+
---
120+
121+
## 🔧 Common Fix Commands
122+
123+
| Issue | Fix |
124+
| ---------------------------- | --------------------------------------------------- |
125+
| ESLint errors | `npm run lint --fix` |
126+
| Prettier issues | `npm run format` |
127+
| Husky hook not running | `npx husky install` |
128+
| TypeScript “No inputs found” | Create a `src/` folder or place `.ts` files at root |
129+
130+
---
131+
132+
## 👩‍💻 Contributing Guidelines
133+
134+
1. Create a new branch:
135+
136+
```bash
137+
git checkout -b feature/your-feature-name
138+
```
139+
140+
2. Commit using [Conventional Commits](https://www.conventionalcommits.org/):
141+
- `feat:` → new feature
142+
- `fix:` → bug fix
143+
- `chore:` → tooling / configs
144+
145+
3. Push and open a PR — CI must pass before merging.
146+
147+
---
148+
149+
## 🧮 Scripts Summary
150+
151+
| Command | Description |
152+
| ----------------------------- | ------------------------------------- |
153+
| `npm run lint` | Run ESLint |
154+
| `npm run format` | Format with Prettier |
155+
| `npm run format -- --check .` | Check Prettier formatting (read-only) |
156+
| `npx tsc --noEmit` | Type-check only |
157+
| `npx husky install` | Reinstall Git hooks |
158+
159+
---
160+
161+
> 💡 _Run this one-liner to confirm everything works:_
162+
>
163+
> ```bash
164+
> npm run lint && npm run format -- --check . && npx tsc --noEmit
165+
> ```
166+
>
167+
> ✅ If you see no output — congrats, your setup is perfect!

eslint.config.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// eslint.config.js
2+
import js from '@eslint/js';
3+
import importPlugin from 'eslint-plugin-import';
4+
import prettier from 'eslint-plugin-prettier';
5+
import sonarjs from 'eslint-plugin-sonarjs';
6+
import unusedImports from 'eslint-plugin-unused-imports';
7+
import tseslint from 'typescript-eslint';
8+
9+
export default tseslint.config(js.configs.recommended, ...tseslint.configs.recommended, {
10+
ignores: ['node_modules', 'dist', 'build'],
11+
files: ['**/*.{js,ts,tsx}'],
12+
languageOptions: {
13+
parser: tseslint.parser,
14+
ecmaVersion: 2022,
15+
sourceType: 'module',
16+
},
17+
plugins: {
18+
'@typescript-eslint': tseslint.plugin,
19+
prettier,
20+
import: importPlugin,
21+
'unused-imports': unusedImports,
22+
sonarjs,
23+
},
24+
rules: {
25+
// 🧹 Prettier integration
26+
'prettier/prettier': ['error', { endOfLine: 'auto' }],
27+
28+
// 🚫 Unused imports / variables
29+
'unused-imports/no-unused-imports': 'error',
30+
'unused-imports/no-unused-vars': [
31+
'error',
32+
{
33+
vars: 'all',
34+
varsIgnorePattern: '^_',
35+
args: 'after-used',
36+
argsIgnorePattern: '^_',
37+
},
38+
],
39+
40+
// 📦 Import hygiene
41+
'import/order': [
42+
'error',
43+
{
44+
groups: ['builtin', 'external', 'internal', ['parent', 'sibling', 'index']],
45+
'newlines-between': 'always',
46+
alphabetize: { order: 'asc', caseInsensitive: true },
47+
},
48+
],
49+
'import/no-duplicates': 'error',
50+
'import/no-cycle': 'warn',
51+
52+
// 🧠 Logic & readability (SonarJS)
53+
'sonarjs/cognitive-complexity': ['warn', 15],
54+
'sonarjs/no-duplicate-string': 'warn',
55+
'sonarjs/no-identical-functions': 'warn',
56+
57+
// ⚙️ TS-specific tuning
58+
'@typescript-eslint/no-explicit-any': 'warn',
59+
'@typescript-eslint/no-unused-vars': 'off', // handled by unused-imports
60+
},
61+
});

0 commit comments

Comments
 (0)