如何获取 ESLint 新配置文件 (eslint.config.js) 的类型提示?

gol*_*pot 5 eslint

eslint.config.js文件中,如何获取新配置对象的 TypeScript 类型提示?

/** @type {???} */
export default [
  {
    rules: {...}
  }
]
Run Code Online (Sandbox Code Playgroud)

jon*_*rpe 14

您可以使用import types将声明(包括库类型)导入到 JSDoc 。对于您的具体情况,相关类型是FlatConfig,因此:

/** @type { import("eslint").Linter.FlatConfig[] } */
export default [
  // get hints here
];
Run Code Online (Sandbox Code Playgroud)

请注意,您需要安装@types/eslintforFlatConfig才能出现在 上Linter