Skip to content

Commit

Permalink
fix: Avoid error when rule element matchers define a capture key but …
Browse files Browse the repository at this point in the history
…some element does not have that capture key
  • Loading branch information
javierbrea committed Dec 1, 2023
1 parent 62a1daa commit 52de7f1
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
### Removed
### BREAKING CHANGES

## [4.0.1] - 2023-12-01

### Fixed
- fix: Avoid error when rule element matchers define a capture key but some element does not have that capture key

## [4.0.0] - 2023-12-01

### Added
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-boundaries",
"version": "4.0.0",
"version": "4.0.1",
"description": "Eslint plugin checking architecture boundaries between elements",
"keywords": [
"eslint",
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sonar.organization=javierbrea
sonar.projectKey=javierbrea_eslint-plugin-boundaries
sonar.projectVersion=4.0.0
sonar.projectVersion=4.0.1

sonar.javascript.file.suffixes=.js
sonar.sourceEncoding=UTF-8
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function micromatchPatternReplacingObjectsValues(pattern, object) {
function isObjectMatch(objectWithMatchers, object, objectsWithValuesToReplace) {
return Object.keys(objectWithMatchers).reduce((isMatch, key) => {
if (isMatch) {
if (!object) {
if (!object || !object[key]) {
return false;
}
const micromatchPattern = micromatchPatternReplacingObjectsValues(
Expand Down
4 changes: 4 additions & 0 deletions test/rules/one-level/element-types.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,10 @@ testCapture(
from: "modules",
allow: [["h*", { elementName: "*-a" }], "c*", "m*"],
},
{
from: "modules",
disallow: [["h*", { foo: "*-a" }], "c*", "m*"],
},
],
},
],
Expand Down

0 comments on commit 52de7f1

Please sign in to comment.