npm-package-json-lint icon indicating copy to clipboard operation
npm-package-json-lint copied to clipboard

Feature request: add whitelist for dependency rules

Open henricazottes opened this issue 3 years ago • 0 comments

Hi,

First of all thanks for the work, it's a very useful package :) I however ran into a kinda specific problem.

Context: I'm using the no-restricted-dependencies rule with the following configuration :

'no-restricted-dependencies': [
  'error',
  [
    ...
    'ts-*',
    ...
  ],
],

Problem: I would like to use the package ts-predicate (which can't be used as dev dependency because it's needed at runtime). And of course I get a lint error because the name matches the rule.

I couldn't find in the documentation if I could use some sort of regex to exclude a particular name. It seems only the wildcard is available but it doesn't fit my situation.

Proposition: Add a whitelist array as an optional array after the matching array. Configuration example:

'no-restricted-dependencies': [
  'error',
  [
    ...
    'ts-*',
    ...
  ],
  [
    'ts-predicate',
  ]
],

What do you think?

henricazottes avatar Oct 26 '22 09:10 henricazottes