Compare commits

...

1 Commits

Author SHA1 Message Date
Saoud Rizwan 6aa1ce9bab feat: add lint rule to enforce webview import boundaries
Adds a GritQL-based Biome plugin that enforces architectural separation
between the webview and extension code. The webview should only import
from @shared/* and its own modules, never from extension-only paths.

Blocked imports:
- @core/*
- @hosts/*
- @api/*
- @services/*
- @integrations/*
- @packages/*
- @generated/*

This catches violations at lint time, preventing architectural drift
that could break the gRPC bridge abstraction layer.
2025-12-28 13:50:26 -08:00
2 changed files with 41 additions and 0 deletions
+8
View File
@@ -131,6 +131,14 @@
"src/dev/grit/process-env.grit"
],
"overrides": [
{
"includes": [
"webview-ui/**"
],
"plugins": [
"src/dev/grit/webview-import-boundary.grit"
]
},
{
"includes": [
"**",
+33
View File
@@ -0,0 +1,33 @@
// Enforce import boundaries for webview code.
// The webview should only import from @shared/* and its own modules,
// never from extension-only paths like @core/*, @hosts/*, @api/*, etc.
// This maintains the architectural separation between webview and extension.
or {
// Regular imports
`import $x from $source` where {
or {
$source <: includes "@core/",
$source <: includes "@hosts/",
$source <: includes "@api/",
$source <: includes "@services/",
$source <: includes "@integrations/",
$source <: includes "@packages/",
$source <: includes "@generated/"
},
register_diagnostic(span=$source, message="Webview cannot import from extension modules. Use @shared/* for shared types or communicate via gRPC bridge.")
},
// Type imports
`import type $x from $source` where {
or {
$source <: includes "@core/",
$source <: includes "@hosts/",
$source <: includes "@api/",
$source <: includes "@services/",
$source <: includes "@integrations/",
$source <: includes "@packages/",
$source <: includes "@generated/"
},
register_diagnostic(span=$source, message="Webview cannot import types from extension modules. Use @shared/* for shared types.")
}
}