Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Fix the indent spaces #43

Closed
michaeljota opened this issue Aug 27, 2016 · 8 comments
Closed

Fix the indent spaces #43

michaeljota opened this issue Aug 27, 2016 · 8 comments
Labels

Comments

@michaeljota
Copy link

Hi!

I saw that you think this tool doesn't suposse to fix indent spaces, but that's all why I downloaded it in the first place. I also try editorconfig-tools but it does not support wildcards out the box (I'm on Windows).

editorconfig-tools says that I can fix the indent spaces. Why this cannot? The .editorcofig file it's all about common configuration. Even if there is something wrong with the fix, there is nothing you can do, they just got the configuration wrong themselfs. I think that at least.

Thanks you!

@jednano
Copy link
Owner

jednano commented Aug 27, 2016

Quite honestly? I don't even believe in the concept of this tool at all any more and I don't use it myself for that very reason. 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.

I think EditorConfig is more about getting your editor configured properly so that you don't insert bad indentation in the first place. It's more about prevention than fixing. Make sense?

@michaeljota
Copy link
Author

It makes sense to me right now. I just downloaded a template and it's indent using 4 spaces. My team use 2 spaces. So I just want a tool that allows me to change it's indentation. This tool would do it.

I mean, yeah, you are right probably, this tool it's not useful all the time, but this corner cases would be really helpful to have something like this.

I hope you still want to support this.

Thanks,

@jednano
Copy link
Owner

jednano commented Aug 27, 2016

Out of curiosity, what language are you writing in and why don't you use a linting tool for that language?

@michaeljota
Copy link
Author

I'm using JS, and I do use a linting tool for that language. However, none of those are able to "fix" indent spaces. Maybe cause it's not a problem, but I would like to have all with the same configuration.

@jednano
Copy link
Owner

jednano commented Aug 28, 2016

What is the name of the linting tool you use?

@jednano
Copy link
Owner

jednano commented Aug 28, 2016

Also, in answer to your previous question, asking why this tool "can't do it," it's because it "cannot be done." I don't care what other tools claim they can do. I've done so much development, trying to fix this problem w/o knowledge of the language in question and I came to a conclusion that it literally cannot be done. You absolutely need to be aware of the language syntax to do it properly. Anything else is half-assed and will yield inconsistent results. For example, without knowing that you're dealing with JavaScript, you couldn't even lint that the following block of code properly, let alone "fix" it:

    /*
     * some comment
     */
    function foo() {
        // function body
    }

You need to understand that the space before the * in the multi-line comment does not count as indentation. In fact, it's considered alignment in this case. You would never know that if you weren't aware of the language in question.

There are so many potential inputs that would never "fix" indentation properly and the fundamental reason is that there's no correct way to detect what the proper indentation should be in the first place if you can't understand what you're looking at. That's the root of the problem.

The main problem, as I've said time and time again, is that people are using spaces for indentation. I am a strong believer in tabs for indentation and spaces for alignment, for this very reason:

tabs-vs-spaces

If everyone used tabs for indentation followed by spaces for alignment, well, your issue wouldn't be an issue at all, because you would just view the code in whatever tab width you deem appropriate.

That said, I'm sure there are a host of tools that claim to do such and such job. If you want to use those tools, fine. Nobody is stopping you. But I promise you they will make mistakes unless they are language-specific tools, aware of the syntax tree.

@jednano
Copy link
Owner

jednano commented Aug 28, 2016

@michaeljota
Copy link
Author

I'm using ESLint, but it doesn't autofix the indentation. You have a good point. The tool would need to know the lenguage syntaxis and how tabs it's being use, if they are.

Thanks anyway. I'm closing this now. :).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants