You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS Code中启用no-inline-styles规则?

启用no-inline-styles规则的方法

基于HTMLHint配置

  • 先确认VS Code已安装HTMLHint扩展
  • 在项目根目录新建或编辑.htmlhintrc配置文件,写入:
    {
      "no-inline-styles": true
    }
    
  • 保存文件后,VS Code会自动应用配置,该规则将开始检测代码中的内联样式并给出提示。

基于ESLint配置(需搭配eslint-plugin-html)

  • 先在项目终端安装依赖:
    npm install eslint eslint-plugin-html --save-dev
    
  • 在项目根目录新建或编辑.eslintrc.json配置文件,添加以下内容:
    {
      "plugins": ["html"],
      "rules": {
        "no-inline-styles": "error"
      }
    }
    
  • 重启VS Code或触发ESLint重新加载,规则即可生效。

内容的提问来源于stack exchange,提问作者Coder

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 05:33:12