Description
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
- gives you the ability to type-check your ESLint config, if you so desire, and
- 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 usingtseslint.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
- clone the repo
npm i
npx eslint -c tseslint.config.js .
— compare withnpx eslint .
Versions
package | version |
---|---|
typescript-eslint |
8.18.2 |
ESLint |
9.17.0 |