Closed codeworrior closed 3 hours ago
In src/linter/ui5Types/SourceFileLinter.ts
the linter already analyzes the global associated properties in analyzePropertyAccessExpression
. The method extractNamespace
might not support cases if conditional access is used. Needs to be analyzed further.
PR https://github.com/SAP/ui5-linter/pull/132 fixes globalThis
.
top
, parent
and top level this
are still not reported but test cases are added.
The problem is that TypeScript seems to treat top
and parent
something different from window
or globalThis
.
While the derived type is Window
, TS fails to resolve any of the UI5 types to properties accessed on top
or parent
. This can be reproduced directly in VSCode as well.
For the top-level this
it's different however. VSCode can derive UI5 types correctly. Only in the linter we don't get them resolved for currently unknown reasons.
Expected Behavior
The linter should not complain about allowed globals, no matter how they are accessed.
Current Behavior
The linter complains about calls to
sap.ui.define
or other allowed globals when they are accessed viaglobalThis
or one of the other names that refer to the global JavaScript context (e.g.self
,window
,top
,parent
, top levelthis
).Example:
(found in sap/ui/documentation/sdk/util/Resources.js)
Context