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

huangapple go评论158阅读模式
英文:

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

问题

/** @type {???} */
export default [
  {
    rules: {...}
  }
]
英文:

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

/** @type {???} */
export default [
  {
    rules: {...}
  }
]

答案1

得分: 9

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

You import declarations, including library types, to JSDoc using import types. For your specific case the relevant type is FlatConfig, so:

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

Note you will need to install @types/eslint for FlatConfig to appear on Linter.

huangapple
  • 本文由 发表于 2023年3月9日 19:42:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/75684118.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定