eslint-plugin-import-x: Typescript issue in flat config: `Types of property 'parser' are incompatible`

Given the following flat config (in a shared config):

import importPlugin from "eslint-plugin-import-x";
import type {Linter} from "eslint";

export default [{
  plugins: {
    "import-x": importPlugin,
  },
}] satisfies Array<Linter.Config>;

I’m presented with the following boatload of a typescript error on line 6:

index.ts:6:5 - error TS2322: Type '{ configs: { recommended: { plugins: ["import-x"]; rules: { 'import-x/no-unresolved': "error"; 'import-x/named': "error"; 'import-x/namespace': "error"; 'import-x/default': "error"; 'import-x/export': "error"; 'import-x/no-named-as-default': "warn"; 'import-x/no-named-as-default-member': "warn"; 'import-x/no-duplica...' is not assignable to type 'Plugin'.
  Types of property 'configs' are incompatible.
    Type '{ recommended: { plugins: ["import-x"]; rules: { 'import-x/no-unresolved': "error"; 'import-x/named': "error"; 'import-x/namespace': "error"; 'import-x/default': "error"; 'import-x/export': "error"; 'import-x/no-named-as-default': "warn"; 'import-x/no-named-as-default-member': "warn"; 'import-x/no-duplicates': "warn...' is not assignable to type 'Record<string, LegacyConfig<RulesRecord, RulesRecord> | Config<RulesRecord> | Config<RulesRecord>[]>'.
      Property ''stage-0'' is incompatible with index signature.
        Type 'PluginConfig' is not assignable to type 'LegacyConfig<RulesRecord, RulesRecord> | Config<RulesRecord> | Config<RulesRecord>[]'.
          Type '{ plugins?: ["import-x"] | undefined; settings?: { "import-x/cache"?: { lifetime?: number | "∞" | "Infinity" | undefined; } | undefined; "import-x/core-modules"?: string[] | undefined; ... 9 more ...; "import-x/resolver-next"?: NewResolver[] | undefined; } | undefined; rules?: Record<...> | undefined; } & Config' is not assignable to type 'LegacyConfig<RulesRecord, RulesRecord> | Config<RulesRecord> | Config<RulesRecord>[]'.
            Type '{ plugins?: ["import-x"] | undefined; settings?: { "import-x/cache"?: { lifetime?: number | "∞" | "Infinity" | undefined; } | undefined; "import-x/core-modules"?: string[] | undefined; ... 9 more ...; "import-x/resolver-next"?: NewResolver[] | undefined; } | undefined; rules?: Record<...> | undefined; } & Config' is not assignable to type 'LegacyConfig<RulesRecord, RulesRecord>'.
              Types of property 'overrides' are incompatible.
                Type 'ConfigOverride[] | undefined' is not assignable to type 'ConfigOverride<RulesRecord>[] | undefined'.
                  Type 'ConfigOverride[]' is not assignable to type 'ConfigOverride<RulesRecord>[]'.
                    Type 'ConfigOverride' is not assignable to type 'ConfigOverride<RulesRecord>'.
                      Types of property 'parser' are incompatible.
                        Type 'string | null | undefined' is not assignable to type 'string | undefined'.
                          Type 'null' is not assignable to type 'string | undefined'.

Not sure how long this error is there, I’m still using eslintrc config, but am trying to finally migrate to flat.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 20 (14 by maintainers)

Most upvoted comments

Also same happens with a new default installation of eslint They are generates file like

/** @type {import('eslint').Linter.Config[]} */
export default []

Maybe should be reported to typescript-eslint? eslint introduced defineConfig support, typescript-eslint should be compatible in this case.