Skip to content

fix(no-callback-literal): report object, array, and template literals - #552

Merged
aladdin-add merged 1 commit into
eslint-community:masterfrom
baevm:no-callback-literal-fix-regression
Jul 11, 2026
Merged

fix(no-callback-literal): report object, array, and template literals#552
aladdin-add merged 1 commit into
eslint-community:masterfrom
baevm:no-callback-literal-fix-regression

Conversation

@baevm

@baevm baevm commented Jul 10, 2026

Copy link
Copy Markdown

What is the purpose of this pull request?

fixes regression in no-callback-literal rule with objects, arrays and template literals.

What changes did you make? (Give an overview)

added reporting on objects, arrays and template literals

Related Issues

#520 (comment).

Is there anything you'd like reviewers to focus on?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a regression in the no-callback-literal rule so it correctly reports additional non-error “literal-like” values (object literals, array literals, and template literals) when they’re used as the first (error) argument in Node-style callbacks.

Changes:

  • Update couldBeError() to explicitly treat ArrayExpression, ObjectExpression, and TemplateLiteral as not being possible Error objects.
  • Add test coverage to ensure the rule reports these cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/lib/rules/no-callback-literal.js Adds invalid test cases for object, array, and template literals passed as the error argument.
lib/rules/no-callback-literal.js Updates couldBeError() to return false for ArrayExpression, ObjectExpression, and TemplateLiteral, enabling reporting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@aladdin-add aladdin-add left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants