@avelonjs/bailiff 0.8.3 → 0.8.4
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/package.json +1 -1
- package/src/paths.ts +8 -10
- package/src/suppress.ts +1 -1
package/package.json
CHANGED
package/src/paths.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
-
import { dirname, join,
|
|
2
|
+
import { dirname, join, relative, sep } from 'node:path'
|
|
3
3
|
|
|
4
4
|
/** Layer a source file belongs to, used by architecture rules. */
|
|
5
5
|
export type FileLayer =
|
|
@@ -21,12 +21,7 @@ export type FileLayer =
|
|
|
21
21
|
| 'request'
|
|
22
22
|
| 'other'
|
|
23
23
|
|
|
24
|
-
const GENERATED_MARKERS = [
|
|
25
|
-
'/app/(web)/',
|
|
26
|
-
'/app/(api)/',
|
|
27
|
-
'/framework/routing/',
|
|
28
|
-
'/database/types.ts',
|
|
29
|
-
]
|
|
24
|
+
const GENERATED_MARKERS = ['/app/(web)/', '/app/(api)/']
|
|
30
25
|
|
|
31
26
|
const VENDOR_PACKAGES = [
|
|
32
27
|
'@supabase/supabase-js',
|
|
@@ -46,14 +41,17 @@ const VENDOR_PACKAGES = [
|
|
|
46
41
|
|
|
47
42
|
/** Normalizes a file path to posix so fixtures and Windows paths classify the same way. */
|
|
48
43
|
export function posixPath(filePath: string): string {
|
|
49
|
-
return filePath.
|
|
44
|
+
return filePath.replaceAll('\\', '/')
|
|
50
45
|
}
|
|
51
46
|
|
|
52
47
|
/** Returns true when `filePath` is framework-generated and must not be hand-edited. */
|
|
53
48
|
export function isGeneratedPath(filePath: string): boolean {
|
|
54
49
|
const normalized = posixPath(filePath)
|
|
55
50
|
if (GENERATED_MARKERS.some((marker) => normalized.includes(marker))) return true
|
|
56
|
-
return
|
|
51
|
+
return (
|
|
52
|
+
/\/framework\/routing\/[^/]+\.generated\.ts$/.test(normalized) ||
|
|
53
|
+
normalized.endsWith('/database/types.ts')
|
|
54
|
+
)
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
/** Returns true when the specifier is a known vendor SDK. */
|
|
@@ -61,7 +59,7 @@ export function isVendorSpecifier(specifier: string): boolean {
|
|
|
61
59
|
if (specifier.startsWith('@supabase/')) return true
|
|
62
60
|
if (specifier.startsWith('@aws-sdk/')) return true
|
|
63
61
|
if (specifier.startsWith('@neondatabase/')) return true
|
|
64
|
-
return VENDOR_PACKAGES.
|
|
62
|
+
return VENDOR_PACKAGES.some((name) => specifier === name || specifier.startsWith(`${name}/`))
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
/** Classifies a source file into the architecture layer Bailiff enforces. */
|
package/src/suppress.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function isSuppressed(
|
|
|
39
39
|
const line = node.loc?.start.line
|
|
40
40
|
if (line === undefined) return false
|
|
41
41
|
return disableComments(context).some((comment) => {
|
|
42
|
-
if (comment.line !== line - 1
|
|
42
|
+
if (comment.line !== line - 1) return false
|
|
43
43
|
if (comment.reason === undefined) return false
|
|
44
44
|
return comment.rule === undefined || comment.rule === rule
|
|
45
45
|
})
|