From 53fa4736ac5d7710d4a42a0cc2f684ae039141c1 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 30 Mar 2023 08:45:01 +0200 Subject: [PATCH] Suppress the behavior of treating a leading ! character as negation on dependencies check --- lib/validation/validateDependencyRules.js | 5 ++++- src/validation/validateDependencyRules.ts | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/validation/validateDependencyRules.js b/lib/validation/validateDependencyRules.js index 92b4fd2..db80ef6 100644 --- a/lib/validation/validateDependencyRules.js +++ b/lib/validation/validateDependencyRules.js @@ -25,7 +25,10 @@ function validateConfig(config, sourceFile, importRecord) { // Check whether: // 1) The import matches the rule // 2) If necessary, the source file has a relevant tag - if (minimatch(importRecord.rawImport, dependencyRule.dependency) && + if (minimatch(importRecord.rawImport, dependencyRule.dependency, { + matchBase: true, + nonegate: true, + }) && fileHasNecessaryTag_1.default(sourceFile, dependencyRule.accessibleTo)) { // A rule matched, so the dependency is valid return; diff --git a/src/validation/validateDependencyRules.ts b/src/validation/validateDependencyRules.ts index 9366447..2affe3d 100644 --- a/src/validation/validateDependencyRules.ts +++ b/src/validation/validateDependencyRules.ts @@ -28,8 +28,12 @@ function validateConfig(config: Config, sourceFile: NormalizedPath, importRecord // Check whether: // 1) The import matches the rule // 2) If necessary, the source file has a relevant tag + if ( - minimatch(importRecord.rawImport, dependencyRule.dependency) && + minimatch(importRecord.rawImport, dependencyRule.dependency, { + matchBase: true, + nonegate: true, + }) && fileHasNecessaryTag(sourceFile, dependencyRule.accessibleTo) ) { // A rule matched, so the dependency is valid