【问题标题】: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
【解决方案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