jsdoc/check-tag-names 正确性
它的作用
报告无效的块标签名。 此外,在使用 TypeScript 等类型检查器时,还会检查那些多余的标签名。
这为什么不好?
使用无效标签会导致混淆,并使文档更难阅读。
示例
以下是此规则的错误代码示例:
javascript
/** @Param */
/** @foo */
/**
* 当使用类型时,这里是多余的。
* @type {string}
*/以下是此规则的正确代码示例:
javascript
/** @param */设置
允许的标签通过 settings.jsdoc.tagNamePreference 进行配置。 此规则没有仅限 CLI 的参数。
你可以通过添加一个键值对来添加自定义标签,其中键和值都与要添加的标签名称匹配,如下所示:
json
{
"plugins": ["jsdoc"],
"rules": {
"jsdoc/check-tag-names": "error"
},
"settings": {
"jsdoc": {
"tagNamePreference": {
"customTagName": "customTagName"
}
}
}
}在上述配置下,添加 customTagName 标签时,此规则的正确代码示例如下:
js
/**
* @customTagName
*/配置
此规则接受一个包含以下属性的配置对象:
definedTags
type: string[]
default: []
允许的额外标签名。
jsxTags
type: boolean
default: false
是否允许与 JSX 相关的标签:
jsxjsxFragjsxImportSourcejsxRuntime
typed
type: boolean
default: false
如果 typed 为 true,则不允许那些不必要或与 TypeScript 功能重复的标签。
如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["jsdoc"],
"rules": {
"jsdoc/check-tag-names": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["jsdoc"],
rules: {
"jsdoc/check-tag-names": "error",
},
});bash
oxlint --deny jsdoc/check-tag-names --jsdoc-plugin版本
此规则在 v0.3.2 中添加。
