stenciljs/eslint-plugin

`expression.callee` is undefined when evaluating custom decorators

Open

#121 geöffnet am 24. Okt. 2024

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)TypeScript (37 Forks)auto 404
Help Wanted

Repository-Metriken

Stars
 (71 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Hello, when using the linter, I have an error exactly here: https://github.com/stencil-community/stencil-eslint/blob/506dba7a5e430da4cfabe96b8e1b1cb31fe07699/src/utils.ts#L50

When debugging the linter run, I have found that dec.expression.callee is undefined. The name of the decorator is situated directly on dec.expression. This issue is happening when using the decorator in this way:

@BindToInstance
  async onApply(
  ... 

instead of

@BindToInstance()
  async onApply(
  ... 

Do you agree to change it to:

function decoratorName(dec) {
  if (!dec.expression) return undefined;
  const { callee, name } = dec.expression;
  return callee ? callee.name : name;
}

Contributor Guide