mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
1ea435d730
shared's lint ran eslint --fix with prettier/prettier as an error, so in lint-prettier.yml the format:check after it only ever saw files it had just rewritten, and the server's format scripts pointed at a test/ directory that does not exist. Now lint is check-only in both (lint:fix applies fixes), the server scripts cover src/ and tests/, and a lint:format ratchet on the shared library holds every file outside scripts/format-baseline.json to Prettier in both workspaces: in the server job of test.yml and in lint-prettier.yml, which keeps providing the lint check. Formatting leaves ESLint in shared, and the unused eslint-plugin-prettier goes. Once the tree is reformatted in one commit, --update empties the baselines and the check is a full prettier --check.
64 lines
2.0 KiB
YAML
64 lines
2.0 KiB
YAML
name: Lint & Prettier
|
|
on:
|
|
pull_request:
|
|
branches: [main, dev]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-24.04
|
|
timeout-minutes: 45
|
|
permissions:
|
|
pull-requests: write
|
|
steps:
|
|
- uses: actions/checkout@v6
|
|
- uses: actions/setup-node@v6
|
|
with:
|
|
node-version-file: .nvmrc
|
|
|
|
- name: Install dependencies
|
|
run: npm install
|
|
|
|
- name: Run lint & format check
|
|
# Both are check-only: lint used to run eslint --fix, which rewrote the
|
|
# files before format:check looked at them, so neither could fail on
|
|
# formatting. lint:format holds every file outside
|
|
# scripts/format-baseline.json to Prettier; the list only shrinks.
|
|
id: checks
|
|
continue-on-error: true
|
|
run: |
|
|
cd shared
|
|
npm run lint
|
|
npm run lint:format
|
|
|
|
- name: Comment on PR if checks failed
|
|
if: steps.checks.outcome == 'failure'
|
|
uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: [
|
|
'## ❌ Lint & Prettier check failed',
|
|
'',
|
|
'Please fix the issues locally by running the following commands inside the `shared` package:',
|
|
'',
|
|
'```bash',
|
|
'cd shared',
|
|
'npm run lint:fix',
|
|
'npx prettier --write <file> # each file lint:format names',
|
|
'npm run lint:format -- --update # when a listed file is formatted now',
|
|
'```',
|
|
'',
|
|
'Then commit and push the changes.',
|
|
].join('\n'),
|
|
});
|
|
|
|
- name: Fail the job if checks failed
|
|
if: steps.checks.outcome == 'failure'
|
|
run: exit 1 |