Editorconfig:如何自动修复项目中的所有文件

标签 editorconfig

鉴于我有一个 .editorconfig 文件,它规定了一致的缩进、行尾、尾随空格等。

# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

作为一名开发人员,我想使用理解 .editorconfig 文件的命令行工具一致地修复所有文件。我想避免繁琐的任务,例如手动打开和更改文件。

我想如果有一个命令,例如:
editorconfix.sh --autofix .

为此目的存在哪些工具?你使用什么脚本?

最佳答案

eclint (还有一个名为 editorconfig-tools 的 fork )。跑

eclint check 'src/**/*'

检查 src 中的所有文件目录,或
eclint fix 'src/**/*'

修复它们。但请注意,当涉及到缩进时,该工具可能会产生一些惊喜!工具作者says in a GitHub comment他已经停止使用该工具,转而使用特定于语言的 linter:

To me, EditorConfig is all about – would you believe it – configuring your editor and nothing more. I don't think it should be responsible for linting or fixing, as there are language-specific tools to accomplish those goals (e.g., ESLint for JavaScript). The only way you can reliably lint or fix indentation is to be aware of the language in question and EditorConfig is language agnostic.

关于Editorconfig:如何自动修复项目中的所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39343031/

相关文章:

visual-studio-code - (为什么)我会在项目中同时使用 .editorconfig 文件和 VS 代码工作区设置?

visual-studio-code - Visual Studio代码的editorconfig

git - 共享 Git 存储库中的 .editorconfig

c# - 如何在 Visual Studio 2019 的错误列表窗口中显示所有建议/警告/错误

angular - 为什么 vscode 删除我的空间?

editorconfig - .editorconfig 文件在 VS 2017 中不起作用

visual-studio-code - 编辑器配置 - 如何对齐代码

c# - 由于 EditorConfig,Visual Studio 不会在 'internalclass' 之间放置空格