css/prefer-logical-properties
建议使用 CSS 逻辑属性,以更好地支持国际化。
| 默认严重程度 | 预设 | 自动修复 | 选项 |
|---|---|---|---|
warning |
opinionated, nuxt |
不支持 | 无 |
适用范围:CSS、SCSS、Sass、Less 和 Stylus 的 style 块,按原样读取(不运行预处理器)。同一个 Stylus 块内请统一使用花括号语法或缩进语法;混合语法会按花括号 Stylus 读取。
错误示例
margin-left 无论书写方向如何,都将外边距固定在物理侧。
<style scoped>
.panel {
margin-left: 1rem;
}
</style>
正确示例
margin-inline-start 改为跟随行内方向的起始侧。
<style scoped>
.panel {
margin-inline-start: 1rem;
}
</style>
配置(Vite+)
import { defineConfig } from "@vizejs/vite-plugin/vite-plus";
export default defineConfig({}).withVue({
linter: {
"preset": "incremental",
"rules": {
"css/prefer-logical-properties": "warn"
}
},
});
然后运行 vp run lint。