Skip to content

deeply nested object literals #88

Description

@johann-sonntagbauer

Currently deeply nested object literals will be formatted in a collapsed form.

This behavior is nice for simple object literals, but for deeply nested ones it would be nice to have the nested properties indented. Maybe a complexity level (like for Arrow expressions) would be nice here.

source

var simple = {
name:'a'
}

var deeplyNested = {
    name:'f',
    nested: {
    	nested: {
    		nested: {
    			nested: {
    				nested: {
    					nested: {
    						nested: {
    							name: 'a'
    						}
    					}
    				}
    			}
    		}
    	}
    }
};

formatted

var simple = {name: 'a'};

var test = {
  name: 'f',
  nested: {
    nested: {nested: {nested: {nested: {nested: {nested: {name: 'a'}}}}}}
  }
};

https://vjeux.github.io/prettier-browser/#%7B%22content%22%3A%22%5Cnvar%20simple%20%3D%20%7B%5Cnname%3A'a'%5Cn%7D%5Cn%5Cnvar%20test%20%3D%20%7B%5Cn%20%20%20%20name%3A'f'%2C%5Cn%20%20%20%20nested%3A%20%7B%5Cn%20%20%20%20%5Ctnested%3A%20%7B%5Cn%20%20%20%20%5Ct%5Ctnested%3A%20%7B%5Cn%20%20%20%20%5Ct%5Ct%5Ctnested%3A%20%7B%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ctnested%3A%20%7B%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ct%5Ctnested%3A%20%7B%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ct%5Ct%5Ctnested%3A%20%7B%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ct%5Ct%5Ct%5Ctname%3A%20'a'%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ct%5Ct%5Ct%7D%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ct%5Ct%7D%5Cn%20%20%20%20%5Ct%5Ct%5Ct%5Ct%7D%5Cn%20%20%20%20%5Ct%5Ct%5Ct%7D%5Cn%20%20%20%20%5Ct%5Ct%7D%5Cn%20%20%20%20%5Ct%7D%5Cn%20%20%20%20%7D%5Cn%7D%3B%22%2C%22options%22%3A%7B%22printWidth%22%3A80%2C%22tabWidth%22%3A2%2C%22useFlowParser%22%3Afalse%2C%22singleQuote%22%3Atrue%2C%22trailingComma%22%3Afalse%2C%22bracketSpacing%22%3Afalse%7D%7D

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.status:needs discussionIssues needing discussion and a decision to be made before action can be taken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions