Skip to main content

Overview

@diagnostic controls warnings for one line, the next line, or a block of code. Suppress false positives without disabling diagnostics for your entire addon.

Syntax

---@diagnostic disable-next-line: code1, code2
---@diagnostic disable-line: code1
---@diagnostic disable: code1
---@diagnostic enable: code1

disable-next-line

Suppress diagnostics on the next line only:
---@diagnostic disable-next-line: undefined-global
print(someExternalGlobal)  -- suppressed
print(anotherGlobal)       -- NOT suppressed

disable-line

Suppress diagnostics on the current line. Place it inline:
print(someGlobal) ---@diagnostic disable-line: undefined-global

Block disable/enable

Disable diagnostics for a section, then enable them again:
---@diagnostic disable: undefined-global
GLOBAL_A = "value"
GLOBAL_B = 42
GLOBAL_C = true
---@diagnostic enable: undefined-global

File-wide disable

A ---@diagnostic disable with no matching enable suppresses diagnostics for the rest of the file:
---@diagnostic disable: undefined-global
-- All undefined-global diagnostics in this file are suppressed

Multiple codes

Suppress multiple diagnostics at once:
---@diagnostic disable-next-line: undefined-global, param-type-mismatch
legacyFunction(someGlobal)

Common codes to suppress

CodeWhen to suppress
undefined-globalGlobal used that’s defined externally (e.g., from another file loaded at runtime)
param-type-mismatchPassing a compatible type that differs from the annotation, or a known false positive
unusedVariable used as documentation or placeholder
inject-fieldAdding fields to a type outside its definition intentionally

Alternative: configure globally

If you suppress the same diagnostic often, disable it or change its severity in .gluarc.json:
Use the settings menu instead of editing the JSON file directly. This helps you avoid config mistakes.
.gluarc.json
{
  "diagnostics": {
    "disable": ["undefined-global"],
    "severity": {
      "param-type-mismatch": "hint"
    }
  }
}
See Diagnostics configuration for all options.