Skip to content

Commit e7d2944

Browse files
committed
chore(tooling): migrate JS/TS lint and format to the oxc toolchain
Replace ESLint with oxlint and Prettier (for JS/TS) with oxfmt: - ESLint -> oxlint: add .oxlintrc.json mirroring the previous config (ignore patterns, no-unused-vars ^_ exceptions, typescript/unicorn/oxc plugins, correctness category); remove eslint, @eslint/js, typescript-eslint and eslint.config.mjs. - Prettier -> oxfmt for JS/TS: add .oxfmtrc.json (migrated from .prettierrc.json) and .oxfmtignore. Prettier is kept but scoped to JSON/YAML via .prettierignore; SCSS/CSS stay with stylelint. oxfmt uses its own --ignore-path so the two formatters never overlap. - Wire oxlint + oxfmt into husky pre-commit/pre-push and CI build.yml. - Fix two findings oxlint's default plugins surfaced: unnecessary spread over a NodeList (groups.ts) and a dead recursion-only parameter (connectSSE in chat/index.ts). - Update AGENTS.md, docs and CHANGELOG.
1 parent 5bfbf42 commit e7d2944

16 files changed

Lines changed: 534 additions & 664 deletions

File tree

.github/workflows/build.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ jobs:
8585
- name: Install Node.js dependencies
8686
run: pnpm install
8787

88-
- name: Run ESLint check
89-
run: pnpm eslint .
88+
- name: Run oxfmt format check
89+
run: pnpm run oxfmt
90+
91+
- name: Run oxlint check
92+
run: pnpm run oxlint
9093

9194
- name: Run Stylelint check
9295
run: pnpm run stylelint

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
composer format && composer validate && composer test && pnpm pretty-quick --staged && pnpm run eslint && pnpm run stylelint && pnpm run tsc && pnpm test
1+
composer format && composer validate && composer test && pnpm pretty-quick --staged && pnpm run oxfmt && pnpm run oxlint && pnpm run stylelint && pnpm run tsc && pnpm test

.husky/pre-push

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
composer validate && composer test && pnpm pretty-quick --staged && pnpm run eslint && pnpm run stylelint && pnpm run tsc && pnpm test
1+
composer validate && composer test && pnpm pretty-quick --staged && pnpm run oxfmt && pnpm run oxlint && pnpm run stylelint && pnpm run tsc && pnpm test

.oxfmtignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# oxfmt formats JavaScript/TypeScript only.
2+
#
3+
# Ignore rules live in .oxfmtrc.json ("ignorePatterns"). This file exists so that
4+
# oxfmt does NOT fall back to reading .prettierignore, which deliberately excludes
5+
# *.ts/*.js/*.scss — those JS/TS files are formatted by oxfmt, not prettier.

.oxfmtrc.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"trailingComma": "es5",
4+
"tabWidth": 2,
5+
"semi": true,
6+
"singleQuote": true,
7+
"printWidth": 120,
8+
"htmlWhitespaceSensitivity": "ignore",
9+
"sortPackageJson": false,
10+
"ignorePatterns": [
11+
".claude/",
12+
"phpmyfaq/admin/assets/js/editor/",
13+
"phpmyfaq/src/libs/",
14+
"*.php",
15+
"*.md",
16+
".github",
17+
"composer.json",
18+
"composer.lock",
19+
"docker-compose.yml",
20+
"package.json",
21+
"pnpm-lock.yaml",
22+
"phpmyfaq/assets/public/",
23+
"site/",
24+
".pnpm-store"
25+
]
26+
}

.oxlintrc.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["typescript", "unicorn", "oxc"],
4+
"categories": {
5+
"correctness": "error"
6+
},
7+
"rules": {
8+
"no-unused-vars": [
9+
"error",
10+
{
11+
"argsIgnorePattern": "^_",
12+
"varsIgnorePattern": "^_",
13+
"caughtErrorsIgnorePattern": "^_"
14+
}
15+
]
16+
},
17+
"ignorePatterns": [
18+
".claude/*",
19+
"babel.config.cjs",
20+
"commitlint.config.cjs",
21+
"coverage/*",
22+
"html-coverage/*",
23+
"node_modules/*",
24+
"phpmyfaq/assets/public/*",
25+
"phpmyfaq/content/upgrades/*",
26+
"phpmyfaq/src/libs/*",
27+
"site/*",
28+
"volumes/*"
29+
],
30+
"overrides": [
31+
{
32+
"files": ["phpmyfaq/sw.js"],
33+
"env": {
34+
"serviceworker": true
35+
}
36+
}
37+
]
38+
}

.prettierignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ phpmyfaq/src/libs/
77
*.php
88
*.md
99

10+
# JavaScript/TypeScript are formatted by oxfmt (see .oxfmtrc.json)
11+
*.ts
12+
*.tsx
13+
*.js
14+
*.jsx
15+
*.mjs
16+
*.cjs
17+
18+
# SCSS/CSS are handled by stylelint
19+
*.scss
20+
*.css
21+
1022
# Ignore code for build
1123
.github
1224
composer.json

AGENTS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ It is built using HTML5, CSS, TypeScript, and PHP and supports various databases
5353
- TypeScript code: pnpm test
5454
- TypeScript code with coverage: pnpm test:coverage
5555
- TypeScript code in watch mode: pnpm test:watch
56-
- TypeScript linting: pnpm lint
57-
- TypeScript code formatting: pnpm lint:fix
56+
- TypeScript linting: pnpm oxlint
57+
- TypeScript code formatting check: pnpm oxfmt
58+
- TypeScript code formatting auto-fix: pnpm oxfmt:fix
59+
- JSON/YAML formatting: pnpm lint (check) / pnpm lint:fix (auto-fix, prettier)
5860
- SCSS linting: pnpm stylelint
5961
- SCSS lint auto-fix: pnpm stylelint:fix
6062
- TypeScript errors have to be fixed before committing code.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ This is a log of major user-visible changes in each phpMyFAQ release.
4040
- migrated codebase using PHP 8.4 language features (Thorsten)
4141
- migrated routes using PHP 8+ #[Route] attributes (Thorsten)
4242
- migrated to Vite v8 (Thorsten)
43+
- migrated from ESLint to oxlint for TypeScript linting (Thorsten)
44+
- migrated from Prettier to oxfmt for JavaScript/TypeScript formatting (Thorsten)
4345
- migrated experimental MCP Server to mcp/sdk (Thorsten)
4446

4547
### phpMyFAQ v4.1.5 - unreleased

docs/development.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,9 @@ To run the PHPUnit-based tests, you can use the following command:
424424

425425
$ composer test
426426

427-
To run the ESLint-based checks, you can use the following command:
427+
To run the oxlint-based checks, you can use the following command:
428428

429-
$ pnpm eslint .
429+
$ pnpm run oxlint
430430

431431
To run the Vitest-based tests, you can use the following command:
432432

@@ -482,7 +482,7 @@ phpMyFAQ provides a set of Composer scripts to simplify common development tasks
482482
The following coding standards are used in phpMyFAQ:
483483

484484
- PHP: [PER Coding Style 3.0](https://www.php-fig.org/per/coding-style/)
485-
- TypeScript with ESLint recommendations
485+
- TypeScript with oxlint recommendations
486486

487487
### 10.6.10 Rebase your Patch
488488

0 commit comments

Comments
 (0)