@boundaries/eslint-plugin 5.4.0 → 6.0.0-beta.2

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.
Files changed (64) hide show
  1. package/README.md +9 -9
  2. package/dist/Config/Config.d.ts +6 -3
  3. package/dist/Config/Config.js +18 -7
  4. package/dist/Config/Recommended.d.ts +1 -1
  5. package/dist/Config/Recommended.js +4 -8
  6. package/dist/Config/Strict.d.ts +1 -1
  7. package/dist/Config/Strict.js +2 -2
  8. package/dist/Debug/Debug.d.ts +34 -0
  9. package/dist/Debug/Debug.js +285 -0
  10. package/dist/Debug/index.d.ts +1 -0
  11. package/dist/{Support → Debug}/index.js +0 -1
  12. package/dist/Elements/Elements.d.ts +9 -7
  13. package/dist/Elements/Elements.js +12 -7
  14. package/dist/Elements/Elements.types.d.ts +1 -0
  15. package/dist/Messages/CustomMessages.d.ts +44 -0
  16. package/dist/Messages/CustomMessages.js +156 -0
  17. package/dist/Messages/CustomMessages.types.d.ts +25 -0
  18. package/dist/Messages/CustomMessages.types.js +2 -0
  19. package/dist/Messages/Messages.d.ts +42 -13
  20. package/dist/Messages/Messages.js +400 -177
  21. package/dist/Messages/index.d.ts +2 -0
  22. package/dist/Messages/index.js +2 -0
  23. package/dist/Public/Config.types.d.ts +2 -2
  24. package/dist/Public/Config.types.js +2 -2
  25. package/dist/Public/Rules.types.d.ts +5 -4
  26. package/dist/Public/Rules.types.js +5 -6
  27. package/dist/Public/Settings.types.d.ts +3 -2
  28. package/dist/Public/Settings.types.js +4 -3
  29. package/dist/Public/index.d.ts +1 -0
  30. package/dist/Rules/Dependencies.d.ts +59 -0
  31. package/dist/Rules/Dependencies.js +439 -0
  32. package/dist/Rules/EntryPoint.js +44 -94
  33. package/dist/Rules/External.js +93 -68
  34. package/dist/Rules/NoIgnored.js +4 -4
  35. package/dist/Rules/NoPrivate.js +18 -5
  36. package/dist/Rules/NoUnknown.js +5 -5
  37. package/dist/Rules/NoUnknownFiles.js +4 -3
  38. package/dist/Rules/Support/DependencyRule.d.ts +9 -1
  39. package/dist/Rules/Support/DependencyRule.js +15 -6
  40. package/dist/Rules/Support/DependencyRule.types.d.ts +1 -1
  41. package/dist/Rules/Support/Helpers.d.ts +6 -2
  42. package/dist/Rules/Support/Helpers.js +7 -31
  43. package/dist/Settings/Helpers.d.ts +83 -1
  44. package/dist/Settings/Helpers.js +197 -7
  45. package/dist/Settings/Settings.d.ts +19 -2
  46. package/dist/Settings/Settings.js +20 -11
  47. package/dist/Settings/Validations.d.ts +11958 -43
  48. package/dist/Settings/Validations.js +783 -157
  49. package/dist/Settings/index.d.ts +0 -1
  50. package/dist/Settings/index.js +0 -1
  51. package/dist/{Settings → Shared}/Settings.types.d.ts +137 -37
  52. package/dist/{Settings → Shared}/Settings.types.js +30 -6
  53. package/dist/{Support/Common.d.ts → Shared/TypeHelpers.d.ts} +18 -0
  54. package/dist/{Support/Common.js → Shared/TypeHelpers.js} +28 -1
  55. package/dist/Shared/index.d.ts +2 -0
  56. package/dist/Shared/index.js +18 -0
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +16 -14
  59. package/package.json +9 -8
  60. package/dist/Rules/ElementTypes.d.ts +0 -25
  61. package/dist/Rules/ElementTypes.js +0 -279
  62. package/dist/Support/Debug.d.ts +0 -5
  63. package/dist/Support/Debug.js +0 -54
  64. package/dist/Support/index.d.ts +0 -2
package/dist/index.js CHANGED
@@ -17,28 +17,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- const fs_1 = require("fs");
21
- const path_1 = require("path");
20
+ const node_fs_1 = require("node:fs");
21
+ const node_path_1 = require("node:path");
22
22
  const Recommended_1 = __importDefault(require("./Config/Recommended"));
23
23
  const Strict_1 = __importDefault(require("./Config/Strict"));
24
- const ElementTypes_1 = __importDefault(require("./Rules/ElementTypes"));
24
+ const Dependencies_1 = __importDefault(require("./Rules/Dependencies"));
25
25
  const EntryPoint_1 = __importDefault(require("./Rules/EntryPoint"));
26
26
  const External_1 = __importDefault(require("./Rules/External"));
27
27
  const NoIgnored_1 = __importDefault(require("./Rules/NoIgnored"));
28
28
  const NoPrivate_1 = __importDefault(require("./Rules/NoPrivate"));
29
29
  const NoUnknown_1 = __importDefault(require("./Rules/NoUnknown"));
30
30
  const NoUnknownFiles_1 = __importDefault(require("./Rules/NoUnknownFiles"));
31
- const Settings_1 = require("./Settings");
32
- // import { warn } from "./Support";
31
+ const Shared_1 = require("./Shared");
32
+ // import { warn } from "./Shared";
33
33
  __exportStar(require("./Public"), exports);
34
34
  /**
35
35
  * The path to the plugin package.json file
36
36
  */
37
- const packageJsonPath = (0, path_1.join)(__dirname, "..", "package.json");
37
+ const packageJsonPath = (0, node_path_1.join)(__dirname, "..", "package.json");
38
38
  /**
39
39
  * The content of the package.json file
40
40
  */
41
- const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, "utf-8"));
41
+ const packageJson = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, "utf-8"));
42
42
  // TODO: Enable this warning in the next major release
43
43
  /* if (packageJson.name !== "@boundaries/eslint-plugin") {
44
44
  warn(
@@ -46,13 +46,15 @@ const packageJson = JSON.parse((0, fs_1.readFileSync)(packageJsonPath, "utf-8"))
46
46
  );
47
47
  } */
48
48
  const RULES = {
49
- [Settings_1.RULE_SHORT_NAMES_MAP.ENTRY_POINT]: EntryPoint_1.default,
50
- [Settings_1.RULE_SHORT_NAMES_MAP.ELEMENT_TYPES]: ElementTypes_1.default,
51
- [Settings_1.RULE_SHORT_NAMES_MAP.EXTERNAL]: External_1.default,
52
- [Settings_1.RULE_SHORT_NAMES_MAP.NO_IGNORED]: NoIgnored_1.default,
53
- [Settings_1.RULE_SHORT_NAMES_MAP.NO_PRIVATE]: NoPrivate_1.default,
54
- [Settings_1.RULE_SHORT_NAMES_MAP.NO_UNKNOWN]: NoUnknown_1.default,
55
- [Settings_1.RULE_SHORT_NAMES_MAP.NO_UNKNOWN_FILES]: NoUnknownFiles_1.default,
49
+ [Shared_1.RULE_SHORT_NAMES_MAP.ENTRY_POINT]: EntryPoint_1.default,
50
+ /** @deprecated Use dependencies rule instead */
51
+ [Shared_1.RULE_SHORT_NAMES_MAP.ELEMENT_TYPES]: (0, Dependencies_1.default)(Shared_1.SETTINGS.RULE_ELEMENT_TYPES),
52
+ [Shared_1.RULE_SHORT_NAMES_MAP.DEPENDENCIES]: (0, Dependencies_1.default)(),
53
+ [Shared_1.RULE_SHORT_NAMES_MAP.EXTERNAL]: External_1.default,
54
+ [Shared_1.RULE_SHORT_NAMES_MAP.NO_IGNORED]: NoIgnored_1.default,
55
+ [Shared_1.RULE_SHORT_NAMES_MAP.NO_PRIVATE]: NoPrivate_1.default,
56
+ [Shared_1.RULE_SHORT_NAMES_MAP.NO_UNKNOWN]: NoUnknown_1.default,
57
+ [Shared_1.RULE_SHORT_NAMES_MAP.NO_UNKNOWN_FILES]: NoUnknownFiles_1.default,
56
58
  };
57
59
  /**
58
60
  * Eslint plugin ensuring that architecture boundaries are respected by the elements in a project
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boundaries/eslint-plugin",
3
- "version": "5.4.0",
3
+ "version": "6.0.0-beta.2",
4
4
  "description": "Eslint plugin checking architecture boundaries between elements",
5
5
  "keywords": [
6
6
  "eslint",
@@ -52,32 +52,33 @@
52
52
  "chalk": "4.1.2",
53
53
  "eslint-import-resolver-node": "0.3.9",
54
54
  "eslint-module-utils": "2.12.1",
55
+ "handlebars": "4.7.8",
55
56
  "micromatch": "4.0.8",
56
- "@boundaries/elements": "1.2.0"
57
+ "@boundaries/elements": "2.0.0-beta.2"
57
58
  },
58
59
  "engines": {
59
60
  "node": ">=18.18"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@types/estree": "1.0.8",
63
- "@types/micromatch": "4.0.9",
64
- "eslint-plugin-eslint-plugin": "7.2.0",
64
+ "@types/micromatch": "4.0.10",
65
+ "eslint-plugin-eslint-plugin": "7.3.2",
65
66
  "eslint-plugin-local-rules": "3.0.2"
66
67
  },
67
68
  "scripts": {
68
69
  "eslint": "eslint",
69
70
  "build": "pnpm build:tsc && pnpm copy:readme",
70
- "build:tsc": "tsc",
71
+ "build:tsc": "tsc --project ./tsconfig.code.json",
71
72
  "copy:readme": "cross-env node ./scripts/copy-readme.js",
72
73
  "check:all": "echo 'All checks passed'",
73
74
  "check:spell": "cspell --quiet .",
74
75
  "check:types": "pnpm check:types:code && pnpm check:types:test",
75
- "check:types:code": "tsc --noEmit",
76
- "check:types:test": "tsc --noEmit --project ./test/tsconfig.json",
76
+ "check:types:code": "tsc --noEmit --project ./tsconfig.code.json",
77
+ "check:types:test": "tsc --noEmit --project ./tsconfig.test.json",
77
78
  "lint": "eslint .",
78
79
  "lint:fix": "eslint . --fix",
79
80
  "serve:unit:report": "serve --config ./serve.test-unit-report.json",
80
81
  "test": "jest",
81
- "test:unit": "cross-env ESLINT_PLUGIN_BOUNDARIES_DEBUG=false pnpm test"
82
+ "test:unit": "pnpm test"
82
83
  }
83
84
  }
@@ -1,25 +0,0 @@
1
- import type { DependencyDescription, Matcher } from "@boundaries/elements";
2
- import type { ElementTypesRuleOptions, RuleResult, SettingsNormalized } from "../Settings";
3
- type PolicyMatch = {
4
- isMatch: boolean;
5
- specifiers?: string | string[];
6
- internalPath?: string;
7
- };
8
- export declare function getRulesResults(ruleOptions: ElementTypesRuleOptions, dependencyDescription: DependencyDescription, matcher: Matcher, settings: SettingsNormalized): {
9
- index: number;
10
- originalRuleIndex: any;
11
- selectorsMatching: {
12
- selectors: {
13
- [x: string]: string | import("@boundaries/elements").BaseElementSelectorData | import("@boundaries/elements").BaseElementSelectorWithOptions | import("@boundaries/elements").BaseElementSelector[] | null;
14
- };
15
- selectorsData: {
16
- isMatch: boolean;
17
- } | null;
18
- };
19
- ruleHasImportKind: boolean;
20
- allowPolicyMatches: PolicyMatch;
21
- denyPolicyMatches: PolicyMatch;
22
- }[];
23
- export declare function elementRulesAllowDependency(dependency: DependencyDescription, settings: SettingsNormalized, ruleOptions?: ElementTypesRuleOptions): RuleResult;
24
- declare const _default: import("eslint").Rule.RuleModule;
25
- export default _default;
@@ -1,279 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRulesResults = getRulesResults;
7
- exports.elementRulesAllowDependency = elementRulesAllowDependency;
8
- const elements_1 = require("@boundaries/elements");
9
- const micromatch_1 = __importDefault(require("micromatch"));
10
- const Elements_1 = require("../Elements");
11
- const Messages_1 = require("../Messages");
12
- const Settings_1 = require("../Settings");
13
- const Support_1 = require("../Support");
14
- const Support_2 = require("./Support");
15
- const { RULE_ELEMENT_TYPES } = Settings_1.SETTINGS;
16
- /**
17
- * Safely matches a dependency selector, catching and logging any errors
18
- */
19
- function createSafeMatcherFunction(dependencyDescription, matcher) {
20
- return (dependencySelector, extraTemplateData, dependencySelectorsGlobals) => {
21
- // Just in case selectors are invalid, we catch errors here to avoid breaking the whole rule evaluation
22
- try {
23
- return matcher.getSelectorMatchingDescription(dependencyDescription, dependencySelector, {
24
- extraTemplateData,
25
- dependencySelectorsGlobals,
26
- });
27
- }
28
- catch (error) {
29
- (0, Support_1.warnOnce)(`Error occurred while matching dependency with selector ${JSON.stringify(dependencySelector)}: ${String(error)}`);
30
- return { isMatch: false, from: null, to: null };
31
- }
32
- };
33
- }
34
- /**
35
- * Determines the rule matching context (directions, template data, etc.)
36
- */
37
- function createRuleMatchContext(rule, dependencyDescription) {
38
- const targetElementDirection = rule.from ? "from" : "to";
39
- const policyElementDirection = rule.from ? "to" : "from";
40
- const denyKeyToUse = rule.deny ? "deny" : "disallow";
41
- const capturedValuesTemplateData = targetElementDirection === "from"
42
- ? {
43
- ...dependencyDescription.from.captured,
44
- from: dependencyDescription.from.captured,
45
- to: dependencyDescription.to.captured,
46
- }
47
- : {
48
- ...dependencyDescription.to.captured,
49
- from: dependencyDescription.from.captured,
50
- to: dependencyDescription.to.captured,
51
- };
52
- const dependencySelectorsGlobals = rule.importKind ? { kind: rule.importKind } : {};
53
- const targetElementSelector = rule[targetElementDirection];
54
- return {
55
- targetElementDirection,
56
- policyElementDirection,
57
- denyKeyToUse,
58
- capturedValuesTemplateData,
59
- dependencySelectorsGlobals,
60
- targetElementSelector,
61
- };
62
- }
63
- /**
64
- * Evaluates both deny and allow policy matches for a rule
65
- */
66
- function evaluatePolicyMatches(rule, context, isMatch, settings) {
67
- const { targetElementDirection, policyElementDirection, denyKeyToUse, capturedValuesTemplateData, dependencySelectorsGlobals, targetElementSelector, } = context;
68
- const templateData = settings.legacyTemplates
69
- ? capturedValuesTemplateData
70
- : {};
71
- const disallowPolicyMatches = rule[denyKeyToUse]
72
- ? isMatch({
73
- [targetElementDirection]: targetElementSelector,
74
- [policyElementDirection]: rule[denyKeyToUse],
75
- }, templateData, dependencySelectorsGlobals)
76
- : { isMatch: false };
77
- const allowPolicyMatches = !disallowPolicyMatches.isMatch && rule.allow
78
- ? isMatch({
79
- [targetElementDirection]: targetElementSelector,
80
- [policyElementDirection]: rule.allow,
81
- }, templateData, dependencySelectorsGlobals)
82
- : { isMatch: false };
83
- return { disallowPolicyMatches, allowPolicyMatches };
84
- }
85
- /**
86
- * Creates rule selectors data based on policy matches
87
- */
88
- function createRuleSelectorsData(rule, context, disallowPolicyMatches, allowPolicyMatches) {
89
- const { targetElementDirection, policyElementDirection, denyKeyToUse } = context;
90
- const allowPolicyMatchesIsMatch = allowPolicyMatches.isMatch;
91
- const disallowPolicyMatchesIsMatch = disallowPolicyMatches.isMatch;
92
- const targetSelector = disallowPolicyMatchesIsMatch || allowPolicyMatchesIsMatch
93
- ? context.targetElementSelector
94
- : null;
95
- let policySelector = null;
96
- if (disallowPolicyMatchesIsMatch) {
97
- policySelector = rule[denyKeyToUse];
98
- }
99
- else if (allowPolicyMatchesIsMatch) {
100
- policySelector = rule.allow;
101
- }
102
- let selectorsData = null;
103
- if (disallowPolicyMatchesIsMatch) {
104
- selectorsData = disallowPolicyMatches;
105
- }
106
- else if (allowPolicyMatchesIsMatch) {
107
- selectorsData = allowPolicyMatches;
108
- }
109
- return {
110
- selectors: {
111
- [targetElementDirection]: targetSelector,
112
- [policyElementDirection]: policySelector,
113
- },
114
- selectorsData,
115
- };
116
- }
117
- function getRulesResults(ruleOptions, dependencyDescription, matcher, settings) {
118
- if (!ruleOptions.rules) {
119
- return [];
120
- }
121
- const isMatch = createSafeMatcherFunction(dependencyDescription, matcher);
122
- return ruleOptions.rules.map((rule, index) => {
123
- const context = createRuleMatchContext(rule, dependencyDescription);
124
- const { disallowPolicyMatches, allowPolicyMatches } = evaluatePolicyMatches(rule, context, isMatch, settings);
125
- const selectorsMatching = createRuleSelectorsData(rule, context, disallowPolicyMatches, allowPolicyMatches);
126
- return {
127
- index,
128
- // @ts-expect-error Workaround to support both allow and disallow in the same entry point rule
129
- originalRuleIndex: rule.originalRuleIndex,
130
- selectorsMatching,
131
- ruleHasImportKind: !!rule.importKind,
132
- allowPolicyMatches,
133
- denyPolicyMatches: disallowPolicyMatches,
134
- };
135
- });
136
- }
137
- /**
138
- * Determines the rule result based on policy matches
139
- */
140
- function determineRuleResult(rulesResults) {
141
- let isAllowed = false;
142
- let ruleIndexMatching = null;
143
- for (const ruleResult of rulesResults) {
144
- if (ruleResult.denyPolicyMatches.isMatch) {
145
- isAllowed = false;
146
- ruleIndexMatching = ruleResult.index;
147
- }
148
- else if (ruleResult.allowPolicyMatches.isMatch) {
149
- isAllowed = true;
150
- ruleIndexMatching = ruleResult.index;
151
- }
152
- }
153
- return { isAllowed, ruleIndexMatching };
154
- }
155
- /**
156
- * Gets the message for the rule, prioritizing rule-specific messages
157
- */
158
- function getRuleMessage(ruleIndexMatching, ruleOptions) {
159
- return ((ruleIndexMatching === null
160
- ? ruleOptions.message
161
- : ruleOptions.rules?.[ruleIndexMatching]?.message) || ruleOptions.message);
162
- }
163
- /**
164
- * Gets specifiers that match the rule for error reporting
165
- */
166
- function getMatchingSpecifiers(ruleIndexMatching, rulesResults, dependency) {
167
- if (ruleIndexMatching === null)
168
- return null;
169
- const selectorDataSpecifiers =
170
- // @ts-expect-error TODO: Align types. At this point, selectorsData.to must always be defined, because otherwise isMatch would be false
171
- rulesResults[ruleIndexMatching].selectorsMatching?.selectorsData?.to
172
- ?.specifiers;
173
- if (!selectorDataSpecifiers) {
174
- return null;
175
- }
176
- if ((0, Support_1.isString)(selectorDataSpecifiers)) {
177
- const hasMatchingSpecifier = dependency.dependency.specifiers?.some((specifier) => micromatch_1.default.isMatch(specifier, selectorDataSpecifiers));
178
- return hasMatchingSpecifier ? [selectorDataSpecifiers] : null;
179
- }
180
- return selectorDataSpecifiers.filter((pattern) => {
181
- return dependency.dependency.specifiers?.some((specifier) => micromatch_1.default.isMatch(specifier, pattern));
182
- });
183
- }
184
- /**
185
- * Creates the rule report object
186
- */
187
- function createRuleReport(ruleIndexMatching, message, dependency, rulesResults) {
188
- if (ruleIndexMatching === null) {
189
- return {
190
- message,
191
- isDefault: true,
192
- importKind: undefined,
193
- disallow: dependency.to,
194
- element: dependency.from,
195
- index: -1,
196
- };
197
- }
198
- return {
199
- message,
200
- isDefault: false,
201
- importKind: rulesResults[ruleIndexMatching].ruleHasImportKind
202
- ? dependency.dependency.kind
203
- : undefined,
204
- disallow: rulesResults[ruleIndexMatching].selectorsMatching?.selectors.to,
205
- element: rulesResults[ruleIndexMatching].selectorsMatching?.selectors.from,
206
- index: rulesResults[ruleIndexMatching].originalRuleIndex ?? ruleIndexMatching,
207
- };
208
- }
209
- /**
210
- * Determines the report path for error reporting
211
- */
212
- function getReportPath(ruleIndexMatching, rulesResults, dependency) {
213
- return ruleIndexMatching === null ||
214
- // @ts-expect-error TODO: Align types. At this point, selectorsData should always be defined
215
- !rulesResults[ruleIndexMatching].selectorsMatching?.selectorsData?.to
216
- ?.internalPath
217
- ? null
218
- : dependency.to.internalPath;
219
- }
220
- function elementRulesAllowDependency(dependency, settings, ruleOptions = {}) {
221
- const defaultIsAllowed = ruleOptions.default === "allow";
222
- const matcher = (0, Elements_1.getElementsMatcher)(settings);
223
- const rulesResults = getRulesResults(ruleOptions, dependency, matcher, settings);
224
- const { isAllowed, ruleIndexMatching } = determineRuleResult(rulesResults);
225
- const finalIsAllowed = ruleIndexMatching === null ? defaultIsAllowed : isAllowed;
226
- if (finalIsAllowed) {
227
- return {
228
- result: finalIsAllowed,
229
- ruleReport: null,
230
- report: null,
231
- };
232
- }
233
- const message = getRuleMessage(ruleIndexMatching, ruleOptions);
234
- const ruleReport = createRuleReport(ruleIndexMatching, message, dependency, rulesResults);
235
- const reportPath = getReportPath(ruleIndexMatching, rulesResults, dependency);
236
- const result = {
237
- result: finalIsAllowed,
238
- // @ts-expect-error Temporary workaround for RuleResult type until types are aligned
239
- ruleReport,
240
- report: {
241
- specifiers: getMatchingSpecifiers(ruleIndexMatching, rulesResults, dependency) ||
242
- undefined,
243
- path: reportPath,
244
- },
245
- };
246
- return result;
247
- }
248
- function errorMessage(ruleData, dependency) {
249
- const ruleReport = ruleData.ruleReport;
250
- if (!ruleReport) {
251
- return `No detailed rule report available. This is likely a bug in ${Settings_1.PLUGIN_NAME}. Please report it at ${Settings_1.PLUGIN_ISSUES_URL}`;
252
- }
253
- if (ruleReport.message) {
254
- return (0, Messages_1.customErrorMessage)(ruleReport.message, dependency);
255
- }
256
- if (ruleReport.isDefault) {
257
- return `No rule allowing this dependency was found. File is ${(0, Messages_1.elementMessage)(dependency.from)}. Dependency is ${(0, Messages_1.elementMessage)(dependency.to)}`;
258
- }
259
- return `Importing ${(0, Messages_1.dependencyImportKindMessage)(ruleReport.importKind, dependency)}${(0, Messages_1.ruleElementMessage)(ruleReport.disallow, dependency.from.captured)} is not allowed in ${(0, Messages_1.ruleElementMessage)(ruleReport.element, dependency.from.captured)}. Disallowed in rule ${ruleReport.index + 1}`;
260
- }
261
- exports.default = (0, Support_2.dependencyRule)({
262
- ruleName: RULE_ELEMENT_TYPES,
263
- description: `Check allowed dependencies between element types`,
264
- schema: (0, Settings_1.rulesOptionsSchema)(),
265
- }, function ({ dependency, node, context, settings, options }) {
266
- // TODO: Remove these checks when allowing to use more selectors in ESLint rules
267
- if ((0, elements_1.isLocalElement)(dependency.to) &&
268
- !(0, elements_1.isIgnoredElement)(dependency.to) &&
269
- !(0, elements_1.isUnknownLocalElement)(dependency.to) &&
270
- !(0, elements_1.isInternalDependency)(dependency)) {
271
- const ruleData = elementRulesAllowDependency(dependency, settings, options);
272
- if (!ruleData.result) {
273
- context.report({
274
- message: errorMessage(ruleData, dependency),
275
- node,
276
- });
277
- }
278
- }
279
- });
@@ -1,5 +0,0 @@
1
- import type { DependencyDescription, ElementDescription } from "@boundaries/elements";
2
- export declare function warn(message: string): void;
3
- export declare function success(message: string): void;
4
- export declare function warnOnce(message: string): void;
5
- export declare function debugDescription(elementDescription: ElementDescription | DependencyDescription): void;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.warn = warn;
7
- exports.success = success;
8
- exports.warnOnce = warnOnce;
9
- exports.debugDescription = debugDescription;
10
- const elements_1 = require("@boundaries/elements");
11
- const chalk_1 = __importDefault(require("chalk"));
12
- const Settings_1 = require("../Settings");
13
- const warns = [];
14
- const debuggedFiles = [];
15
- const COLORS_MAP = {
16
- gray: "gray",
17
- green: "green",
18
- yellow: "yellow",
19
- };
20
- function trace(message, color) {
21
- // eslint-disable-next-line no-console
22
- console.log(chalk_1.default[COLORS_MAP[color]](`[${Settings_1.PLUGIN_NAME}]: ${message}`));
23
- }
24
- function warn(message) {
25
- trace(message, COLORS_MAP.yellow);
26
- }
27
- function success(message) {
28
- trace(message, COLORS_MAP.green);
29
- }
30
- function warnOnce(message) {
31
- if (!warns.includes(message)) {
32
- warns.push(message);
33
- warn(message);
34
- }
35
- }
36
- function debugDescription(elementDescription) {
37
- const isDependency = (0, elements_1.isDependencyDescription)(elementDescription);
38
- const key = isDependency
39
- ? elementDescription.to.source
40
- : elementDescription.path || "";
41
- const type = isDependency
42
- ? elementDescription.to.type
43
- : elementDescription.type;
44
- if ((0, Settings_1.isDebugModeEnabled)() && !debuggedFiles.includes(key)) {
45
- debuggedFiles.push(key);
46
- if (type) {
47
- success(`'${key}' is of type '${type}'`);
48
- }
49
- else {
50
- warn(`'${key}' is of unknown type`);
51
- }
52
- trace(`\n${JSON.stringify(elementDescription, null, 2)}`, COLORS_MAP.gray);
53
- }
54
- }
@@ -1,2 +0,0 @@
1
- export * from "./Common";
2
- export * from "./Debug";