# @db-ux/core-eslint-plugin 中文文档

规范地址：https://npmcn.com/package/%40db-ux/core-eslint-plugin/

版本：6\.3\.2
npm 元数据更新时间：2026-11-11T12:58:20.268Z
中文译文更新时间：2026-11-11T20:50:55.855Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40db-ux/core-eslint-plugin
原文对照：https://npmcn.com/package/%40db-ux/core-eslint-plugin/?lang=original
源码仓库：https://github.com/db-ux-design-system/core-web

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：260 kB，65 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- peer 依赖：eslint \>=9\.0\.0
- 首次发布：2026-02-11T07:51:39.549Z
- 最新版本发布：2026-11-11T12:58:19.894Z
- 近 30 天下载量：3398（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：98（近 12 个月 98 个）

## 中文简介

DB UX 设计系统组件的 ESLint 插件

## 安装

```sh
npm install @db-ux/core-eslint-plugin
```

也可以使用：`pnpm add @db-ux/core-eslint-plugin`、`yarn add @db-ux/core-eslint-plugin`、`bun add @db-ux/core-eslint-plugin`

## README

# @db-ux/core-slint-插件

ESLint插件用于验证跨越React,Vue,和Angular对DB UX设计系统组件的正确使用.

## 安装

```shell
npm install eslint @db-ux/core-eslint-plugin --save-dev
```

**Vue项目**,同时安装 `vue-eslint-parser`数字 :

```shell
npm install vue-eslint-parser --save-dev
```

**角化项目**,同时安装 `@angular-eslint/template-parser`数字 :

```shell
npm install @angular-eslint/template-parser --save-dev
```

**反应/ TypeScript 项目**,同时安装 `@typescript-eslint/parser`数字 :

```shell
npm install @typescript-eslint/parser --save-dev
```

## 使用量

在您的 ESLint 配置中添加 :

**ESLint 9+(平面配置) :**

```js
// eslint.config.js
import dbUx from "@db-ux/core-eslint-plugin";

export default [
    {
        plugins: {
            "db-ux": dbUx
        },
        rules: dbUx.configs.recommended.rules
    }
];
```

**Vue项目**,配置 Vue 解析器 :

```js
import dbUx from "@db-ux/core-eslint-plugin";
import vueParser from "vue-eslint-parser";
import tsParser from "@typescript-eslint/parser";

export default [
    {
        files: ["**/*.vue"],
        languageOptions: {
            parser: vueParser,
            parserOptions: {
                parser: tsParser,
                ecmaVersion: "latest",
                sourceType: "module"
            }
        },
        plugins: {
            "db-ux": dbUx
        },
        rules: dbUx.configs.recommended.rules
    }
];
```

**角化项目**,配置角模板解析器 :

```js
import dbUx from "@db-ux/core-eslint-plugin";
import angularTemplateParser from "@angular-eslint/template-parser";

export default [
    {
        files: ["**/*.html"],
        languageOptions: {
            parser: angularTemplateParser
        },
        plugins: {
            "db-ux": dbUx
        },
        rules: dbUx.configs.recommended.rules
    }
];
```

**或使规则能够单独:**

```js
import dbUx from "@db-ux/core-eslint-plugin";

export default [
    {
        plugins: {
            "db-ux": dbUx
        },
        rules: {
            "db-ux/button-no-text-requires-tooltip": "error"
        }
    }
];
```

**反应/ TypeScript 项目**,配置 TypeScript 解析器 :

```js
import dbUx from "@db-ux/core-eslint-plugin";
import tsParser from "@typescript-eslint/parser";

export default [
    {
        files: ["**/*.ts", "**/*.tsx"],
        languageOptions: {
            parser: tsParser,
            parserOptions: {
                ecmaVersion: "latest",
                sourceType: "module",
                ecmaFeatures: { jsx: true }
            }
        },
        plugins: {
            "db-ux": dbUx
        },
        rules: dbUx.configs.recommended.rules
    }
];
```

## 规则

### `button-no-text-requires-tooltip`

确保按钮带有 `noText` 道具两个都有 `icon` (或 `iconLeading`编号 :`iconTrailing`)和a 数据 `DBTooltip` 孩子们.

**无效 :**

```jsx
// React
<DBButton noText>Save</DBButton>
<DBButton icon="save" noText>Save</DBButton>

// Angular
<db-button [noText]="true">ABC</db-button>
<db-button icon="x" [noText]="true">ABC</db-button>

// Vue
<DBButton :noText="true">ABC</DBButton>
<DBButton icon="x" :noText="true">ABC</DBButton>
```

**有效时间 :**

```jsx
// React
<DBButton icon="save" noText>
  Save
  <DBTooltip>Save document</DBTooltip>
</DBButton>

// Angular
<db-button icon="x_placeholder" [noText]="true">
  ABC
  <db-tooltip>ABC</db-tooltip>
</db-button>

// Vue
<DBButton icon="x_placeholder" :noText="true">
  ABC
  <DBTooltip>ABC</DBTooltip>
</DBButton>
```

## 支持的框架

-   反应(JSX/TSX)
-   Vue (SFC) (英语)
-   角 (平板)

插件会自动检测基于文件扩展和解析的框架.

### `button-type-required`

确保 DBButton 有明确的 `type` 属性(提交、按钮或重置).

**无效 :**

```jsx
<DBButton>Save</DBButton>
<db-button>Save</db-button>
```

**有效时间 :**

```jsx
<DBButton type="button">Save</DBButton>
<DBButton type="submit">Submit</DBButton>
<DBButton type="reset">Reset</DBButton>
```

### `form-label-required`

确保格式组件(DBInput、DBTextrea、DBSelect、DBCustomSelect、DBCheckbox、DBradio、DBSwitch)具有 `label` 属性.

**无效 :**

```jsx
// React
<DBInput />
<DBCheckbox />
<DBSelect />

// Angular
<db-input></db-input>
<db-checkbox></db-checkbox>

// Vue
<DBInput />
<DBCheckbox />
```

**有效时间 :**

```jsx
// React
<DBInput label="Name" />
<DBCheckbox label="Accept terms" />
<DBSelect label="Country" />

// Angular
<db-input label="Name"></db-input>
<db-checkbox [label]="labelText"></db-checkbox>

// Vue
<DBInput :label="dynamicLabel" />
<DBCheckbox label="Accept terms" />
```

### `prefer-icon-attribute`

优先使用 `icon` 属性 `<DBIcon>` 支持图标属性的组件的子组件.

**无效 :**

```jsx
// React
<DBButton><DBIcon icon="save" /></DBButton>
<DBInput><DBIcon icon="search" /></DBInput>

// Angular
<db-button><db-icon icon="save"></db-icon></db-button>

// Vue
<DBLink><DBIcon icon="external" /></DBLink>
```

**有效时间 :**

```jsx
// React
<DBButton icon="save">Save</DBButton>
<DBInput icon="search" />

// Angular
<db-button icon="save">Save</db-button>

// Vue
<DBLink :icon="iconName">Link</DBLink>
```

### `text-or-children-required`

确保组件(DBAccordion项目、DBBadge项目、DBButton项目、DBLink项目、DBInfotext项目、DBControlPanelNavigation项目、DBNavigation项目、DB通知、DBDialogheader项目、DBDrawerheader项目)要么具有 `text` 财产或儿童含量。 对于 DBDialog 标题和 DBDrawer 标题, 守护对话框的可访问名称: 标题内容成为 `aria-labelledby` 目标,所以空标题会让对话框未命名 .

DBIcon被故意排除: 它总是用 `aria-hidden="true"`,所以一个 `text` 无论是屏幕阅读器还是视觉用户, 装饰性的图标不需要任何内容,而信息化的图标则需要被命名为"包装"来包围.

**无效 :**

```jsx
// React
<DBButton />
<DBLink />
<DBBadge />

// Angular
<db-button></db-button>
<db-notification></db-notification>

// Vue
<DBInfotext />
```

**有效时间 :**

```jsx
// React
<DBButton text="Save" />
<DBButton>Save</DBButton>
<DBLink>Click here</DBLink>

// Angular
<db-button text="Save"></db-button>
<db-button>Save</db-button>

// Vue
<DBBadge>New</DBBadge>

// DBIcon is decorative and is never reported
<DBIcon icon="test" />
```

### `no-interactive-tooltip-content`

防止DBTooltip内部的互动元素(按钮,链接,输入). 交互内容使用 DBPopover .

**无效 :**

```jsx
// React
<DBTooltip><button>Click</button></DBTooltip>
<DBTooltip><DBButton>Action</DBButton></DBTooltip>
<DBTooltip><a href="#">Link</a></DBTooltip>

// Angular
<db-tooltip><button>Click</button></db-tooltip>
<db-tooltip><db-button>Action</db-button></db-tooltip>

// Vue
<DBTooltip><DBLink href="#">Link</DBLink></DBTooltip>
```

**有效时间 :**

```jsx
// React
<DBTooltip>Simple text</DBTooltip>
<DBTooltip><span>Text with span</span></DBTooltip>
<DBTooltip><p>Paragraph</p></DBTooltip>

// For interactive content, use DBPopover:
<DBPopover><DBButton>Action</DBButton></DBPopover>
```

### `tooltip-requires-interactive-parent`

保证DBTooltip是一个具有交互元素的可访问性的孩子(用户必须能够将焦点集中在父母身上).

**无效 :**

```jsx
// React
<span>Show more<DBTooltip>XXX</DBTooltip></span>
<div>Text<DBTooltip>Info</DBTooltip></div>
<DBBadge>Badge<DBTooltip>Info</DBTooltip></DBBadge>

// Angular
<span>Show more<db-tooltip>XXX</db-tooltip></span>

// Vue
<div>Text<DBTooltip>Info</DBTooltip></div>
```

**有效时间 :**

```jsx
// React
<button>Save<DBTooltip>Save document</DBTooltip></button>
<DBButton>Save<DBTooltip>Save document</DBTooltip></DBButton>
<a href="#">Link<DBTooltip>More info</DBTooltip></a>

// Angular
<db-button>Save<db-tooltip>Save document</db-tooltip></db-button>

// Vue
<DBLink href="#">Link<DBTooltip>More info</DBTooltip></DBLink>
```

### `no-nested-accordion`

防止将 DBAccordion 组件嵌入内部,因为它会混淆用户.

**无效 :**

```jsx
// React
<DBAccordion><DBAccordion>Nested</DBAccordion></DBAccordion>
<DBAccordion><DBAccordionItem><DBAccordion>Deep</DBAccordion></DBAccordionItem></DBAccordion>

// Angular
<db-accordion><db-accordion>Nested</db-accordion></db-accordion>

// Vue
<DBAccordion><div><DBAccordion>Nested</DBAccordion></div></DBAccordion>
```

**有效时间 :**

```jsx
// React
<DBAccordion><DBAccordionItem>Item</DBAccordionItem></DBAccordion>
<div><DBAccordion>First</DBAccordion></div>
<DBAccordion>First</DBAccordion><DBAccordion>Second</DBAccordion>
```

### `badge-corner-placement-rules`

确保 DBBadge 带有角位置的字符最大为3个,并具有可访问性标签属性.

**无效 :**

```jsx
// React
<DBBadge placement="corner-top-left">9999</DBBadge>
<DBBadge placement="corner-top-right" text="1234" />
<DBBadge placement="corner-top-left">99</DBBadge>

// Angular
<db-badge placement="corner-top-left">9999</db-badge>

// Vue
<DBBadge placement="corner-top-right">Long text</DBBadge>
```

**有效时间 :**

```jsx
// React
<DBBadge>Long text is fine</DBBadge>
<DBBadge placement="inline">Long text</DBBadge>
<DBBadge placement="corner-top-left" label="New items">99+</DBBadge>
<DBBadge placement="corner-top-right" text="5" label="Notifications" />

// Auto-fix converts:
<DBBadge placement="corner-top-left">9999</DBBadge>
// to:
<DBBadge placement="corner-top-left" label="9999">999</DBBadge>
```

### `badge-no-inline-in-interactive`

防止DBBadge在交互元素(DBButton,DBLink)内置内置. 换作转角位置.

**无效 :**

```jsx
// React
<DBButton><DBBadge placement="inline">Badge</DBBadge>Button</DBButton>
<DBLink><DBBadge placement="inline">Badge</DBBadge>Link</DBLink>

// Angular
<db-button><db-badge placement="inline">Badge</db-badge>Button</db-button>

// Vue
<DBButton><DBBadge placement="inline">Badge</DBBadge>Button</DBButton>
```

**有效时间 :**

```jsx
// React
<DBBadge placement="inline">Badge</DBBadge>
<DBButton><DBBadge placement="corner-top-right" label="New">5</DBBadge>Button</DBButton>
<DBLink><DBBadge placement="corner-top-left" label="Count">3</DBBadge>Link</DBLink>

// Auto-fix converts:
<DBButton><DBBadge placement="inline">Badge</DBBadge>Button</DBButton>
// to:
<DBButton><DBBadge placement="corner-top-right">Badge</DBBadge>Button</DBButton>
```

### `button-single-icon-attribute`

确保DBButton只使用一个图标属性(icon,图标领跑,或图标Trailing).

**无效 :**

```jsx
// React
<DBButton icon="save" iconLeading="save">Save</DBButton>
<DBButton icon="save" iconTrailing="arrow">Save</DBButton>
<DBButton iconLeading="save" iconTrailing="arrow">Save</DBButton>

// Angular
<db-button icon="save" [iconLeading]="iconName">Save</db-button>

// Vue
<DBButton icon="save" :iconTrailing="icon">Save</DBButton>
```

**有效时间 :**

```jsx
// React
<DBButton icon="save">Save</DBButton>
<DBButton iconLeading="save">Save</DBButton>
<DBButton iconTrailing="arrow">Next</DBButton>

// Angular
<db-button icon="save">Save</db-button>
<db-button [iconLeading]="iconName">Save</db-button>

// Vue
<DBButton :iconTrailing="icon">Next</DBButton>
```

### `link-external-security`

确保外部链接具有适当的安全属性(目标=" blank"和指针政策).

**无效 :**

```jsx
// React
<DBLink content="external">External</DBLink>
<DBLink content="external" target="_blank">External</DBLink>
<DBLink target="_blank">External</DBLink>

// Angular
<db-link content="external">External</db-link>

// Vue
<DBLink content="external" :target="linkTarget">External</DBLink>
```

**有效时间 :**

```jsx
// React
<DBLink href="#">Internal link</DBLink>
<DBLink content="external" target="_blank" referrerPolicy="no-referrer">External</DBLink>

// Angular
<db-link content="external" target="_blank" referrerPolicy="no-referrer">External</db-link>

// Vue
<DBLink content="external" target="_blank" :referrerPolicy="policy">External</DBLink>
```

### `select-requires-options`

确保 DBSelect 有选项属性或选项孩子.

选项在通过 `<optgroup>`,控制流或循环:角 `@for`编号 :`@if`编号 :`@switch`, (中文(简体) ), `*ngFor`编号 :`*ngIf` 财务报告和审定财务报表 `ng-container`单 `<template v-for>`和反应碎片, `&&`/tern 表达式和 `.map()`。反应表达式不能静态解决(例如:. `{renderOptions()}`未报告.

**无效 :**

```jsx
// React
<DBSelect label="Country" />
<DBSelect label="Country"></DBSelect>
<DBSelect label="Country"><div><option value="de">Germany</option></div></DBSelect>

// Angular
<db-select label="Country"></db-select>
<db-select label="Country">@if (show) { }</db-select>

// Vue
<DBSelect label="Country" />
```

**有效时间 :**

```jsx
// React
<DBSelect label="Country">
  <option value="de">Germany</option>
  <option value="us">USA</option>
</DBSelect>
<DBSelect label="Country" options={countryOptions} />
<DBSelect label="Country">
  {countries.map((c) => <option key={c} value={c}>{c}</option>)}
</DBSelect>

// Angular
<db-select label="Country">
  <option value="de">Germany</option>
</db-select>
<db-select label="Country" [options]="options"></db-select>
<db-select label="Country">
  @for (c of countries; track c) {
    <option [value]="c">{{ c }}</option>
  }
</db-select>

// Vue
<DBSelect label="Country" :options="options" />
<DBSelect label="Country">
  <template v-for="c in countries" :key="c">
    <option :value="c">{{ c }}</option>
  </template>
</DBSelect>
```

### `close-button-text-required`

确保带有闭合按钮的组件具有适当的文本属性,以便于访问.

**无效 :**

```jsx
// React
<DBNotification closeable>Message</DBNotification>
<DBDrawerHeader>Title</DBDrawerHeader>
<DBDialogHeader>Title</DBDialogHeader>
<DBCustomSelect label="Select" />

// Angular
<db-notification closeable>Message</db-notification>
<db-drawer-header>Title</db-drawer-header>
<db-dialog-header>Title</db-dialog-header>

// Vue
<DBCustomSelect label="Select" />
<DBDrawerHeader>Title</DBDrawerHeader>
<DBDialogHeader>Title</DBDialogHeader>
```

**有效时间 :**

```jsx
// React
<DBNotification closeButtonText="Close">Message</DBNotification>
<DBDrawerHeader closeButtonText="Close drawer">Title</DBDrawerHeader>
<DBDialogHeader closeButtonText="Close dialog">Title</DBDialogHeader>
<DBCustomSelect mobileCloseButtonText="Close" label="Select" />

// Angular
<db-notification closeButtonText="Close">Message</db-notification>
<db-drawer-header [closeButtonText]="closeText">Title</db-drawer-header>
<db-dialog-header closeButtonText="Close dialog">Title</db-dialog-header>

// Vue
<DBCustomSelect :mobileCloseButtonText="closeText" label="Select" />
<DBDrawerHeader :closeButtonText="closeText">Title</DBDrawerHeader>
<DBDialogHeader :closeButtonText="closeText">Title</DBDialogHeader>
```

### `drawer-header-required`

确保 DBDrawer 拥有用于访问的 DBDrawer Header 。 信头提供了关闭按钮和 `aria-labelledby` 用于对话框.

**无效 :**

```jsx
// React
<DBDrawer>Content</DBDrawer>
<DBDrawer open={true}>Content</DBDrawer>

// Angular - missing `header` attribute for slot projection
<db-drawer><db-drawer-header>Title</db-drawer-header>Content</db-drawer>
<db-drawer>Content</db-drawer>

// Vue - missing named slot
<DBDrawer><DBDrawerHeader>Title</DBDrawerHeader>Content</DBDrawer>
<DBDrawer>Content</DBDrawer>
```

**有效时间 :**

```jsx
// React
<DBDrawer header={<DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader>}>Content</DBDrawer>

// Angular - uses `header` attribute for ng-content projection
<db-drawer><db-drawer-header header closeButtonText="Close">Title</db-drawer-header>Content</db-drawer>
<db-drawer><ng-container header><db-drawer-header closeButtonText="Close">Title</db-drawer-header></ng-container>Content</db-drawer>

// Vue - uses named slot
<DBDrawer><template v-slot:header><DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader></template>Content</DBDrawer>
<DBDrawer><template #header><DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader></template>Content</DBDrawer>
```

### `custom-heading-single-heading`

确保 DBCustom 标题包装 完全一个标题。 组件只提供一个标题外加兄弟会内容的布局,没有自己的标题语义,所以没有嵌入 `h1`\- 说吧`h6` (或 `DBHeadingH1`\- 说吧`DBHeadingH6`无所被暴露为一头. 单打包件中不止一个标题会打破文档大纲.

这个 `startSlot` 财务报告和审定财务报表 `endSlot` 内容也算数,因为它在包装箱里制造。 在反应中,内容是属性(`endSlot={…}`)取而代之为子也,故"通则"以检查两者.

无法静态解决的内容(JSX表达式, `<slot>`, (中文(简体) ), `<ng-content>`,非 DB 组件)压制缺失标题报告.

**无效 :**

```jsx
// React
<DBCustomHeading>Installation</DBCustomHeading>
<DBCustomHeading><span>Installation</span></DBCustomHeading>
<DBCustomHeading><h2>One</h2><h3>Two</h3></DBCustomHeading>
<DBCustomHeading endSlot={<h3>Two</h3>}><h2>One</h2></DBCustomHeading>

// Angular
<db-custom-heading>Installation</db-custom-heading>
<db-custom-heading><db-heading-h-2>One</db-heading-h-2><h3>Two</h3></db-custom-heading>
<db-custom-heading><h2>One</h2><h3 end-slot>Two</h3></db-custom-heading>

// Vue
<DBCustomHeading>Installation</DBCustomHeading>
<DBCustomHeading><h2>One</h2><DBHeadingH3>Two</DBHeadingH3></DBCustomHeading>
<DBCustomHeading><h2>One</h2><template #end-slot><h3>Two</h3></template></DBCustomHeading>
```

**有效时间 :**

```jsx
// React
<DBCustomHeading><h2>Installation</h2></DBCustomHeading>
<DBCustomHeading endSlot={<button type="button">More options</button>}>
    <DBHeadingH2>Installation</DBHeadingH2>
</DBCustomHeading>
<DBCustomHeading>{children}</DBCustomHeading>
<DBCustomHeading endSlot={slotContent} />

// Angular
<db-custom-heading><h2>Installation</h2></db-custom-heading>
<db-custom-heading><h2>Installation</h2><db-badge end-slot>3</db-badge></db-custom-heading>
<db-custom-heading><db-heading-h-2 *ngIf="visible">Installation</db-heading-h-2></db-custom-heading>

// Vue
<DBCustomHeading><DBHeadingH2>Installation</DBHeadingH2></DBCustomHeading>
<DBCustomHeading><h2>Installation</h2><template #end-slot><DBBadge>3</DBBadge></template></DBCustomHeading>
<DBCustomHeading><slot /></DBCustomHeading>
```

### `dialog-header-required`

确保 DBDialog 在其中有一个 DBDialog 标题 `header` 进入空间。 信头提供了关闭按钮和 `aria-labelledby` 用于对话框.

**无效 :**

```jsx
// React
<DBDialog>Content</DBDialog>
<DBDialog open={true}>Content</DBDialog>

// Angular - missing `header` attribute for slot projection
<db-dialog><db-dialog-header>Title</db-dialog-header>Content</db-dialog>
<db-dialog>Content</db-dialog>

// Vue - missing named slot
<DBDialog><DBDialogHeader>Title</DBDialogHeader>Content</DBDialog>
<DBDialog>Content</DBDialog>
```

**有效时间 :**

```jsx
// React
<DBDialog header={<DBDialogHeader closeButtonText="Close">Title</DBDialogHeader>}>Content</DBDialog>

// Angular - uses `header` attribute for ng-content projection
<db-dialog><db-dialog-header header closeButtonText="Close">Title</db-dialog-header>Content</db-dialog>
<db-dialog><ng-container header><db-dialog-header closeButtonText="Close">Title</db-dialog-header></ng-container>Content</db-dialog>

// Vue - uses named slot
<DBDialog><template v-slot:header><DBDialogHeader closeButtonText="Close">Title</DBDialogHeader></template>Content</DBDialog>
<DBDialog><template #header><DBDialogHeader closeButtonText="Close">Title</DBDialogHeader></template>Content</DBDialog>
```

### `sub-component-required-parent`

确保子组件在其所需的母组件和槽内被使用.

**配置的关系 :**

| 次级构成部分 | 必需的父 | 所需时间段 |
| --- | --- | --- |
| `DBDrawerHeader` | `DBDrawer`, (中文(简体) ), `DBHeader` 或者说 `DBControlPanelMobile` | `header` |
| `DBDrawerFooter` | `DBDrawer` | `footer` |
| `DBDialogHeader` | `DBDialog` | `header` |
| `DBDialogFooter` | `DBDialog` | `footer` |
| `DBAccordionItem` | `DBAccordion` | (直接子女) |

`DBHeader` 财务报告和审定财务报表 `DBControlPanelMobile` 转发 `header` 进入 `header` 内部时间档 `DBDrawer`,所以一个 `DBDrawerHeader` 被录取了 槽只在 `showDrawerHeaderSlot` 已经设定.

**无效 :**

```jsx
// React
<div><DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader></div>
<div><DBDialogHeader closeButtonText="Close">Title</DBDialogHeader></div>
<div><DBAccordionItem headlinePlain="Test">Content</DBAccordionItem></div>

// Angular - missing slot attribute or wrong parent
<div><db-drawer-header closeButtonText="Close">Title</db-drawer-header></div>
<db-drawer><db-drawer-header closeButtonText="Close">Title</db-drawer-header></db-drawer>
<db-dialog><db-dialog-header closeButtonText="Close">Title</db-dialog-header></db-dialog>

// Vue - missing named slot or wrong parent
<div><DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader></div>
<DBDrawer><DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader></DBDrawer>
<DBDialog><DBDialogFooter>Actions</DBDialogFooter></DBDialog>
```

**有效时间 :**

```jsx
// React
<DBDrawer header={<DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader>}>Content</DBDrawer>
<DBHeader showDrawerHeaderSlot header={<DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader>}>Content</DBHeader>
<DBDialog header={<DBDialogHeader closeButtonText="Close">Title</DBDialogHeader>}>Content</DBDialog>
<DBAccordion><DBAccordionItem headlinePlain="Test">Content</DBAccordionItem></DBAccordion>

// Angular - with slot attribute
<db-drawer><db-drawer-header header closeButtonText="Close">Title</db-drawer-header></db-drawer>
<db-drawer><ng-container header><db-drawer-header closeButtonText="Close">Title</db-drawer-header></ng-container></db-drawer>
<db-dialog><db-dialog-header header closeButtonText="Close">Title</db-dialog-header></db-dialog>
<db-dialog><db-dialog-footer footer>Actions</db-dialog-footer></db-dialog>
<db-accordion><db-accordion-item headlinePlain="Test">Content</db-accordion-item></db-accordion>

// Vue - with named slot
<DBDrawer><template #header><DBDrawerHeader closeButtonText="Close">Title</DBDrawerHeader></template></DBDrawer>
<DBDialog><template #header><DBDialogHeader closeButtonText="Close">Title</DBDialogHeader></template></DBDialog>
<DBDialog><template #footer><DBDialogFooter>Actions</DBDialogFooter></template></DBDialog>
<DBAccordion><DBAccordionItem headlinePlain="Test">Content</DBAccordionItem></DBAccordion>
```

### `control-panel-mobile-burger-menu-label-required`

确保 DB ControlPanelMobile 有汉堡MenuLabel 属性用于访问.

**无效 :**

```jsx
// React
<DBControlPanelMobile>Content</DBControlPanelMobile>

// Angular
<db-control-panel-mobile>Content</db-control-panel-mobile>

// Vue
<DBControlPanelMobile>Content</DBControlPanelMobile>
```

**有效时间 :**

```jsx
// React
<DBControlPanelMobile burgerMenuLabel="Menu">Content</DBControlPanelMobile>

// Angular
<db-control-panel-mobile burgerMenuLabel="Menu">Content</db-control-panel-mobile>
<db-control-panel-mobile [burgerMenuLabel]="menuLabel">Content</db-control-panel-mobile>

// Vue
<DBControlPanelMobile :burgerMenuLabel="label">Content</DBControlPanelMobile>
```

### `navigation-item-back-button-text-required`

确保 DB ControlPanelNavigation ProjectGroup 为访问提供后按钮文本属性 .

**无效 :**

```jsx
// React
<DBControlPanelNavigationItemGroup>Item</DBControlPanelNavigationItemGroup>
<DBControlPanelNavigationItemGroup icon="home">Item</DBControlPanelNavigationItemGroup>

// Angular
<db-control-panel-navigation-item-group>Item</db-control-panel-navigation-item-group>

// Vue
<DBControlPanelNavigationItemGroup>Item</DBControlPanelNavigationItemGroup>
```

**有效时间 :**

```jsx
// React
<DBControlPanelNavigationItemGroup backButtonText="Back">Item</DBControlPanelNavigationItemGroup>
<DBControlPanelNavigationItemGroup backButtonText="Go back">Item</DBControlPanelNavigationItemGroup>

// Angular
<db-control-panel-navigation-item-group backButtonText="Back">Item</db-control-panel-navigation-item-group>
<db-control-panel-navigation-item-group [backButtonText]="backText">Item</db-control-panel-navigation-item-group>

// Vue
<DBControlPanelNavigationItemGroup :backButtonText="text">Item</DBControlPanelNavigationItemGroup>
```

### `custom-select-tags-remove-text-required`

确保使用所选 Type="tag" 选择的 DBCustomS 取消了 TagsTexts 属性的可访问性 .

**无效 :**

```jsx
// React
<DBCustomSelect label="Select" selectedType="tag" />
<DBCustomSelect label="Select" selectedType="tag" options={opts} />

// Angular
<db-custom-select label="Select" selectedType="tag"></db-custom-select>

// Vue
<DBCustomSelect label="Select" selectedType="tag" />
```

**有效时间 :**

```jsx
// React
<DBCustomSelect label="Select" />
<DBCustomSelect label="Select" selectedType="text" />
<DBCustomSelect label="Select" selectedType="tag" removeTagsTexts={["Remove A", "Remove B"]} />

// Angular
<db-custom-select label="Select" selectedType="tag" removeTagsTexts="texts"></db-custom-select>

// Vue
<DBCustomSelect label="Select" selectedType="tag" :removeTagsTexts="texts" />
```

### `tag-removable-remove-button-required`

确保有行为="可移动"的 DBTag 已去除用于访问的按钮属性.

**无效 :**

```jsx
// React
<DBTag behavior="removable">Tag</DBTag>
<DBTag behavior="removable" semantic="successful">Tag</DBTag>

// Angular
<db-tag behavior="removable">Tag</db-tag>

// Vue
<DBTag behavior="removable">Tag</DBTag>
```

**有效时间 :**

```jsx
// React
<DBTag>Tag</DBTag>
<DBTag behavior="static">Tag</DBTag>
<DBTag behavior="removable" removeButton="Remove">Tag</DBTag>

// Angular
<db-tag behavior="removable" removeButton="Remove">Tag</db-tag>

// Vue
<DBTag behavior="removable" :removeButton="removeText">Tag</DBTag>
```

### `form-validation-message-required`

保证具有验证属性的窗体组件对用户反馈无效Message.

**无效 :**

```jsx
// React
<DBInput label="Name" required />
<DBTextarea label="Text" maxLength={100} />
<DBInput label="Age" min={18} />
<DBInput label="Email" pattern=".*@.*" />

// Angular
<db-input label="Name" required></db-input>

// Vue
<DBInput label="Score" :max="100" />
```

**有效时间 :**

```jsx
// React
<DBInput label="Name" />
<DBInput label="Name" required invalidMessage="Required" />
<DBTextarea label="Text" maxLength={100} invalidMessage="Too long" />
<DBInput label="Age" min={18} invalidMessage="Must be 18+" />
<DBInput label="Email" pattern=".*@.*" invalidMessage="Invalid email" />

// Applies to: DBInput, DBTextarea, DBSelect, DBCustomSelect, DBCheckbox
// Checks: required, maxLength, minLength (Input/Textarea), min, max, pattern (Input only)
```

### `input-type-required`

建议向 DBInput 添加类型属性,以获得更好的开发者经验.

**无效 :**

```jsx
// React
<DBInput label="Name" />
<DBInput label="Name" placeholder="Enter name" />

// Angular
<db-input label="Name"></db-input>

// Vue
<DBInput label="Name" />
```

**有效时间 :**

```jsx
// React
<DBInput label="Name" type="text" />
<DBInput label="Email" type="email" />
<DBInput label="Password" type="password" />

// Auto-fix adds:
<DBInput label="Name" type="text" />
```

### `input-file-type-validation`

确保带有type="文件"的 DBInput 接受属性,并验证仅文件属性.

**无效 :**

```jsx
// React
<DBInput label="File" type="file" />
<DBInput label="Name" type="text" multiple />
<DBInput label="Name" type="text" accept=".pdf" />

// Angular
<db-input label="File" type="file"></db-input>

// Vue
<DBInput label="Email" type="email" accept=".pdf" multiple />
```

**有效时间 :**

```jsx
// React
<DBInput label="Name" type="text" />
<DBInput label="File" type="file" accept=".pdf" />
<DBInput label="Files" type="file" accept="image/*" multiple />

// Angular
<db-input label="File" type="file" accept=".jpg"></db-input>

// Vue
<DBInput label="File" type="file" accept="image/*" :multiple="true" />
```

## 常见问题

### @db-ux/core-eslint-plugin 是什么？

DB UX 设计系统组件的 ESLint 插件

### 如何安装 @db-ux/core-eslint-plugin？

在项目目录运行 npm install @db-ux/core-eslint-plugin，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：eslint（\>=9\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @db-ux/core-eslint-plugin 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @db-ux/core-eslint-plugin 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @db-ux/core-eslint-plugin 可以商用吗？

@db-ux/core-eslint-plugin 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @db-ux/core-eslint-plugin 的下载量有多少？

根据 npm 官方下载统计，@db-ux/core-eslint-plugin 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,398 次，日均约 113 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @db-ux/core-eslint-plugin 还在维护吗？

最新版本 6\.3\.2 发布于 2026/11/11（今天）；至今共发布 98 个版本，其中过去 12 个月发布了 98 个；首次发布于 2026/02/11。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

