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

Inconsistent formatting with Javascript and brackets #12541

Closed
EricG-Personal opened this issue Mar 26, 2022 · 1 comment
Closed

Inconsistent formatting with Javascript and brackets #12541

EricG-Personal opened this issue Mar 26, 2022 · 1 comment
Labels
type:duplicate Issues that are a duplicate of a previous issue

Comments

@EricG-Personal
Copy link

Prettier 2.6.1
Playground link

--parser babel
--print-width 120
--tab-width 4
--use-tabs
--single-quote
--no-bracket-spacing
--trailing-comma none

Input:

let a = [{a: 'a longer string', b: 'an even longer string'}];

let a = [{a: 'a longer string', 
          b: 'an even longer string'}];
          
let a = [{
    a: 'a longer string', 
    b: 'an even longer string'
}];
        
let a = [
    {
        a: 'a longer string', 
        b: 'an even longer string'
    }
]; 

Output:

let a = [{a: 'a longer string', b: 'an even longer string'}];

let a = [{a: 'a longer string', b: 'an even longer string'}];

let a = [
	{
		a: 'a longer string',
		b: 'an even longer string'
	}
];

let a = [
	{
		a: 'a longer string',
		b: 'an even longer string'
	}
];

Expected behavior:

I would expect Prettier's opinion on how this object to look to be consistent regardless of how the user initially typed it. At the moment, there are (at least) two possible answers for how Prettier will format the same code.

@kachkaev
Copy link
Member

👋 @EricG-Personal! Please see #2068 and #11856. This behaviour has been a long-standing trade-off between the deterministic behaviour and output ugliness. Thoughts are welcome in #2068!

@kachkaev kachkaev added the type:duplicate Issues that are a duplicate of a previous issue label Mar 26, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:duplicate Issues that are a duplicate of a previous issue
Projects
None yet
Development

No branches or pull requests

2 participants