-
Notifications
You must be signed in to change notification settings - Fork 68
Open
Description
Repro
Run tsc
on this eslint.config.mjs
.
import ts from 'typescript-eslint';
import mocha from 'eslint-plugin-mocha';
export default ts.config(
mocha.configs['recommended'],
);
Expected behavior
Type check should pass.
Actual behavior
Got the following errors.
eslint.config.mjs:10:5 - error TS18048: 'mocha.configs' is possibly 'undefined'.
10 mocha.configs['recommended'],
~~~~~~~~~~~~~
eslint.config.mjs:10:5 - error TS2345: Argument of type 'LegacyConfig<RulesRecord, RulesRecord> | Config<RulesRecord> | Config<RulesRecord>[]' is not assignable to parameter of type 'InfiniteDepthConfigWithExtends'.
Type 'LegacyConfig<RulesRecord, RulesRecord>' is not assignable to type 'InfiniteDepthConfigWithExtends'.
Type 'LegacyConfig<RulesRecord, RulesRecord>' is not assignable to type 'ConfigWithExtends'.
Types of property 'extends' are incompatible.
Type 'string | string[] | undefined' is not assignable to type 'InfiniteDepthConfigWithExtends[] | undefined'.
Type 'string' is not assignable to type 'InfiniteDepthConfigWithExtends[]'.
10 mocha.configs['recommended'],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 2 errors in the same file, starting at: eslint.config.mjs:10
Description
These errors were caused because the mocha
instance is typed as ESLint.Plugin
.
eslint-plugin-mocha/source/plugin.ts
Line 81 in 1e5a3a1
const mochaPlugin: ESLint.Plugin = { |
ESLint.Plugin
is a generic eslint plugin object which knows nothing about eslint-plugin-mocha. So it types configs
field as optional. However eslint-plugin-mocha actually sets the configs
field and the field should not be optional.
sschadwick and mdmower-csnw
Metadata
Metadata
Assignees
Labels
No labels