Skip to content

Bug: tseslint.config hides user-friendly error messages from ESLint #10549

Closed
@abrahamguo

Description

@abrahamguo

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

According to the docs, tseslint.config is a helper function that

  1. gives you the ability to type-check your ESLint config, if you so desire, and
  2. adds support for the extends property on config objects.
    Besides that, it should have no other effect.

However, another "hidden" difference, when using tseslint.config, is that it suppresses user-friendly error messages from ESLint.

For example, if a config object is undefined, ESLint returns:
TypeError: Config (unnamed): Unexpected undefined config at user-defined index 0.

but tseslint.config returns:
TypeError: Cannot destructure property 'extends' of 'configWithExtends' as it is undefined.
which is a less-helpful error.

Now, in an ideal world, TypeScript would report that a user had passed undefined to the function. However, I think there are several things to consider:

  • Users may choose to keep their eslint.config.js in JavaScript, and not type-check it, while still using tseslint.config()
  • Users may misspell a preset of an ESLint plugin, and that ESLint plugin might not provide TS type definitions, e.g. tseslint.config(eslintPlugin['nonexistent-preset']);
  • No matter what happens on the TypeScript side, tseslint.config should not remove any functionality on the JavaScript side, since that's what the docs say.

Reproduction Repository Link

https://github.com/abrahamguo/repro/tree/undefined-config

Repro Steps

  1. clone the repo
  2. npm i
  3. npx eslint -c tseslint.config.js . — compare with npx eslint .

Versions

package version
typescript-eslint 8.18.2
ESLint 9.17.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinglocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions