Skip to content

Commit

Permalink
fix: requestIdleCallback and requestAnimationFrame provider (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshay090 authored Aug 27, 2023
1 parent b2cd1c6 commit 2cec0c7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/providers/caniuse-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,18 @@ const CanIUseProvider: Array<AstMetadataApiWithTargetsResolver> = [
object: "performance",
property: "now",
},
// requestIdleCallback()
{
caniuseId: "requestidlecallback",
astNodeType: AstNodeTypes.CallExpression,
object: "requestIdleCallback",
},
// requestAnimationFrame()
{
caniuseId: "requestanimationframe",
astNodeType: AstNodeTypes.CallExpression,
object: "requestAnimationFrame",
},
{
caniuseId: "typedarrays",
astNodeType: AstNodeTypes.NewExpression,
Expand Down
22 changes: 22 additions & 0 deletions test/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,5 +667,27 @@ ruleTester.run("compat", rule, {
},
],
},
{
code: "window.requestIdleCallback(() => {})",
settings: {
browsers: ["safari 12"],
},
errors: [
{
message: "requestIdleCallback is not supported in Safari 12",
},
],
},
{
code: "window.requestAnimationFrame(() => {})",
settings: {
browsers: ["OperaMini all"],
},
errors: [
{
message: "requestAnimationFrame is not supported in op_mini all",
},
],
},
],
});

0 comments on commit 2cec0c7

Please sign in to comment.