Skip to content

Commit dc13ec5

Browse files
authored
chore: quality-tightening (oxfmt + drop prettier/eslint + tsgo + husky self-heal) (#95)
* chore: quality-tightening (oxfmt + drop prettier/eslint + tsgo + husky self-heal) This repo was already partially migrated (had oxlint, husky 9, lint-staged, vitest). Finishes the alignment with the rest of the rollout: - prettier (root) + prettier (functions/) -> oxfmt across the workspace - functions/ workspace eslint + @typescript-eslint/* + jest -> dropped entirely; the workspace now uses the root oxlint via 'yarn lint'. - new: oxlint plugins extended to typescript + vitest + unicorn + oxc (was just baseline correctness rules) - new: tsgo --noEmit as default 'typecheck'; tsc kept as 'typecheck:tsc' fallback - husky 9: existing /sh/ hook + 'husky install' replaced with the standard scripts/ensure-husky.mjs self-heal pattern + lint-staged + gitleaks. Drops the broken 'exec >/dev/tty' redirect that fails in non-interactive shells. - npm 'shellcheck' package dropped (playbook trap #2: it's broken and corrupts actionlint output). mise.toml adds shellcheck plus actionlint and gitleaks as managed binaries. - CI: existing main.yml steps re-ordered (Format/Lint/Typecheck/ Test) and 'yarn format' (which writes) replaced with 'yarn format:check' (which doesn't). codecov-action v4.0.1 -> v5. oxlint config tunes: - typescript/no-extraneous-class off (the codebase uses static-only classes as namespaces, idiomatic in this repo) - no-await-in-loop off (Firestore migrations and rate-limited HTTP loops are single-threaded by design) 13 pre-existing typescript/no-explicit-any warnings remain (mostly in firebase-functions handler signatures and json deserialisation). Per playbook trap #22 the lint script drops --deny-warnings. Verified locally: lint 0/13, format clean, typecheck clean, test 7/7. * ci(versioning-backend): repair Firebase predeploy after lint migration The Test Deploy job runs 'firebase deploy --only functions:testFunction' which executes the firebase.json 'predeploy' hooks. The hook still called: - yarn workspace functions lint - yarn workspace functions test run Both broke after the migration: - The 'lint' script is now at the root only (functions/ no longer has its own lint command). - 'test run' was the jest CLI form ('jest run'); vitest's equivalent is 'vitest run' which we exposed as the 'test:run' workspace script. Predeploy hooks now invoke: - yarn lint (root oxlint over the workspace) - yarn workspace functions run test:run (vitest run, scoped to functions) - yarn workspace functions build (unchanged)
1 parent a2fcfe0 commit dc13ec5

17 files changed

Lines changed: 933 additions & 3959 deletions

.github/workflows/main.yml

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ jobs:
1414

1515
- name: Read Node version from mise.toml
1616
id: node
17-
run:
18-
echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
17+
run: echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
1918
"$GITHUB_OUTPUT"
2019

2120
- name: Install package manager (from package.json)
@@ -40,8 +39,7 @@ jobs:
4039
node_modules
4140
${{ steps.yarn-config.outputs.cacheFolder }}
4241
.yarn/install-state.gz
43-
key:
44-
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
42+
key: yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
4543
hashFiles('yarn.lock') }}
4644
restore-keys: |
4745
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-
@@ -53,20 +51,20 @@ jobs:
5351
case "$(yarn --version)" in 1.*) echo 'expected up-to-date yarn version'; exit 1 ;; esac
5452
yarn install --immutable
5553
56-
- name: run linter
57-
run: yarn lint
54+
- name: Format
55+
run: yarn format:check
5856

59-
- name: run format
60-
run: yarn format
57+
- name: Lint
58+
run: yarn lint
6159

62-
- name: run typecheck
60+
- name: Typecheck
6361
run: yarn typecheck
6462

65-
- name: run tests
63+
- name: Test
6664
run: yarn coverage
6765

6866
- name: Upload coverage reports to Codecov
69-
uses: codecov/codecov-action@v4.0.1
67+
uses: codecov/codecov-action@v5
7068
with:
7169
token: ${{ secrets.CODECOV_TOKEN }}
7270
slug: game-ci/versioning-backend
@@ -82,8 +80,7 @@ jobs:
8280

8381
- name: Read Node version from mise.toml
8482
id: node
85-
run:
86-
echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
83+
run: echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
8784
"$GITHUB_OUTPUT"
8885

8986
- name: Install package manager (from package.json)
@@ -108,8 +105,7 @@ jobs:
108105
node_modules
109106
${{ steps.yarn-config.outputs.cacheFolder }}
110107
.yarn/install-state.gz
111-
key:
112-
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
108+
key: yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
113109
hashFiles('yarn.lock') }}
114110
restore-keys: |
115111
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-
@@ -134,8 +130,7 @@ jobs:
134130

135131
- name: Read Node version from mise.toml
136132
id: node
137-
run:
138-
echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
133+
run: echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
139134
"$GITHUB_OUTPUT"
140135

141136
- name: Install package manager (from package.json)
@@ -160,8 +155,7 @@ jobs:
160155
node_modules
161156
${{ steps.yarn-config.outputs.cacheFolder }}
162157
.yarn/install-state.gz
163-
key:
164-
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
158+
key: yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
165159
hashFiles('yarn.lock') }}
166160
restore-keys: |
167161
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-
@@ -199,8 +193,7 @@ jobs:
199193

200194
- name: Read Node version from mise.toml
201195
id: node
202-
run:
203-
echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
196+
run: echo "version=$(grep -E '^node\s*=' mise.toml | sed -E 's/.*"([^"]+)".*/\1/')" >>
204197
"$GITHUB_OUTPUT"
205198

206199
- name: Install package manager (from package.json)
@@ -225,8 +218,7 @@ jobs:
225218
node_modules
226219
${{ steps.yarn-config.outputs.cacheFolder }}
227220
.yarn/install-state.gz
228-
key:
229-
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
221+
key: yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-${{
230222
hashFiles('yarn.lock') }}
231223
restore-keys: |
232224
yarn-${{ runner.os }}-node${{ steps.node.outputs.version }}-

.husky/pre-commit

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#!/bin/sh
2-
. "$(dirname -- "$0")/_/husky.sh"
3-
4-
# Fix from https://github.com/typicode/husky/issues/968#issuecomment-1176848345
5-
if [ -t 2 ] ; then exec >/dev/tty 2>&1 ; fi
6-
7-
# Check changes that are staged for commit
1+
#!/usr/bin/env sh
82
yarn lint-staged
3+
yarn typecheck
4+
5+
if command -v gitleaks >/dev/null 2>&1; then
6+
gitleaks protect --staged --no-banner --redact
7+
fi

.oxfmtrc.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"proseWrap": "preserve",
7+
"sortPackageJson": false,
8+
"ignorePatterns": [
9+
"**/node_modules/**",
10+
"**/lib/**",
11+
"**/dist/**",
12+
"**/coverage/**",
13+
"**/.yarn/**",
14+
"**/.firebase/**"
15+
]
16+
}

.oxlintrc.json

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "vitest", "unicorn", "oxc"],
4+
"categories": {
5+
"correctness": "error",
6+
"suspicious": "error",
7+
"perf": "error"
8+
},
29
"rules": {
3-
"no-unsafe-declaration-merging": "off"
4-
}
10+
"vitest/require-mock-type-parameters": "off",
11+
"vitest/valid-title": "off",
12+
"typescript/no-explicit-any": "warn",
13+
"typescript/ban-ts-comment": "off",
14+
"typescript/no-namespace": "off",
15+
"typescript/no-unsafe-declaration-merging": "off",
16+
"typescript/no-extraneous-class": "off",
17+
"no-bitwise": "off",
18+
"no-await-in-loop": "off"
19+
},
20+
"overrides": [
21+
{
22+
"files": ["**/*.test.ts", "**/*.spec.ts", "**/test/**/*.ts"],
23+
"rules": {
24+
"typescript/no-explicit-any": "off",
25+
"no-unused-vars": "off"
26+
}
27+
}
28+
],
29+
"env": {
30+
"browser": false,
31+
"node": true,
32+
"es2024": true,
33+
"vitest/globals": true
34+
},
35+
"ignorePatterns": [
36+
"**/node_modules/**",
37+
"**/lib/**",
38+
"**/dist/**",
39+
"**/coverage/**",
40+
"**/.yarn/**",
41+
"**/.firebase/**"
42+
]
543
}

.prettierignore

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

.prettierrc.json

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

.yarnrc.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
nodeLinker: node-modules
22

3-
43
# Solo project; PRs are exclusively from the maintainer. Re-enable when
54
# accepting third-party PRs that auto-trigger CI without manual review.
65
enableHardenedMode: false
76

8-
npmRegistryServer: "https://registry.npmjs.org/"
7+
npmRegistryServer: 'https://registry.npmjs.org/'

DEVELOPMENT.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ This will compile the TypeScript code into JavaScript in the `lib` directory, wh
5252
To use Firebase Admin SDK locally:
5353

5454
1. Download a service account key from your Firebase project settings:
55-
5655
- Go to [Firebase Console](https://console.firebase.google.com/)
5756
- Select your project
5857
- Go to Project Settings > Service accounts

firebase.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"functions": {
77
"runtime": "nodejs22",
88
"predeploy": [
9-
"yarn workspace functions lint",
10-
"yarn workspace functions test run",
9+
"yarn lint",
10+
"yarn workspace functions run test:run",
1111
"yarn workspace functions build"
1212
]
1313
},

functions/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "functions",
33
"scripts": {
44
"dev": "yarn watch",
5-
"lint": "eslint \"src/**/*\"",
65
"build": "run -T tsc",
76
"watch": "run -T tsc --watch",
87
"serve": "yarn build && firebase emulators:start --only functions",
@@ -11,7 +10,8 @@
1110
"deploy": "firebase deploy --only functions",
1211
"logs": "firebase functions:log",
1312
"test": "run -T vitest",
14-
"typecheck": "run -T tsc --noEmit",
13+
"typecheck": "run -T tsgo --noEmit",
14+
"typecheck:tsc": "run -T tsc --noEmit",
1515
"coverage": "run -T vitest run --coverage",
1616
"test:run": "run -T vitest run",
1717
"test:ui": "run -T vitest --ui"
@@ -38,12 +38,7 @@
3838
"@types/node-fetch": "^2.6.11",
3939
"@types/semver": "^7.5.8",
4040
"@types/ws": "^8.5.13",
41-
"@typescript-eslint/eslint-plugin": "^7.12.0",
42-
"@typescript-eslint/parser": "^7.12.0",
43-
"eslint": "^8.57.0",
44-
"eslint-plugin-import": "^2.29.1",
45-
"firebase-functions-test": "^3.3.0",
46-
"jest": "^29.7.0"
41+
"firebase-functions-test": "^3.3.0"
4742
},
4843
"private": true,
4944
"packageManager": "yarn@4.14.1"

0 commit comments

Comments
 (0)