@aphrody/eslint-plugin-m3

中文文档
1.4.7发布于 2026/10/23Apache-2.0TypeScriptES Module零依赖近 30 天下载 1706

Lint rules for sites consuming material-web (@aphrody/m3-react + Material Symbols) — runs under the native bun lint (jsPlugins).

原始使用文档
文档目录3 节
  1. Rules (8)
  2. Presets (ESLint flat config)
  3. Development

@aphrody/eslint-plugin-m3

Lint rules for code that consumes material-web (@aphrody/m3-react Md* wrappers, md-* elements, Material Symbols), for bun lint (jsPlugins) or ESLint-compatible hosts.

bun add -d @aphrody/eslint-plugin-m3
{
  "jsPlugins": ["./node_modules/@aphrody/eslint-plugin-m3/index.js"],
  "rules": {
    "m3/valid-icon-name": "error",
    "m3/valid-color-role": "error",
    "m3/no-sx-prop": "error",
    "m3/no-mui-prop-on-md": "error",
    "m3/no-mui-import": "warn",
    "m3/prefer-icon-token": "warn",
    "m3/require-icon-button-label": "warn",
    "m3/no-hardcoded-color": "warn"
  }
}

That is .oxlintrc.json for bun lint; the jsPlugins path is relative to that file. Plain ESM, no transpilation.

License: Apache-2.0 (LICENSE). Install guide: docs/material/m3/INSTALL.md.

It pairs with @aphrody/m3-codemods: what the codemods leave as MIGRATION-TODO, these rules keep catching.

Rules (8)

RuleLevelFixCatches
m3/valid-icon-nameerrorauto<md-icon> / <MdIcon> text that is not a Material Symbols glyph (checked against 4253 glyphs); fixes MUI PascalCase leftovers (Delete).
m3/valid-color-roleerror-var(--md-sys-color-<role>) with a role material-web does not emit (typos, MUI or Tailwind names); suggests the closest role.
m3/no-sx-properror-sx on an md-* element, where it has no effect; use className and --md-sys-* tokens.
m3/no-mui-prop-on-mderrorautoMUI prop names left on a wrapper (checked to selected, title to text, open to opened, value to activeTabIndex).
m3/no-mui-importwarn-Remaining @mui/material, @mui/icons-material or @mui/x-* imports.
m3/prefer-icon-tokenwarn-Inline fontVariationSettings on an icon; use --md-icon-fill, --md-icon-wght, --md-icon-grad, --md-icon-opsz.
m3/require-icon-button-labelwarn-Icon buttons without an accessible name (aria-label, aria-labelledby, title); WCAG 4.1.2.
m3/no-hardcoded-colorwarn-Hard-coded #hex / rgb() in style or sx of an md-* element; use a var(--md-sys-color-*) role.

bun lint --fix applies the two autofixes (valid-icon-name, no-mui-prop-on-md).

Presets (ESLint flat config)

import m3 from "@aphrody/eslint-plugin-m3";

export default [m3.configs.recommended]; // or m3.configs.strict: every rule as an error

Development

bun test/run.ts                    # bun lint over the fixtures (every rule fires on bad, none on good)
bun scripts/sync-symbol-names.ts   # regenerate data/material-symbols-names.js

The glyph list (data/material-symbols-names.js) is generated from ../m3-codemods/data/material-symbols-names.json (official codepoints of google/material-design-icons, Apache-2.0); prepack runs the sync.

版本与发布记录

@aphrody/eslint-plugin-m3 共发布 12 个版本,首次发布于 2026/06/04;过去 12 个月发布了 12 个版本。

版本发布日期距今
1.4.7latest2026/10/2317 天前
1.4.42026/10/1822 天前
3.3.72026/10/101 个月前
3.3.62026/10/101 个月前
3.3.52026/10/091 个月前
3.3.42026/10/071 个月前

关于 @aphrody/eslint-plugin-m3 的常见问题

@aphrody/eslint-plugin-m3 是什么?

Lint rules for sites consuming material-web (@aphrody/m3-react + Material Symbols) — runs under the native bun lint (jsPlugins).

如何安装 @aphrody/eslint-plugin-m3?

在项目目录运行 npm install @aphrody/eslint-plugin-m3,或使用 pnpm add / yarn add / bun add。

@aphrody/eslint-plugin-m3 支持 TypeScript 吗?

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

@aphrody/eslint-plugin-m3 支持 ESM 还是 CommonJS?

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

@aphrody/eslint-plugin-m3 可以商用吗?

@aphrody/eslint-plugin-m3 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@aphrody/eslint-plugin-m3 的下载量有多少?

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

@aphrody/eslint-plugin-m3 还在维护吗?

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