jsdoc/check-property-names Correctness
作用
确保 JSDoc 中的属性名称在同一个块内不会重复,并且嵌套属性具有已定义的根属性。
为什么这很糟糕?
具有相同名称的 @property 标签可能会让人困惑,并且可能表明存在错误。
示例
此规则的错误代码示例:
javascript
/**
* @typedef {object} state
* @property {number} foo
* @property {string} foo
*/
/**
* @typedef {object} state
* @property {number} foo.bar
*/此规则的正确代码示例:
javascript
/**
* @typedef {object} state
* @property {number} foo
*/
/**
* @typedef {object} state
* @property {object} foo
* @property {number} foo.bar
*/如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jsdoc"],
"rules": {
"jsdoc/check-property-names": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jsdoc"],
rules: {
"jsdoc/check-property-names": "error",
},
});bash
oxlint --deny jsdoc/check-property-names --jsdoc-plugin版本
此规则于 v0.2.18 中新增。
