nielsr's picture
nielsr HF Staff
Add Formal Conjectures (snapshot 86a2f58): statements + files parquet, Lean project (part 7)
8ca48d7 verified
Raw History Blame Contribute Delete
2.12 kB

The namespace linter checks that every declaration is inside a namespace.

47
def namespaceLinter : Linter where run := withSetOptionIn fun stx ↦ do
body · 9 lines
  if getLinterValue linter.style.namespace (← getLinterOptions) then
    for id in (← Mathlib.Linter.getNamesFrom (stx.getPos?.getD default)) do
      let declName := id.getId
      if declName.hasMacroScopes then continue
      let nm := declName.components
      -- If the declaration has only one component, it's not in a namespace
      if nm.length == 1 then
        Linter.logLint linter.style.namespace id
          m!"The declaration '{declName}' is not inside a namespace. All declarations should be placed within a namespace."