Skip to content

Code spans and fenced blocks in plain comments are linted as prose #1208

Closed

Description

@chad-loder

Check for existing issues

  • Completed

Environment

macOS (arm64), built from source, v3 at cfb21a4.

Describe the bug / provide steps to reproduce it

In a comment read as plain lines, a word is only treated as code when it touches a backtick. A word in the middle of a code span is linted as prose, and so is everything in a fenced example. With an existence rule on ZEBRA and this test.ts:

/**
 * Reads it.
 *
 * ```ts
 * const ZEBRA = read();
 * ```
 */
export function f() {}

// A host (`fr_FR` → `jeu. 30 ZEBRA …`) fails, and ZEBRA is prose.
f();

vale test.ts reports 5:10 (inside the fence) and 10:31 (inside the span) as well as 10:52; only 10:52 is prose.

I have a fix with tests at v3...chad-loder:vale:fix/comment-code-masks. It masks these the way the doc-comment conventions already mask tags, so it depends on the fix for #1207. I'm holding both PRs while #1204 is open, per CONTRIBUTING: "Finish one before opening the next."

Activity

  1. jdkato commented on Oct 16, 2026

    @jdkato
    Member

    A comment with no format assigned is linted as plain lines, and in plain text a backtick is a character. Code spans and fences are Markdown; assign it and they're handled:

    [formats]
    ts = md
  2. chad-loder commented on Oct 16, 2026

    @chad-loder
    ContributorAuthor

    Thank you, that works. With ts = md the repro reports only 10:52, so my fix branch isn't needed.

    For anyone who finds this later: the comment is then read as Markdown throughout, so a line indented four or more spaces after a blank line is an indented code block and is skipped, just as it would be in a .md file. Most doc comments are already written that way, so it rarely comes up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions