fix: scope import-direction to JS/TS with honest skip for other languages#86
Merged
Merged
Conversation
…cuous pass import-direction only parses JS/TS ES-module imports, but it reported available+0 edges (a PASS) on a project whose module-path dirs exist yet hold no JS/TS source — falsely claiming the dependency direction was verified. - set `available` only when JS/TS source is actually found; otherwise report honest `skipped` with a reason that says the check is JS/TS-only and points to the language's own import linter (import-linter / deptrac / packwerk / …) - JS/TS behavior unchanged (edge collection/attribution/sort); existing tests green - validated on a large real-world Python project: was a vacuous PASS, now skipped - supersedes the abandoned tree-sitter multi-language attempt — native per-language architecture linters do cross-language dependency-direction far better
67fcb41 to
18ce12c
Compare
Prospec Check |
Test Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
摘要
drift 的 import-direction 檢查只解析 JS/TS ES-module import,但在非 JS/TS 專案上,它掃到 0 個 JS/TS 檔卻仍回報
available+ 0 邊 →評估為 PASS——一個空洞 PASS,假裝依賴方向已驗、實際一個檔都沒看,違反 drift 引擎「來源不可得 → skipped,絕不空洞 PASS」的原則。本 PR 把 import-direction 明確收斂為 JS/TS-only + 誠實 skipped:
available僅在實際掃到 JS/TS 源碼檔時成立;module paths 下無任何 JS/TS 源碼(即使目錄存在、含其他語言)→ 回報skipped,原因明示「JS/TS-only」並指向該語言的原生 import linter(import-linter / deptrac / packwerk / dependency-cruiser …)。為什麼不做跨語言解析
一度嘗試以 tree-sitter 擴充為 11 語言(見已擱置的 spike),但在一個大型真實 Python 專案上驗證發現:主流的絕對 import(
from <pkg>.x,佔 ~84%)需要 package-root 解析,等於重寫各語言成熟的架構 linter,ROI 低且維護重(+22MB grammar、WASM 依賴)。每個語言都有專門、AST 精準的原生工具(Python import-linter、PHP deptrac、Ruby packwerk、JS/TS dependency-cruiser、Java ArchUnit …),prospec 不該重造。誠實 skipped + 指路,遠優於誤導的空洞 PASS。驗證
skipped(帶 JS/TS-only + import-linter 指路)。