@blumintinc/eslint-plugin-blumint 1.20.11 → 1.20.12

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.
package/lib/index.js CHANGED
@@ -223,7 +223,7 @@ function noFrontendImportsFromFunctionsPatterns(pattern) {
223
223
  module.exports = {
224
224
  meta: {
225
225
  name: '@blumintinc/eslint-plugin-blumint',
226
- version: '1.20.11',
226
+ version: '1.20.12',
227
227
  },
228
228
  parseOptions: {
229
229
  ecmaVersion: 2020,
@@ -13,6 +13,26 @@ const DEFAULT_OPTIONS = {
13
13
  additionalSubjectExtensions: [],
14
14
  };
15
15
  const normalizeExtension = (extension) => extension.startsWith('.') ? extension : `.${extension}`;
16
+ /**
17
+ * A suite may be split by concern into `Subject.<qualifier>.test.tsx` files that
18
+ * sit beside `Subject.tsx`. Progressively dropping trailing dot-segments lets
19
+ * such a test resolve to its subject at any qualifier depth, while never
20
+ * crossing a directory boundary — a genuinely misplaced test still reports.
21
+ * Empty prefixes are dropped so a dotfile stem cannot match a bare `.ts`.
22
+ */
23
+ const subjectBaseNamesFor = (stem) => {
24
+ const segments = stem.split('.');
25
+ const baseNames = [];
26
+ for (let depth = segments.length; depth > 0; depth--) {
27
+ const baseName = segments.slice(0, depth).join('.');
28
+ if (baseName) {
29
+ baseNames.push(baseName);
30
+ }
31
+ }
32
+ // An extensionless stem (a file named exactly ".test.ts") leaves nothing to
33
+ // probe; keep it so the report still names what was looked for.
34
+ return baseNames.length > 0 ? baseNames : [stem];
35
+ };
16
36
  exports.testFileLocationEnforcement = (0, createRule_1.createRule)({
17
37
  name: 'test-file-location-enforcement',
18
38
  meta: {
@@ -57,17 +77,22 @@ exports.testFileLocationEnforcement = (0, createRule_1.createRule)({
57
77
  }
58
78
  const directory = path_1.default.dirname(filename);
59
79
  const testFileName = path_1.default.basename(filename);
60
- const baseName = testFileName.replace(TEST_FILE_PATTERN, '');
61
- const candidates = subjectExtensions.map((extension) => path_1.default.join(directory, `${baseName}${extension}`));
62
- const hasSibling = candidates.some((candidate) => fs_1.default.existsSync(candidate));
80
+ const stem = testFileName.replace(TEST_FILE_PATTERN, '');
81
+ const baseNames = subjectBaseNamesFor(stem);
82
+ const hasSibling = baseNames.some((baseName) => subjectExtensions.some((extension) => fs_1.default.existsSync(path_1.default.join(directory, `${baseName}${extension}`))));
63
83
  if (hasSibling) {
64
84
  return;
65
85
  }
66
86
  const relativePath = path_1.default.isAbsolute(filename)
67
87
  ? path_1.default.relative(process.cwd(), filename) || filename
68
88
  : filename;
69
- const expectedNames = subjectExtensions
70
- .map((extension) => `"${baseName}${extension}"`)
89
+ // Naming the shortest prefix alongside the full stem keeps the guidance
90
+ // honest: either subject name satisfies the rule.
91
+ const reportedBaseNames = baseNames.length > 1
92
+ ? [baseNames[0], baseNames[baseNames.length - 1]]
93
+ : baseNames;
94
+ const expectedNames = reportedBaseNames
95
+ .flatMap((baseName) => subjectExtensions.map((extension) => `"${baseName}${extension}"`))
71
96
  .join(' or ');
72
97
  context.report({
73
98
  node,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blumintinc/eslint-plugin-blumint",
3
- "version": "1.20.11",
3
+ "version": "1.20.12",
4
4
  "description": "Custom eslint rules for use within BluMint",
5
5
  "author": {
6
6
  "name": "Brodie McGuire",
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "version": "1.20.12",
4
+ "date": "2026-07-28T22:32:01.811Z",
5
+ "rules": [
6
+ {
7
+ "name": "test-file-location-enforcement",
8
+ "changeType": "fix",
9
+ "issues": [
10
+ 1372
11
+ ],
12
+ "summary": "accept suite-qualifier test files (closes #1372)"
13
+ }
14
+ ]
15
+ },
2
16
  {
3
17
  "version": "1.20.11",
4
18
  "date": "2026-07-28T20:40:15.882Z",