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?
editorconfig file doesn't override a particular setting. An example of such a preference is indent style—tabs or spaces. EditorConfig settings are supported by many code editors and IDEs, including Visual Studio.
Here the root=true specify to the editor that it is the top-most EditorConfig file, any rules specified under this section header- [*] will be applied to all the files including your *. js, *. css, etc. You can have specific rules for specific files for example [*.
editorconfig to GitHub or not? It depends. If the files are specific to your project, then it is appropriate to commit them. If they are appropriate for your work flow, then it is not.
EditorConfig helps maintain consistent coding styles for multiple developers working on the same project across various editors and IDEs.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With