Problem
The compat/compat rule produces false positives when local variable or parameter names happen to collide with browser API names. Two related issues:
1. Arrow function / function expression parameters not recognized as local declarations
The Identifier visitor tracks locally declared names to suppress false positives when a name shadows a browser global. However, it only checks these parent node types: Property, FunctionDeclaration, VariableDeclarator, ClassDeclaration, ImportDefaultSpecifier, ImportSpecifier, ImportDeclaration.
Missing: ArrowFunctionExpression and FunctionExpression.
This means callback parameters that share a name with a browser API are flagged:
// Flagged as "scheduler is not supported in Safari 26.2"
// but 'scheduler' here is a domain object, not Window.scheduler
schedulers.map(scheduler => scheduler.name);
// Same issue with function expressions
items.map(function(fetch) { return fetch.toString(); });
2. Early-return guard pattern not recognized as feature detection
The existing isInsideIfStatement check only suppresses errors for API usage inside an if block. The common early-return guard pattern is not detected:
function setup() {
if (!('serviceWorker' in navigator)) {
return; // early exit if API unavailable
}
// This usage is safe but still flagged:
navigator.serviceWorker.register('/sw.js');
}
Impact
In a large codebase, these false positives can produce dozens of spurious errors, particularly when domain entities share names with newer browser APIs (e.g. scheduler matching the Prioritized Task Scheduling API Window.scheduler).
Problem
The
compat/compatrule produces false positives when local variable or parameter names happen to collide with browser API names. Two related issues:1. Arrow function / function expression parameters not recognized as local declarations
The
Identifiervisitor tracks locally declared names to suppress false positives when a name shadows a browser global. However, it only checks these parent node types:Property,FunctionDeclaration,VariableDeclarator,ClassDeclaration,ImportDefaultSpecifier,ImportSpecifier,ImportDeclaration.Missing:
ArrowFunctionExpressionandFunctionExpression.This means callback parameters that share a name with a browser API are flagged:
2. Early-return guard pattern not recognized as feature detection
The existing
isInsideIfStatementcheck only suppresses errors for API usage inside anifblock. The common early-return guard pattern is not detected:Impact
In a large codebase, these false positives can produce dozens of spurious errors, particularly when domain entities share names with newer browser APIs (e.g.
schedulermatching the Prioritized Task Scheduling APIWindow.scheduler).