build(lint): cache eslint with strategy content

Cache eslint using `--cache-strategy content` instead of the default
`--cache-strategy metadata`.

By default, `eslint` uses the file metadata (e.g. modification time)
to detect when the cache should be invalidated.

However, this is not efficient with `git`, since git constantly changes
the modification time,
e.g. running `git switch main && git switch original-branch` would not
change the file contents, but would change the file mtimes and force
eslint to re-lint everything.

Using the file contents is slower (~3% for me), but more resilient.

See
https://eslint.org/docs/latest/use/command-line-interface#--cache-strategy
This commit is contained in:
Alois Klink
2023-02-05 19:25:57 +00:00
parent 71e5a53172
commit b3e509b7d4

View File

@@ -23,7 +23,7 @@
"build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"", "build": "pnpm run -r clean && concurrently \"pnpm build:vite\" \"pnpm build:types\"",
"dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"", "dev": "concurrently \"pnpm build:vite --watch\" \"ts-node-esm .vite/server.ts\"",
"release": "pnpm build", "release": "pnpm build",
"lint": "eslint --cache --ignore-path .gitignore . && pnpm lint:jison && prettier --cache --check .", "lint": "eslint --cache --cache-strategy content --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:fix": "eslint --fix --ignore-path .gitignore . && prettier --write . && ts-node-esm scripts/fixCSpell.ts",
"lint:jison": "ts-node-esm ./scripts/jison/lint.mts", "lint:jison": "ts-node-esm ./scripts/jison/lint.mts",
"cypress": "cypress run", "cypress": "cypress run",