# 🔍 check-resolutions

> 🤖 Coded with [Claude Code](https://claude.ai/claude-code)

Checks whether entries in `package.json` `resolutions` are still needed by inspecting the existing `yarn.lock`. No files are modified unless you append the `--fix` flag.

This is to be used if the resolution is used to ensure a minimum version of the package (e.g. in response to a vulnerability scan). For each resolution, it finds all resolved versions in the lockfile for that package and checks whether every resolved version already meets or exceeds the resolution constraint. If so, the resolution isn't enforcing anything useful.

This is particularly useful when upgrading node modules using `yarn upgrade --latest`. NOTE - `yarn upgrade --latest` can upgrade resolutions to the latest versions AND add them to `dependencies` (rather than `resolutions`). Please revert this change if so. After you've run this tool, you can upgrade your resolutions to the latest version if they are still required. 

## Install globally

```sh
chmod +x check-resolutions.mjs
nvm use 24
yarn global add file:$PWD
```

## Usage

Run from a yarn project directory:

```sh
# Check which resolutions are still needed
check-resolutions

# Remove stale resolutions from package.json
check-resolutions --fix
```

After `--fix`, run `yarn install` to update your lockfile.

## Development

Install dependencies and run the test suite:

```sh
yarn install
yarn test
```

## Uninstall

```sh
yarn global remove check-resolutions
```
