ShtukbaseStandard
EC-R03/norms/rules/std-editorconfig/EC-R03.md

缩进与行长与 .editorconfig 一致

SHOULD观察传感器生效中
缩进与行长与 .editorconfig 一致
原因: 混合制表符与空格的缩进,会使代码在不同编辑器中的样子不一致。
页面字段(15)
ruleIdEC-R03
requirement缩进与行长与 .editorconfig 一致
levelSHOULD
floorfalse
statusactive
sphereengineering
appliesToall text files
enforcers.shtukbase/packages/std-editorconfig/checks/ec03_indent.ts
enforcerKindsensor
modeobserve
because混合制表符与空格的缩进,会使代码在不同编辑器中的样子不一致。
baseline0
reviewBy2027-05-28
packstd-editorconfig
sourcesEditorConfig Specification 0.17.2, https://spec.editorconfig.org/

行的缩进遵循 indent_style:space 时缩进中不得有制表符;tab 时不得有两个或以上连续空格;若设置了 max_line_length,则每行不得超过该长度。这是一种启发式规则:多行字符串与对齐会造成误报,因此该规范只作观察。

为什么。 混合制表符与空格的缩进,会使代码在不同编辑器中的样子不一致。

如何修复。 重新缩进这些行;对于必须使用制表符的格式(如 Makefile),在 .editorconfig 中加一节,设置 indent_style = tab。

运行。 在项目根目录:shtuk run std-editorconfig indent。每个文件、每种违规类型输出一行:首行、共有多少处,以及该做什么。在 enforce 模式下退出码为 1,在 observe 与 warn 模式下为 0。设置见:/norms/standards/editorconfig.md。

执行器是 std-editorconfig 包的 indent 检查。

包 标准:EditorConfig 会把此页面放在 /norms/rules/std-editorconfig/EC-R03.md。源文本