Skip to content

Changed result matching comment in JS class member in ^0.45.0 #2867

Description

@HerringtonDarkholme

Discussed in #2866

Originally posted by donmccurdy August 3, 2026
I'm trying to match any JSDoc comment on a JavaScript class member containing the JSDoc tag @memberof, and to remove that tag. In v0.44 I used the following successfully:

id: no-jsdoc-memberof
message: >
  ES6 class members do not require @memberof tags.
severity: error
language: JavaScript
files:
  - packages/engine/Source/**/*.js
rule:
  kind: comment
  regex: "(?i)@memberof"
  pattern: $COMMENT
  inside:
    kind: class_declaration
    stopBy: end
transform:
  COMMENT_FIX: replace($COMMENT, replace="(?i)\n.*@memberof.*\n", by="\n")
fix: '$COMMENT_FIX'

As of v0.45, the rule no longer detects any issues on the following code block:

class MyClass {
  /** @memberof MyClass.prototype */
  get myProp() { return 1; }
}

If I remove the pattern: $COMMENT line, the rule detects the issue again, but the transform no longer applies. I'm not 100% sure that I've understood some relevant FAQ entries so I'm not reporting this as a bug yet, but it seems unexpected to me to get a different result from v0.44 and v0.45. Any advice appreciated, thanks!

If this is intended, I can remove the transform. Just using ast-grep to detect the issue would be OK for my purposes, without necessary auto-fixing it.

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions