Skip to content
← Back to rules

jsdoc/require-property-type Correctness

它的作用

要求每个 @property 标签都具有类型值(在花括号内)。

为什么这很糟糕?

属性的类型应当被文档化。

示例

以下是此规则的不正确代码示例:

javascript
/**
 * @typedef {SomeType} SomeTypedef
 * @property foo
 */

以下是此规则的正确代码示例:

javascript
/**
 * @typedef {SomeType} SomeTypedef
 * @property {number} foo
 */

如何使用

To enable this rule using the config file or in the CLI, you can use:

json
{
  "plugins": ["jsdoc"],
  "rules": {
    "jsdoc/require-property-type": "error"
  }
}
ts
import { defineConfig } from "oxlint";

export default defineConfig({
  plugins: ["jsdoc"],
  rules: {
    "jsdoc/require-property-type": "error",
  },
});
bash
oxlint --deny jsdoc/require-property-type --jsdoc-plugin

版本

此规则于 v0.2.18 中添加。

参考资料