Skip to content

Commit

Permalink
feat: runLinter uses ``withImportModules #[module, Batteries.Tactic.L…
Browse files Browse the repository at this point in the history
…int]`` (#931)
  • Loading branch information
kim-em authored Sep 2, 2024
1 parent a7fd140 commit e776546
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripts/runLinter.lean
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,24 @@ unsafe def main (args : List String) : IO Unit := do
stdin := .null
}
_ ← child.wait
-- If the linter is being run on a target that doesn't import `Batteries.Tactic.List`,
-- the linters are ineffective. So we import it here.
let lintModule := `Batteries.Tactic.Lint
let lintFile ← findOLean lintModule
unless (← lintFile.pathExists) do
-- run `lake build +Batteries.Tactic.Lint` (and ignore result) if the file hasn't been built yet
let child ← IO.Process.spawn {
cmd := (← IO.getEnv "LAKE").getD "lake"
args := #["build", s!"+{lintModule}"]
stdin := .null
}
_ ← child.wait
let nolintsFile : FilePath := "scripts/nolints.json"
let nolints ← if ← nolintsFile.pathExists then
readJsonFile NoLints nolintsFile
else
pure #[]
withImportModules #[{module}] {} (trustLevel := 1024) fun env =>
withImportModules #[module, lintModule] {} (trustLevel := 1024) fun env =>
let ctx := { fileName := "", fileMap := default }
let state := { env }
Prod.fst <$> (CoreM.toIO · ctx state) do
Expand Down

0 comments on commit e776546

Please sign in to comment.