@bridge-ds/stylelint-plugin

中文文档
0.2.27发布于 2026/11/08MITTypeScriptES Module构建来源已验证近 30 天下载 2798

Stylelint rule bridge/use-tokens: no raw colors, lengths, radii, shadows, durations or z-index in product CSS where a design token exists. Autofixes exact matches. Reads the tokens through @bridge-ds/core and bridge.config.json.

原始使用文档

@bridge-ds/stylelint-plugin

Stylelint rule for product apps that use a Bridge design system: raw colors, lengths, radii, borders, shadows, durations, easings, z-index and fonts are reported where a design token exists, with the token to use. stylelint --fix replaces values that equal a token with var(--token); nothing else is rewritten.

It reads the tokens (every brand, theme and density) through @bridge-ds/core and the design system's bridge.config.json, so the suggestions are the same as bridge audit and the bridge_audit MCP tool.

Install

npm install --save-dev stylelint @bridge-ds/stylelint-plugin
// .stylelintrc.json in the product app
{
  "plugins": ["@bridge-ds/stylelint-plugin"],
  "rules": {
    "bridge/use-tokens": [true, { "designSystem": "../design-system" }]
  }
}

bridge/use-tokens

.card {
  color: #1c2735;   /* Use var(--color-text-default) instead of #1c2735: it is the same color (#1c2735). */
  padding: 13px;    /* Use a token instead of the raw spacing 13px: closest is var(--space-3) (12px, high match). */
  z-index: 1000;    /* fixed to var(--layer-dropdown) */
}
OptionDefault
designSystemBRIDGE_DS, else the nearest folder with bridge.config.jsonDesign system repo root.
minConfidence"medium"Report a value only when a token is at least this close: exact, high, medium, low.
categoriesallcolor, spacing, size, radius, border-width, shadow, duration, easing, z-index, font-family, font-size, font-weight, line-height.
ignorePropertiesnoneProperty names or /regex/ strings to skip.

Colors are matched by perceptual distance (deltaE in OKLab) across every mode; semantic tokens and tokens that fit the property (a background gets a surface token) win near-ties. Lengths go to the nearest scale step. var() fallbacks, percentages, 0, auto and local stacking (z-index 0, 1, -1) are not reported.

版本与发布记录

@bridge-ds/stylelint-plugin 共发布 28 个版本,首次发布于 2026/10/18;过去 12 个月发布了 28 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.27latest2026/11/08今天
0.2.262026/11/035 天前
0.2.252026/11/026 天前
0.2.242026/11/027 天前
0.2.232026/10/318 天前
0.2.222026/10/318 天前

关于 @bridge-ds/stylelint-plugin 的常见问题

@bridge-ds/stylelint-plugin 是什么?

Stylelint rule bridge/use-tokens: no raw colors, lengths, radii, shadows, durations or z-index in product CSS where a design token exists. Autofixes exact matches. Reads the tokens through @bridge-ds/core and bridge.config.json.

如何安装 @bridge-ds/stylelint-plugin?

在项目目录运行 npm install @bridge-ds/stylelint-plugin,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:stylelint(>=16.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@bridge-ds/stylelint-plugin 支持 TypeScript 吗?

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

@bridge-ds/stylelint-plugin 支持 ESM 还是 CommonJS?

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

@bridge-ds/stylelint-plugin 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bridge-ds/stylelint-plugin 可以商用吗?

@bridge-ds/stylelint-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@bridge-ds/stylelint-plugin 的下载量有多少?

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

@bridge-ds/stylelint-plugin 还在维护吗?

最新版本 0.2.27 发布于 2026/11/08(今天);至今共发布 28 个版本,其中过去 12 个月发布了 28 个;首次发布于 2026/10/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。