Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get type hints for ESLint's new config file (eslint.config.js)?

Tags:

eslint

In an eslint.config.js file, how can I get TypeScript type hints for the new config object?

/** @type {???} */
export default [
  {
    rules: {...}
  }
]
like image 358
golopot Avatar asked Sep 10 '25 18:09

golopot


2 Answers

You import declarations, including library types, to JSDoc using import types.

For your specific case the relevant type is Config, so:

/** @type { import("eslint").Linter.Config[] } */
export default [
  // get hints here
];

Note:

  • the v8 types called this FlatConfig, which is still available as a deprecated alias in the v9 types; and
  • you may need to explicitly install @types/eslint for Config/FlatConfig to appear on Linter.
like image 70
jonrsharpe Avatar answered Sep 13 '25 08:09

jonrsharpe


for eslint v9 use: change the file name to eslint.config.mjs

    /** @type { import("eslint").Linter.Config[] } */
    export default [...]
like image 26
ary_yan Avatar answered Sep 13 '25 09:09

ary_yan