Given I have an .editorconfig file that dictates consistent indent, line endings, trailing whitespace, etc.
# 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
As a Developer, I want to fix all files consistently with a command line tool that understands .editorconfig files. I want to avoid tedious tasks, for instance, manually open and change files.
I imagine if there was a command like for example:
editorconfix.sh --autofix .
Which tools exist for this purpose? What scripts do you use?
There is eclint (and a fork called editorconfig-tools). Run
eclint check 'src/**/*'
to check all files in the src
directory, or
eclint fix 'src/**/*'
to fix them. But please note that the tool can produce some surprises when it comes to indentation! The author of the tool says in a GitHub comment that he has stopped using the tool himself in favour of language-specific linters:
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.