Coder Social home page Coder Social logo

Fix the indent spaces about eclint HOT 8 CLOSED

jednano avatar jednano commented on June 19, 2024
Fix the indent spaces

from eclint.

Comments (8)

jednano avatar jednano commented on June 19, 2024

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?

from eclint.

michaeljota avatar michaeljota commented on June 19, 2024

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,

from eclint.

jednano avatar jednano commented on June 19, 2024

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

from eclint.

michaeljota avatar michaeljota commented on June 19, 2024

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.

from eclint.

jednano avatar jednano commented on June 19, 2024

What is the name of the linting tool you use?

from eclint.

jednano avatar jednano commented on June 19, 2024

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.

from eclint.

jednano avatar jednano commented on June 19, 2024

For the record, ESLint has an autofix capability with the --fix flag.

from eclint.

michaeljota avatar michaeljota commented on June 19, 2024

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. :).

from eclint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.