@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
|
@@ -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
|
|
61
|
-
const
|
|
62
|
-
const hasSibling =
|
|
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
|
-
|
|
70
|
-
|
|
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
package/release-manifest.json
CHANGED
|
@@ -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",
|