Using pnpm and corepack to manage both Node.js and pnpm versions.
- ensure right Node.js version is used
- ensure right package manager & package manager version is used, ie. if we use pnpm it should disallow use of yarn/npm and the version of pnpm used should be correct
use-node-version=18.15.0
in.npmrc
to pin the Node.js version pnpm will use when invokedpreinstall
script that enables corepack- problem:
npm i
still works - [failed]
corepack enable npm yarn pnpm
, would overwritenpm
,yarn
andpnpm
with symlinks/shims, this would be useful so thatnpm ...
andyarn ...
get intercepted and error withUsage Error: This project is configured to use pnpm
- however it looks like this only works on second run, the first
npm i
will work fine, the second will fail with the right error, so we need to find an alternative
- however it looks like this only works on second run, the first
- lint rule using check-file/filename-blocklist and eslint-plugin-json (in order to lint JSON files) that disallows
package-lock.json
in favour of apnpm-lock.yaml
- Rule:
'check-file/filename-blocklist': [ 'error', { '{,}package-lock.json': '*pnpm-lock.yaml', }, ],
- ESLint invocation:
eslint . --ext js,json
- Error output:
1:2 error The filename "package-lock.json" matches the blocklisted "{,}package-lock.json" pattern. Use a pattern like "*pnpm-lock.yaml" instead check-file/filename-blocklist
- Rule:
- problem: