Repository navigation
chore(dx): backend ESLint, root scripts, dev CORS, CONTRIBUTING and Dependabot - #67
Merged
Merged
Conversation
Remove an unused import, an unused `next` parameter and two unused catch bindings, make a `let` that is never reassigned a `const`, and keep the Express `Request` namespace augmentation with a comment saying why it needs one. No behaviour change.
Flat config in the style of the frontend's: @eslint/js and typescript-eslint recommended, Node globals, `dist`, `logs` and `uploads` ignored. The 45 existing uses of `any` are reported as warnings instead of errors, so the lint step can be required now and the types tightened one file at a time. Same ESLint 9 and typescript-eslint ranges as the frontend.
`npm run check` runs what CI runs for frontend and backend, so it can be run before pushing. `install:all` installs the root, frontend and backend dependencies. The existing scripts are untouched.
Vite's --host prints a Network URL, and Vite moves to the next port when 5173 is taken, but the development default only listed localhost:5173 and :3000. Opening the app on 127.0.0.1 or the LAN address made every API call fail with "Not allowed by CORS", and the login page then looked like a wrong password. In development without CORS_ORIGINS, also accept loopback and private-network origins on any port. Production and an explicit CORS_ORIGINS list behave exactly as before. The decision moves to config/cors.config.ts so it can be tested.
Branches from and pull requests against develop, Conventional Commits, tests with every change, npm run check before pushing, the changelog, translations and migrations, and no version bumps. The pull request template checklist uses npm run check instead of listing the commands for each side.
One pull request a month for all ecosystems (npm in the root, frontend and backend, GitHub Actions, and both Dockerfiles), using a multi-ecosystem group so it stays one rather than six. Pull requests target develop. The first run also brings the older actions in docker-publish.yml up to date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The next steps of #45, in the order listed there: backend ESLint, root npm scripts, the dev CORS fix, CONTRIBUTING and Dependabot. Part of #45. The Node 24 step and the
npm auditpass change what ships, so they will come in a separate pull request, after this one.Changes
fix(lint): resolve the backend ESLint errors: 10 findings, no behaviour change (an unused import, an unusednextparameter, two unused catch bindings, aletthat is never reassigned, and a comment on the ExpressRequestnamespace augmentation, which has no module-syntax form).ci(backend): add ESLint and run it in CI: flat config in the style of the frontend's (@eslint/jsandtypescript-eslintrecommended, Node globals), same ESLint 9 and typescript-eslint ranges, and a lint step in the CI Backend job. The 45 existing uses ofanyare warnings rather than errors, so the step can be required now and the types tightened one file at a time.npm run lintends with 0 errors and 44 warnings (oneanywas among the fixed lines).chore: add root npm scripts for lint, test, build and check:npm run checkruns what CI runs, for frontend and backend. Alsoinstall:all. Existing scripts untouched.fix(cors): accept localhost and LAN origins in development:npm run devstarts Vite with--hostand prints a Network URL, but the development default only listedlocalhost:5173and:3000. On127.0.0.1, the LAN address, or Vite's next port when 5173 is taken, every API call failed withNot allowed by CORS, and the login page looked like a wrong password. In development withoutCORS_ORIGINS, loopback and private-network (10/8, 172.16/12, 192.168/16) origins are now accepted on any port. Production and an explicitCORS_ORIGINSbehave as before. The decision moved intoconfig/cors.config.tsso it can be tested.docs: add CONTRIBUTING.md and point the README and PR template to it:developas the base, branch names, Conventional Commits,npm run check, changelog, translations. The PR template checklist usesnpm run check.ci(dependabot): add a monthly grouped update against develop: monthly, one pull request for all ecosystems (npm in the root, frontend and backend, GitHub Actions, both Dockerfiles) using a multi-ecosystem group, targetingdevelop. The first run also brings the older actions indocker-publish.ymlup to date. Weekly is a one-line change.How it was verified
npm run checkat the root: 0 lint errors (frontend 8 warnings, backend 44), 162 frontend and 221 backend tests pass, both builds pass. 33 new tests forcors.config: the origin lists in each mode (pinning thatgetCorsOriginsstill behaves as the code it replaced), when the local-network rule applies, and accepted and rejected origins, including look-alike hosts such aslocalhost.example.comand172.32.0.1.POST /api/auth/login, 400 = past CORS, 500 =Not allowed by CORS):NODE_ENV=development:localhost:5173,localhost:5174,127.0.0.1:5173and192.168.1.15:5173pass;https://example.comis rejected.NODE_ENV=productionwithCORS_ORIGINS=https://app.example.com: everything else is rejected, including localhost.CORS_ORIGINS=http://localhost:5173: only that origin passes..github/dependabot.ymlwas validated against the SchemaStore Dependabot schema (it accepts the file and rejects a deliberately broken one). GitHub itself has not read it yet: Dependabot reads the file from the default branch, so it takes effect with the next merge intomain, and any problem will show on the repository's Dependabot page.Not checked: the new lint step has not run in CI yet (it passes locally with the same
npm ciinstall), and the CORS fix was not tried from a second device on the LAN.Checklist
develop(notmain)fix(discogs): …CHANGELOG.mdunder## [Unreleased]npm run checkpasses (lint, tests and build, frontend and backend)backend/src/scripts/migration-runner.ts(none needed)