amilajack / amilajack/eslint-plugin-compat

Not every `requestIdleCallback()` reported as not supported in Safari

Aberta
#648 0 comentários 0 reações 0 responsáveis Ver no GitHub
Linguagem predominante
TypeScript
Estrelas
3.2k
Forks
115
Métricas de merge de PRs
Nenhum PR com merge em 30d

Descrição

After #588 (which closed #554), eslint-plugin-compat correctly detects some usages of `requestIdleCallback()` (which is still not supported in Safari 18.3), but not all:

```js
// ✓ correctly detected as not supported:
window.requestIdleCallback();

// ⨉ not detected
requestIdleCallback();

// ⨉ not detected
const mywindow = window;
mywindow.requestIdleCallback();

// ⨉ not detected
document.querySelector('iframe').contentWindow.requestIdleCallback()
```

I can only speculate that it is a performance optimization to match only CallExpressions where the callee is a MemberExpression _with the object being an Identifier named "window"_ and the property also being an Identifier named "requestIdleCallback", i.e.

```jsonc
// window.requestIdleCallback()
{
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"object": {"type": "Identifier", "name": "window"},
"property": {"type": "Identifier", "name": "requestIdleCallback"}
}
}
```

Matching, on the one hand, CallExpressions with an Identifier named "window" being the direct callee, like

```jsonc
// requestIdleCallback()
{
"type": "CallExpression",
"callee": {"type": "Identifier", "name": "requestIdleCallback"}
}
```

or, on the other hand, CallExpressions where the callee is a MemberExpression with the property being an Identifier named "requestIdleCallback", no matter what the object is, like

```jsonc
// mywindow.requestIdleCallback()
// document.querySelector('iframe').contentWindow.requestIdleCallback();
{
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"property": {"type": "Identifier", "name": "requestIdleCallback"}
}
}
```

or, maybe too broad, just matching the Identifier "requestIdleCallback" in general, without considering CallExpressions, like

```jsonc
// requestIdleCallback
{"type": "Identifier", "name": "requestIdleCallback"}
```

could solve this.

(On a side note: what an awesome project, thank you so much for this effort!)

---

Edit: should this issue have been directly reported for [ast-metadata-inferer](https://github.com/amilajack/ast-metadata-inferer) instead?

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.