Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
ota-meshi merged 7 commits intomasterfromignore-object-names
Sep 22, 2025

Conversation

@waynzh
Copy link
Member

resolve#2917

@changeset-bot
Copy link

changeset-botbot commentedSep 5, 2025
edited
Loading

🦋 Changeset detected

Latest commit:d5805cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
eslint-plugin-vueMinor

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

export default {
computed: {
foo: function () {
return z.a.b.c.d.e.f.method().catch(err => err).finally(() => {})
Copy link
Member

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 😄

Suggested change
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)

Copy link
MemberAuthor

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...

Copy link
Contributor

CopilotAI left a 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 newignoredObjectNames array 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.

FileDescription
lib/rules/no-async-in-computed-properties.jsImplements core logic for theignoredObjectNames option with root object name extraction
tests/lib/rules/no-async-in-computed-properties.jsAdds comprehensive test cases for valid and invalid usage with the new option
docs/rules/no-async-in-computed-properties.mdUpdates documentation with option details and Zod usage examples
.changeset/cute-bears-sneeze.mdAdds changelog entry for the minor version feature

Tip: Customize your code reviews with copilot-instructions.md.Create the file orlearn how to get started.

Comment on lines 46 to 76
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
}
Copy link

CopilotAISep 5, 2025

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.

Copilot uses AI. Check for mistakes.
returnfalse
}

constrootObjectName=getRootObjectName(callee)
Copy link

CopilotAISep 5, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Member

@FloEdelmannFloEdelmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks!

waynzh reacted with heart emoji
Copy link
Member

@ota-meshiota-meshi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM! Thanks!

@ota-meshiota-meshi merged commit79d6a31 intomasterSep 22, 2025
15 checks passed
@ota-meshiota-meshi deleted the ignore-object-names branchSeptember 22, 2025 01:20
@github-actionsgithub-actionsbot mentioned this pull requestSep 18, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

Copilot code reviewCopilotCopilot left review comments

@FloEdelmannFloEdelmannFloEdelmann approved these changes

@ota-meshiota-meshiota-meshi approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Vue ESLint: false positive of vue/no-async-in-computed-properties due to using zod .catch inside a computed

4 participants

@waynzh@FloEdelmann@ota-meshi

[8]ページ先頭

©2009-2025 Movatter.jp