RubyMine代码重新格式化不考虑ESLint配置

问题描述 投票:2回答:1

我已经在RubyMine(或任何IntelliJ产品)中设置了ESLint,并且在编辑时可以看到警告和错误。

enter image description here

但是当我执行代码->重新格式化代码时,它使用4个空格进行缩进(编辑器中的设置->代码样式-> Java脚本),但我在.eslintrc中设置了2个空格

{
  "extends": "airbnb",
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "es6": true,
    "commonjs": true
  },
  "plugins": [
    "react"
  ],
  "indent": [
    2,
    2
  ],
  "object-curly-spacing": [
    "always"
  ],
}

如何在格式化代码时要求RubyMine使用.eslintrc中的设置?

javascript intellij-idea rubymine eslint
1个回答
1
投票

您可以应用ESLint规则以用于自动格式化程序,模板等。但是,坦率地说,您必须知道它在哪里。如果您不知道要看哪里,则几乎没有机会实际找到它。

打开您的.eslintrc,然后在编辑器窗格中右键单击(打开上下文菜单)。从选项中选择Apply ESLint Code Style Rules

请参见下面的屏幕截图。

请记住,每次触摸.eslintrc时都必须重复此过程。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.