From 8b4426aebf0a2c44df3aacca7a7f37de02164ebe Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Thu, 26 Jan 2023 16:31:40 +0000 Subject: [PATCH 1/2] build(lint): cache prettier on `pnpm run lint` [Prettier 2.7.0](https://prettier.io/blog/2022/06/14/2.7.0.html) added a `--cache` CLI option to greatly speed up subsequent prettier runs. By default, the cache is stored in `./node_modules/.cache/prettier/.prettier-cache` and uses an `md5` checksum of the contents as the cache-key. On my PC, running `pnpm run lint` used to take 13.9 seconds, but now it only takes 6 seconds. Potential issues ---------------- Although updating Node.JS/Prettier will invalidate the cache, updating or changing prettier plugins won't invalidate the cache. Since we do use `prettier-plugin-jsdoc` in Mermaid, this might cause a minor issue, but CI should catch it. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a1f2828df..f6130fa47 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"", "dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"", "release": "pnpm build", - "lint": "eslint --cache --ignore-path .gitignore . && pnpm lint:jison && prettier --check .", + "lint": "eslint --cache --ignore-path .gitignore . && pnpm lint:jison && prettier --cache --check .", "lint:fix": "eslint --fix --ignore-path .gitignore . && prettier --write . && ts-node-esm scripts/fixCSpell.ts", "lint:jison": "ts-node-esm ./scripts/jison/lint.mts", "cypress": "cypress run", From 4900647bf0fe1fb7e1e4e60acc5bdbdc2c2c01df Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Sun, 29 Jan 2023 20:27:31 +0000 Subject: [PATCH 2/2] ci(lint): show nice error on lint failure Prints a nice error on GitHub Actions if `pnpm run lint` fails. --- .github/workflows/lint.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 95e4256b1..a21fbc005 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -37,7 +37,20 @@ jobs: CYPRESS_CACHE_FOLDER: .cache/Cypress - name: Run Linting - run: pnpm run lint + shell: bash + run: | + if ! pnpm run lint; then + # print a nice error message on lint failure + ERROR_MESSAGE='Running `pnpm run lint` failed.' + ERROR_MESSAGE+=' Running `pnpm run lint:fix` may fix this issue. ' + ERROR_MESSAGE+=" If this error doesn't occur on your local machine," + ERROR_MESSAGE+=' make sure your packages are up-to-date by running `pnpm install`.' + ERROR_MESSAGE+=' You may also need to delete your prettier cache by running' + ERROR_MESSAGE+=' `rm ./node_modules/.cache/prettier/.prettier-cache`.' + echo "::error title=Lint failure::${ERROR_MESSAGE}" + # make sure to return an error exitcode so that GitHub actions shows a red-cross + exit 1 + fi - name: Verify Docs id: verifyDocs