markuplint
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMarkuplint
Markuplint
Reference knowledge for working with Markuplint.
Markuplint使用参考知识库。
What is Markuplint
什么是Markuplint
An HTML linter that checks conformance with HTML Standard, WAI-ARIA, and project-specific rules. Supports JSX, Vue, Svelte, Astro, Pug, PHP, and more via parser plugins.
- Official site: https://markuplint.dev
- GitHub: https://github.com/markuplint/markuplint
- Playground: https://playground.markuplint.dev
一款HTML代码检查工具,可检查代码是否符合HTML标准、WAI-ARIA规范及项目自定义规则。通过解析器插件支持JSX、Vue、Svelte、Astro、Pug、PHP等多种语法。
- 官方网站:https://markuplint.dev
- GitHub:https://github.com/markuplint/markuplint
- 在线 playground:https://playground.markuplint.dev
Reading Violation Messages
违规信息解读
Format:
message (ruleId) [named-rule]The attribute name is duplicated (attr-duplication) [html-standard/attr-duplication]- (
ruleId) — the base rule. Always present.attr-duplication - (
named-rule) — preset-defined alias. Present only for named rules. Thehtml-standard/attr-duplicationprefix indicates which preset defined it (e.g.,namespace/,a11y/,html-standard/).performance/ - —
severity(exit code 1),error(exit code 0 by default), orwarning.info
To look up any rule:
https://markuplint.dev/docs/rules/{ruleId}格式:
message (ruleId) [named-rule]The attribute name is duplicated (attr-duplication) [html-standard/attr-duplication]- (
ruleId)——基础规则,始终存在。attr-duplication - (
named-rule)——预设规则的别名,仅在命名规则中存在。html-standard/attr-duplication前缀表示该规则来自哪个预设(例如namespace/、a11y/、html-standard/)。performance/ - ——严重程度,包括
severity(退出码1)、error(默认退出码0)或warning。info
查询规则详情请访问:
https://markuplint.dev/docs/rules/{ruleId}CLI Quick Reference
CLI快速参考
shell
undefinedshell
undefinedBasic lint
Basic lint
npx markuplint "src/**/*.html"
npx markuplint "src/**/*.html"
JSON output (for programmatic use)
JSON output (for programmatic use)
npx markuplint "src/**/*.html" --format JSON
npx markuplint "src/**/*.html" --format JSON
Auto-fix (rules that support it)
Auto-fix (rules that support it)
npx markuplint "src/**/*.html" --fix
npx markuplint "src/**/*.html" --fix
Preview fixes without writing
Preview fixes without writing
npx markuplint "src/**/*.html" --fix-dry-run
npx markuplint "src/**/*.html" --fix-dry-run
Suppress current violations for gradual adoption
Suppress current violations for gradual adoption
npx markuplint "src/**/*.html" --suppress
npx markuplint "src/**/*.html" --suppress
Clean up fixed suppressions
Clean up fixed suppressions
npx markuplint "src/**/*.html" --prune-suppressions
npx markuplint "src/**/*.html" --prune-suppressions
GitHub Actions annotations
GitHub Actions annotations
npx markuplint "src/**/*.html" --format GitHub
npx markuplint "src/**/*.html" --format GitHub
Limit output for large projects
Limit output for large projects
npx markuplint "src/**/*.html" --max-count=50
Always quote glob patterns to prevent shell expansion.npx markuplint "src/**/*.html" --max-count=50
请始终为通配符模式添加引号,避免shell自动展开。Config Patterns
配置模式
Disable a named rule
禁用命名规则
json
{ "rules": { "a11y/html-lang": false } }json
{ "rules": { "a11y/html-lang": false } }Disable all rules in a namespace
禁用命名空间下的所有规则
json
{ "rules": { "a11y/*": false } }json
{ "rules": { "a11y/*": false } }Change severity
修改严重程度
json
{ "rules": { "a11y/html-lang": "warning" } }json
{ "rules": { "a11y/html-lang": "warning" } }Element-specific rules
元素特定规则
nodeRuleschildNodeRules"inheritance": truenodeRuleschildNodeRules"inheritance": trueAncestor matching
祖先元素匹配
Use . Do NOT use — it is deprecated.
:is(selector *):closest()json
{ "selector": "div:is(nav *)" }使用。请勿使用——该语法已被废弃。
:is(selector *):closest()json
{ "selector": "div:is(nav *)" }Common Issues and Fixes
常见问题及解决方法
OGP / Open Graph property
attribute
propertyOGP/Open Graph property
属性
propertyThe attribute is not in the HTML spec. See: https://markuplint.dev/docs/rules/invalid-attr#the-open-graph-protocol
propertypropertyinvalid-attr
with frameworks
invalid-attr框架中的invalid-attr
问题
invalid-attrInstall the framework's spec plugin (e.g., ). See: https://markuplint.dev/docs/guides/beyond-html#why-need-the-spec-plugins
@markuplint/react-spec安装对应框架的规范插件(例如)。详情请见:https://markuplint.dev/docs/guides/beyond-html#why-need-the-spec-plugins
@markuplint/react-speccharacter-reference
false positives with template engines
character-reference模板引擎中的character-reference
误报
character-referenceSome template syntaxes trigger false positives. Disable partially or report: https://markuplint.dev/docs/rules/character-reference
部分模板语法会触发误报。可部分禁用该规则或提交问题反馈:https://markuplint.dev/docs/rules/character-reference
--init
is interactive only
--init--init
仅支持交互式操作
--initnpx markuplint --init.markuplintrcnpx markuplint --init.markuplintrcDocumentation URLs
文档链接
| Topic | URL |
|---|---|
| All rules | |
| Specific rule | |
| Presets | |
| Framework setup | |
| Config properties | |
| Selectors | |
| CLI options | |
| FAQ | |
| Migration (v4→v5) | |
Use on these URLs when you need current details.
WebFetch| 主题 | 链接 |
|---|---|
| 所有规则 | |
| 特定规则 | |
| 预设规则 | |
| 框架配置 | |
| 配置属性 | |
| 选择器 | |
| CLI选项 | |
| 常见问题 | |
| 版本迁移(v4→v5) | |
如需获取最新详情,可通过访问上述链接。
WebFetch