Skip to content

Commit 30bcbae

Browse files
authored
ci: adds lint staged workflow, js ci actions (#2)
Adds lint staged and CI workflows, including running Biome to lint net new TypeScript and JavaScript files and TSC to run type checking on TypeScript files being committed. Also adds tsconfig.json with appropriate type information.
1 parent d1aff80 commit 30bcbae

File tree

6 files changed

+445
-19
lines changed

6 files changed

+445
-19
lines changed

.github/workflows/js-ci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: JavaScript CI
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- '**/*.ts'
9+
- '**/*.js'
10+
push:
11+
branches:
12+
- main
13+
paths:
14+
- '**/*.ts'
15+
- '**/*.js'
16+
17+
jobs:
18+
lint-ts:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v4
25+
with:
26+
version: 10.6.5
27+
run_install: true
28+
- name: Install Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: 22
32+
cache: 'pnpm'
33+
- name: Check Types
34+
run: pnpm lint:ts
35+
lint-js:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Checkout Repository
39+
uses: actions/checkout@v4
40+
- name: Setup Biome
41+
uses: biomejs/setup-biome@v2
42+
with:
43+
version: 1.9.4
44+
- name: Biome Check
45+
run: biome ci --formatter-enabled=false --changed
46+

.husky/pre-commit

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# Check if the current branch is main or in a detached state
4+
branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD)
5+
6+
if [[ "$branch" == "main" ]]; then
7+
echo "You are on the main branch. Committing directly to main is not allowed."
8+
exit 1
9+
fi
10+
11+
pnpm lint-staged

biome.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",
6-
"useIgnoreFile": false
6+
"useIgnoreFile": false,
7+
"defaultBranch": "main"
78
},
89
"files": {
910
"ignoreUnknown": false,
10-
"ignore": ["node_modules", "dist"]
11+
"include": ["src/**/*"]
1112
},
1213
"formatter": {
1314
"enabled": true,

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jacobwolf/gitops-secrets",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Easily and securely inject environment variable secrets—no matter the size—into any JavaScript runtime.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -9,11 +9,16 @@
99
"access": "public"
1010
},
1111
"scripts": {
12-
"lint": "biome check --write .",
12+
"lint:js": "biome check --write .",
13+
"lint:ts": "tsc --noEmit --pretty",
1314
"format": "biome format --write .",
1415
"build": "tsup",
1516
"test": "vitest",
16-
"prepublishOnly": "pnpm build"
17+
"prepublishOnly": "pnpm build",
18+
"prepare": "husky"
19+
},
20+
"lint-staged": {
21+
"*.{js,ts}": ["pnpm lint:js"]
1722
},
1823
"repository": {
1924
"type": "git",
@@ -25,6 +30,8 @@
2530
"packageManager": "pnpm@10.6.5",
2631
"devDependencies": {
2732
"@biomejs/biome": "1.9.4",
33+
"husky": "^9.1.7",
34+
"lint-staged": "^15.5.0",
2835
"tsup": "^8.4.0",
2936
"typescript": "^5.8.2",
3037
"vitest": "^3.0.9"

0 commit comments

Comments
 (0)