Skip to content

Tool directives can hide trailing reader-facing comments #1

Description

@sdfsdhgjkbmnmxc

Tool directives are currently exempted by matching a recognized prefix against the whole comment node. As a result, reader-facing prose appended to a directive is exempted as well.

For example:

// @ts-expect-error the upstream types are wrong

The directive itself is machine-facing and should pass, but the trailing explanation is ordinary prose and can become stale. The same loophole exists for prefixes such as nolint, noqa, and swiftlint.

Ideally, commentcensor would exempt only the machine-consumed directive and inspect any trailing prose. This cannot be fixed by simply splitting on whitespace: directive arguments such as # noqa: F401 are also machine-consumed, and each tool has its own syntax.

Keep the current behavior for now. A future fix should define the accepted syntax of each directive and test both valid arguments and trailing reader-facing text.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions