oxc-project/oxc · error · syn::Error

missing `version = "x.y.z"` or `version = "next"` in `declar

Error message

missing `version = "x.y.z"` or `version = "next"` in `declare_oxc_lint!`

What it means

Compile-time error raised inside the declare_oxc_lint! proc-macro parse function when a rule declaration omits the required version attribute. Every lint rule must record the oxc version it shipped in (or "next" for unreleased), so the macro refuses to generate the rule metadata without it.

Source

Thrown at crates/oxc_macros/src/declare_oxc_lint.rs:201

                    if input.peek(Token!(=)) || fix.is_some() {
                        return Err(Error::new_spanned(key, "unexpected key in rule declaration"));
                    }
                    // fix kind shorthand, e.g. `dangerous-suggestion``
                    fix.replace(key);
                }
            }
        }

        let remaining = input.parse::<proc_macro2::TokenStream>()?;
        if !remaining.is_empty() {
            return Err(Error::new_spanned(
                remaining,
                "unexpected tokens in rule declaration, missing a comma?",
            ));
        }

        let Some(version) = version else {
            return Err(Error::new(
                struct_name.span(),
                "missing `version = \"x.y.z\"` or `version = \"next\"` in `declare_oxc_lint!`",
            ));
        };

        // Validate that any markdown fenced code blocks (```) in rule docs are properly closed.
        // If the total number of fences found is odd, a block was not closed.
        #[cfg(feature = "ruledocs")]
        if !backtick_fences_count.is_multiple_of(2) {
            return Err(Error::new(
                struct_name.span(),
                "unclosed markdown code block in documentation, please close all ``` fences",
            ));
        }
        #[cfg(feature = "ruledocs")]
        let Some(documentation) = documentation else {
            return Err(Error::new(
                struct_name.span(),

View on GitHub (pinned to a3d33dda7c)

Solutions

  1. Add version = "next" to the declare_oxc_lint! block for unreleased rules
  2. Or set version = "x.y.z" matching the release the rule ships in
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_macros/src/declare_oxc_lint.rs:181 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@a3d33dda7c (2026-08-20). Data as JSON: /api/errors/037b0288d724e545. Report an issue: GitHub.