Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork698
AddedignoredObjectNames option tovue/no-async-in-computed-properties#2927
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
changeset-botbot commentedSep 5, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
🦋 Changeset detectedLatest commit:d5805cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means?Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| export default { | ||
| computed: { | ||
| foo: function () { | ||
| return z.a.b.c.d.e.f.method().catch(err => err).finally(() => {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
For some more elaborate tests 😄
| returnz.a.b.c.d.e.f.method().catch(err=>err).finally(()=>{}) | |
| returnz.a?.b!.['c'][d].e.f.method().catch(err=>err).finally(()=>{}) |
(The non-null assertion! needs the typescript-eslint parser, so maybe this should be a separate test)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Just pushed a commit that adds askipWrapper function to handle complex member expression chains with optional chaining support.
Decided not to use TypeScript AST node types directly since that could lead to a bunch of type conflicts...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR adds anignoredObjectNames option to thevue/no-async-in-computed-properties rule to allow certain object names to be ignored when using promise-like methods. This is useful for validation libraries like Zod that use.then(),.catch(), and.finally() method names for non-promise purposes.
- Adds schema validation for the new
ignoredObjectNamesarray option - Implements logic to extract root object names from member expression chains and skip reporting when they match ignored names
- Updates documentation with examples showing how to ignore Zod validation chains
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/rules/no-async-in-computed-properties.js | Implements core logic for theignoredObjectNames option with root object name extraction |
| tests/lib/rules/no-async-in-computed-properties.js | Adds comprehensive test cases for valid and invalid usage with the new option |
| docs/rules/no-async-in-computed-properties.md | Updates documentation with option details and Zod usage examples |
| .changeset/cute-bears-sneeze.md | Adds changelog entry for the minor version feature |
Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.
| functiongetRootObjectName(memberExpr){ | ||
| letcurrent=memberExpr.object | ||
| while(current){ | ||
| switch(current.type){ | ||
| case'MemberExpression':{ | ||
| current=utils.skipChainExpression(current.object) | ||
| break | ||
| } | ||
| case'CallExpression':{ | ||
| constcalleeExpr=utils.skipChainExpression(current.callee) | ||
| if(calleeExpr.type==='MemberExpression'){ | ||
| current=calleeExpr.object | ||
| }elseif(calleeExpr.type==='Identifier'){ | ||
| returncalleeExpr.name | ||
| }else{ | ||
| returnnull | ||
| } | ||
| break | ||
| } | ||
| case'Identifier':{ | ||
| returncurrent.name | ||
| } | ||
| default:{ | ||
| returnnull | ||
| } | ||
| } | ||
| } | ||
| returnnull | ||
| } |
CopilotAISep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The function parametermemberExpr suggests it expects aMemberExpression, but the function accessesmemberExpr.object without validation. If a non-MemberExpression node is passed, this will cause a runtime error when trying to access theobject property.
| returnfalse | ||
| } | ||
| constrootObjectName=getRootObjectName(callee) |
CopilotAISep 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
ThegetRootObjectName function expects aMemberExpression butcallee is already confirmed to be aMemberExpression at line 84. However, the function should validate its input parameter or the call should be made more explicit about the type being passed.
Co-authored-by: Flo Edelmann <git@flo-edelmann.de>
Co-authored-by: Flo Edelmann <git@flo-edelmann.de>
FloEdelmann left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks!
ota-meshi left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM! Thanks!
79d6a31 intomasterUh oh!
There was an error while loading.Please reload this page.
resolve#2917