-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[bug 1.4.1] semicolon insertion before ArrayExpression and others #1935
Comments
so I've diagnosed the 'issue' and it seems this is inserted intentionally to prevent issues with automatic semicolon insertion. Dunno why this was not acting like this before v1.4.1 for me. However that being said - it shouldnt be inserted automatically, only when the problem really might occur. For example eslint recognized those different situations correctly, it wont have problem with allowing someCall()
[a] = obj and the possible fix for the problem is to put semi at the end of the previous line like this someCall();
[a] = obj I think this looks way more naturally and we should print like this, gonna dig into the code to see if I can make that happen. |
Having the semicolon at the start of the line is more common with semi-colon-less development. It makes it obvious that the semi-colon is there for a semantic reason. https://standardjs.com/rules.html#semicolons The reason we always print the semi-colon at the start, even if it isn't strictly required, is that it makes it easier to move lines of code around the file without accidentally introducing ASI issues. Closing this as prettier is working as intended. |
@azz if (is.array(fn)) {
;[context, fn] = fn
} else if (fn.fn) {
;({ context, fn } = fn)
}
this argument is OTOH not that much appealing as prettier would just prevent ASI when formatting, its an automated process after all also this conflicts with |
This has already been discussed numerous times. |
--no-semi
affects this[]
produces;[]
({})
produces;({})
<div/>
produces;<div/>
Possibly other expressions are affected too.
The weird part is that by going back in git's history to the
v1.4.0
or even before that still produces the same result. However those cases didnt parse like this onv1.4.0
nor onv1.3.1
.You can checkout what prettier have changed for our codebase when upgrading to
v1.4.0
(ive ran prettier on all files) here. State before that upgrade is also full-prettier on versionv1.3.1
.After an attempt to upgrade to
v1.4.1
those 2 lines got affected by the 'bug' described, I didnt commit it yet though.I could have some stale npm packages in my
node_modules
before (didntrm -rf node_modules
after upgrade or before), maybe that was the case? Dunno how to verify that thoughNevertheless the behaviour is rly weird and I guess it should be fixed. Can help with that if u give a green light to it ;)
The text was updated successfully, but these errors were encountered: