OfficeDev / OfficeDev/Office-Addin-Scripts
eslint-plugin-office-addins: load-object-before-read doesn't understand ClientResult
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 194
- Forks
- 117
- Avg merge
- 1d 32m
- Merged PRs (30d)
- 2
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: eslint-plugin-office-addins@3.0.2
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the load-object-before-read rule and reproduce the ClientResult example from the issue, including awaiting context.sync() before reading value. The work is done when the rule no longer reports an error for that access pattern while continuing to check ordinary objects that require an explicit load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- eslint, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100