Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(linter): add no-promise-in-callback #7307

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

no-yan
Copy link
Contributor

@no-yan no-yan commented Nov 16, 2024

related: #4655

This PR implements a rule to detect Promises inside error-first callbacks, preventing the mixed usage of callbacks and Promises.

Example of problematic code:

a(function(err) { doThing().then(a) });
                  ^^^^^^^^^^^^^^

Original implementation

Copy link

graphite-app bot commented Nov 16, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “0-merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Nov 16, 2024
Copy link

codspeed-hq bot commented Nov 16, 2024

CodSpeed Performance Report

Merging #7307 will not alter performance

Comparing no-yan:feat/no-promise-in-callback (169fd16) with main (cf99be0)

Summary

✅ 30 untouched benchmarks

}
}

fn is_callback_function<'a>(node: &AstNode<'a>, ctx: &LintContext<'a>) -> bool {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the original ESLint implementation, some functions were located in the lib directory.
I moved them into this rule file because they are not used by other rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linter Area - Linter C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant