【问题标题】:How to get editorconfig file from eslintrc file?如何从 eslintrc 文件中获取 editorconfig 文件?
【发布时间】:2017-05-17 18:48:02
【问题描述】:

我正在尝试为我的项目设置标准代码样式,并且我找到了http://editorconfig.org/,这是一个标准。我非常喜欢它,Intellij 支持它(我们使用 Intellij)。

我有一个 .eslintrc 文件(从 airbnb 样式扩展)。

那么,如何从 .eslintrc 文件中获取 .editorconfig 文件?

【问题讨论】:

  • 不清楚“那么,如何从 .eslintrc 文件中获取 .editorconfig 文件?”是什么意思。你能详细说明吗?如果您在项目的根目录中包含这两个文件,Intellij 将自动使用.editorconfig。如果你想将 ESLint 与 Intellij 一起使用,你需要使用像 github.com/idok/eslint-plugin 这样的包,但它也应该在项目的根目录中选择并使用配置。

标签: phpstorm eslint editorconfig


【解决方案1】:

如果您正在寻找配置由eslint-config-airbnb 规则强制执行的样式的.editorconfig,您可以使用该模块存储库中的.editorconfig 文件:

https://github.com/airbnb/javascript/blob/master/.editorconfig

【讨论】:

    【解决方案2】:

    我为此目的找到了 eslint-to-editorconfig,但我无法让它从 airbnb 基本规则扩展规则。也许你会有更好的运气:

    $ ./node_modules/.bin/eslint-to-editorconfig  
    /path/to/app/node_modules/eslint-to-editorconfig/node_modules/eslint/lib/config/config-file.js:402
                throw e;
                ^
    
    Error: /path/to/app/node_modules/eslint-config-airbnb-base/rules/es6.js:
        Configuration for rule "arrow-parens" is invalid:
        Value "as-needed,[object Object]" has more items than allowed.
    
    Referenced from: airbnb-base
    Referenced from: /path/to/app/.eslintrc
    

    【讨论】:

      猜你喜欢
      • 2019-10-07
      • 1970-01-01
      • 2022-11-29
      • 2015-07-30
      • 2012-04-22
      • 2014-01-18
      • 2021-08-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多