Skip to content

fix(lint): clear warnings in version-check scripts#37

Closed
eouzoe wants to merge 1 commit into
mainfrom
pr/scripts-fixes
Closed

fix(lint): clear warnings in version-check scripts#37
eouzoe wants to merge 1 commit into
mainfrom
pr/scripts-fixes

Conversation

@eouzoe

@eouzoe eouzoe commented Jul 16, 2026

Copy link
Copy Markdown
Owner

修改了什麼

修復 scripts/check-env.mjsscripts/check-versions.mjs 兩個 lint/邏輯警告:

  • check-env.mjs:移除未使用的 readdirSync import;版本正則 [-+][0-9A-Za-z.\-]+ 改為 [-+][0-9A-Za-z.-]+.- 在字元類別中順序無關,原寫法多一個冗餘跳脫)。
  • check-versions.mjs[...directDeps.entries()].sort() 改為顯式 .sort((a, b) => a[0].localeCompare(b[0])),避免對 [name, range] 陣列做不可靠的預設字典序排序。

為什麼要修改

  • 未使用 import 會觸發 oxlint no-unused-vars 警告。
  • .sort()[string, string] 陣列用預設比較,行為依賴實作且會對整個 tuple 而非鍵名排序,改為按套件名 localeCompare 才正確穩定。

功能

  • 無新功能;純清理與排序修正。

涉及檔案

  • scripts/check-env.mjs(2 行)
  • scripts/check-versions.mjs(1 行)

影響

  • check-versions.mjs 輸出順序改為依套件名字母排序(更可讀),不影響過期判斷邏輯。
  • 兩腳本仍 exit 0(無過期時)/exit 1(有過期時)。

參考文件 / 依據

  • oxlint no-unused-vars;JS Array.prototype.sort 預設行為。

測試

  • node --check 兩腳本語法通過。
  • bun scripts/check-env.mjs 實際執行 exit 0。
  • bun scripts/check-versions.mjs 實際執行 exit 0,過期列表正常輸出(sort 修復生效)。

@eouzoe eouzoe closed this Jul 16, 2026
@eouzoe
eouzoe deleted the pr/scripts-fixes branch July 16, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant