Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indentation of object literals #2278

Closed
andersekdahl opened this issue Apr 10, 2015 · 7 comments

Comments

Projects
None yet
5 participants
@andersekdahl
Copy link

commented Apr 10, 2015

Not sure if this is considered a feature request or a bug, but I can't find any combination of style rules that would warn about these code snippets:

let myvar = {
          y: 1,
            x: 2
                           };

or:

func(1, 2,
        {
x: {
  y: 3
          }
               });

The indentation of these snippets are way off, but as I said, I can't find any rules to flag this. I guess it's not a simple problem since you might want to align function arguments to start after the function name, something like:

func(1,
     2,
     {
       x: {
         y: 3
       }
     }
);

But it should be pretty universal that { and } should be on the same indentation level, and that properties in an object literal should have the same indentation.

I'd be happy to take a crack at it, if someone could give me some starting pointers.

@andersekdahl

This comment has been minimized.

Copy link
Author

commented Apr 10, 2015

Found a plugin which handles this here: https://github.com/nodeca/eslint-plugin-nodeca/blob/master/lib/indent.js

Perhaps include that in the builtin indent rule?

@nzakas

This comment has been minimized.

Copy link
Member

commented Apr 10, 2015

Yeah, our indent rule has a bunch of bugs, we will take a look.

@thaiat

This comment has been minimized.

Copy link

commented Jul 5, 2015

any update ?

@ilyavolodin

This comment has been minimized.

Copy link
Member

commented Jul 5, 2015

Issue is open and accepted. Just waiting for somebody to create a pull request.

@nzakas

This comment has been minimized.

Copy link
Member

commented Jul 6, 2015

@thaiat If a rule is marked as "accepted" it means it's on the roadmap. We are waiting for someone to claim this issue. There won't be any updates until someone volunteers to work on it.

@thaiat

This comment has been minimized.

Copy link

commented Jul 8, 2015

@nzakas for what it worth i started using the nodeca plugin : https://github.com/nodeca/eslint-plugin-nodeca and it works great.
Maybe there is no need for reinventing the wheel/rule here

@gyandeeps

This comment has been minimized.

Copy link
Member

commented Jul 12, 2015

working on this.

gyandeeps added a commit that referenced this issue Jul 13, 2015

gyandeeps added a commit that referenced this issue Jul 13, 2015

gyandeeps added a commit that referenced this issue Jul 13, 2015

gyandeeps added a commit that referenced this issue Jul 14, 2015

@nzakas nzakas closed this in #2978 Jul 14, 2015

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.