Skip to content

no-accessor-recursion - improve detection #119

Description

@forivall

In my code, i sometimes use the pattern

class CustomError extends Error {
  constructor(someBigObject: any) {
    super()
    this.object = someBigObject
  }
  get message(): string {
    const value = `Failed ${util.inspect(this.object)}`
    this.message = value
    return value
  }
  set message(value: string) {
    Object.defineProperty(this, 'message', {value, configurable: true, enumerable: true, writable: true})
  }
}

Ideally, this should pass, and only fail if there's a get/access in the set and a set/assignment in the get (or a get/access in the get or a set/assignment in the set, obviously)

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions