@boundaries/eslint-plugin 5.3.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,7 +18,6 @@ const Helpers_1 = require("./Helpers");
18
18
  const Settings_1 = require("./Settings");
19
19
  const Settings_types_1 = require("./Settings.types");
20
20
  const { TYPES, ALIAS, ELEMENTS, DEPENDENCY_NODES, ADDITIONAL_DEPENDENCY_NODES, VALID_DEPENDENCY_NODE_KINDS, DEFAULT_DEPENDENCY_NODES, VALID_MODES, } = Settings_types_1.SETTINGS;
21
- const invalidMatchers = [];
22
21
  const DEFAULT_MATCHER_OPTIONS = {
23
22
  type: "object",
24
23
  };
@@ -108,23 +107,50 @@ function rulesOptionsSchema(options = {}) {
108
107
  ];
109
108
  }
110
109
  function isValidElementTypesMatcher(matcher, settings) {
111
- const matcherToCheck = (0, Common_1.isArray)(matcher) ? matcher[0] : matcher;
112
- const typeMatcherToCheck = (0, Common_1.isString)(matcherToCheck)
113
- ? matcherToCheck
114
- : matcherToCheck.type;
115
- return (!typeMatcherToCheck ||
116
- (typeMatcherToCheck &&
117
- micromatch_1.default.some(settings.elementTypeNames, typeMatcherToCheck)));
110
+ const matcherToCheck = (0, Common_1.isArray)(matcher)
111
+ ? matcher[0]
112
+ : matcher;
113
+ return (!matcherToCheck ||
114
+ (matcherToCheck &&
115
+ micromatch_1.default.some(settings.elementTypeNames, matcherToCheck)));
116
+ }
117
+ /**
118
+ * Checks if the value is a single matcher with options (tuple of [string, object])
119
+ */
120
+ function isSingleMatcherWithOptions(value) {
121
+ return ((0, Common_1.isArray)(value) &&
122
+ value.length === 2 &&
123
+ (0, Common_1.isString)(value[0]) &&
124
+ (0, Common_1.isObject)(value[1]));
118
125
  }
119
126
  // TODO: Remove this validation. Selectors should not be limited to element types defined in settings when using selector objects
120
127
  function validateElementTypesMatcher(elementsMatcher, settings) {
121
- const [matcher] = (0, Common_1.isArray)(elementsMatcher)
122
- ? elementsMatcher
123
- : [elementsMatcher];
124
- if (!invalidMatchers.includes(matcher) &&
125
- !isValidElementTypesMatcher(matcher, settings)) {
126
- invalidMatchers.push(matcher);
127
- (0, Debug_1.warnOnce)(`Option '${matcher}' does not match any element type from '${ELEMENTS}' setting`);
128
+ // Handle empty array case
129
+ if ((0, Common_1.isArray)(elementsMatcher) && elementsMatcher.length === 0) {
130
+ return;
131
+ }
132
+ // Determine if it's a single matcher or an array of matchers
133
+ let matcher;
134
+ if ((0, Common_1.isString)(elementsMatcher)) {
135
+ matcher = elementsMatcher;
136
+ }
137
+ else if (isSingleMatcherWithOptions(elementsMatcher)) {
138
+ // It's a single matcher with options: ["type", { option: value }]
139
+ matcher = elementsMatcher;
140
+ }
141
+ else if ((0, Common_1.isArray)(elementsMatcher)) {
142
+ // It's an array of matchers: ["helpers", "components"] or [["helpers", {...}], "components"]
143
+ // NOTE: Validate only the first matcher. It is wrong, but we don't want to impact performance, and anyway it was already validating only the first one.
144
+ // In next major version, validation will be removed, because schema validation will handle it.
145
+ matcher = elementsMatcher[0];
146
+ }
147
+ else {
148
+ (0, Debug_1.warnOnce)(`Option is not a valid elements selector: '${JSON.stringify(elementsMatcher)}'`);
149
+ return;
150
+ }
151
+ // Validate the matcher
152
+ if (!isValidElementTypesMatcher(matcher, settings)) {
153
+ (0, Debug_1.warnOnce)(`Option '${JSON.stringify(matcher)}' does not match any element type from '${ELEMENTS}' setting`);
128
154
  }
129
155
  }
130
156
  function isValidElementAssigner(element) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boundaries/eslint-plugin",
3
- "version": "5.3.0",
3
+ "version": "5.3.1",
4
4
  "description": "Eslint plugin checking architecture boundaries between elements",
5
5
  "keywords": [
6
6
  "eslint",
@@ -53,14 +53,16 @@
53
53
  "eslint-import-resolver-node": "0.3.9",
54
54
  "eslint-module-utils": "2.12.1",
55
55
  "micromatch": "4.0.8",
56
- "@boundaries/elements": "1.1.1"
56
+ "@boundaries/elements": "1.1.2"
57
57
  },
58
58
  "engines": {
59
59
  "node": ">=18.18"
60
60
  },
61
61
  "devDependencies": {
62
62
  "@types/estree": "1.0.8",
63
- "@types/micromatch": "4.0.9"
63
+ "@types/micromatch": "4.0.9",
64
+ "eslint-plugin-eslint-plugin": "7.2.0",
65
+ "eslint-plugin-local-rules": "3.0.2"
64
66
  },
65
67
  "scripts": {
66
68
  "eslint": "eslint",