eslint-plugin-office-addins: load-object-before-read doesn't understand ClientResult #877
Description
Expected behavior
When using a ClientResult, calling load
is not required (in fact there is no load()
) – instead context.sync()
is sufficient to make its value
available.
The load-object-before-read
rule should understand this exception and not show an error in this situation.
Current behavior
The load-object-before-read
rule shows an error where value
is accessed on a ClientResult, even after awaiting context.sync()
.
Note that the code works fine in Office, this is only an error in the linter.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- Attempt to use a ClientResult's value after awaiting
context.sync()
(example code below)
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
- Operating System: macOS 14.5
- Node version: v22.4.1
- Office version: Microsoft Excel Version 16.87 (24071426)
- Tool version: [email protected]
Failure Logs
A simple test case based on the example on the documentation page for ClientResult:
const tableCount = context.workbook.tables.getCount();
// This sync call implicitly loads tableCount.value.
// Any other ClientResult values are loaded too.
await context.sync();
console.log(tableCount.value); // eslint error: An explicit load call on 'tableCount' for property 'value' needs to be made before the property can be read.
Seems to be the same issue as someone is experiencing here: https://stackoverflow.com/questions/78191843/do-we-need-to-call-load-before-reading-ooxml-of-an-api-object