-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Labels
area:rangesIssues about formatting/ignoring/etc segments of filesIssues about formatting/ignoring/etc segments of fileslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 1.14.0
Playground link
--parser babylon
--range-end 304
--range-start 101
Can reproduce with just range 100 - 101 (the newline character after the brace on line 4), so that seems to be the culprit.
If I replace line 4 with an expression (e.g. let x) then the method is formatted correctly more often so long as my selection covers the second character of the expression, but you can break it again by moving the start of the selection over the brace on line 3.
Input:
class Foo {
/** Does this key match a given MinimalKey extending object? */
match(keyevent) {
// 'in' doesn't include prototypes, so it's safe for this object.
for (let attr in this) {
if (this[attr] !== keyevent[attr]) return false
}
return true
}
}
Output:
class Foo {
/** Does this key match a given MinimalKey extending object? */
match(keyevent) {
// 'in' doesn't include prototypes, so it's safe for this object.
for (let attr in this) {
if (this[attr] !== keyevent[attr]) return false;
}
return true;
}
}
Expected behavior:
Don't indent so much. Don't be so sensitive to range choice.
ppaul, MasonD and sheerun
Metadata
Metadata
Assignees
Labels
area:rangesIssues about formatting/ignoring/etc segments of filesIssues about formatting/ignoring/etc segments of fileslang:javascriptIssues affecting JSIssues affecting JSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.