【问题标题】:Is there a simple way to refactor file indentation for a while code base?有没有一种简单的方法来重构文件缩进一段时间的代码库?
【发布时间】:2018-07-27 09:50:20
【问题描述】:

我有一个项目,它以 4 空格缩进开始,然后仅对某些文件切换到 2 空格。

现在我有 .editoconfig 文件来标准化缩进

*.{ts}]
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2

有没有办法将此新规则应用于现有代码?

【问题讨论】:

    标签: indentation automated-refactoring editorconfig


    【解决方案1】:

    我发现Resharper by Jetbrains 完全可以胜任。不幸的是,仅适用于Windows

    【讨论】:

      【解决方案2】:

      我们为此使用了 ESLint。我们使用此规则在项目根目录中创建了一个特殊的.eslintrc.json,并使用了--fix 命令行选项。

      但是您必须事先从项目中删除所有其他 eslint 配置文件,否则您将获得在其他地方定义的规则也会被自动修复。

      【讨论】:

        猜你喜欢
        • 2022-11-10
        • 1970-01-01
        • 2011-01-26
        • 1970-01-01
        • 1970-01-01
        • 2020-10-18
        • 2010-09-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多