Allow any one of specified packages in peerDependencies

(Raghav Dua) #1

This is a feature request.

Currently, NPM checks for all the packages specified in peerDependencies.

Devs should be able to specify a list of packages with versions and tell NPM that if any one of these packages is present, the peer dep is satisfied.

Use Case
I maintain a Linter. It has a plugin mechanism similar to ESLint’s. All plugins should specify the linter’s NPM package name and version range in their peerDependencies.

The problem is - I recently had to change the name of this linter. It is now available from both the old NPM package name (let’s call that foo) and the new one (bar).

Now, the plugins for this linter should be able to tell NPM that either foo or bar is acceptable as a peer dep.

I’m thinking something on the lines of:

  "peerDependencies": {
    "anyOf": [
      { "foo": "^1.0.3", "bar": "^1.0.0" },
      { "lorem": "^1.0.3", "ipsum": "^1.0.0" }

The above translates to: I want either foo or bar AND either lorem or ipsum to satisfy my peer deps.

Before I refine this idea, I’d like to know if this is a reasonable request.
Happy to clarify any doubts.

See original issue
See the code where the changes will be required.

(I’m totally new to this forum and went through the community guidelines, but in case you find something wrong with my post, let me know.)

(Kat Marchán) #2

No worries, your post is good :+1:t3: