diff --git a/src/language-js/printer-estree.js b/src/language-js/printer-estree.js index 4934b0893..8c4faea4f 100644 --- a/src/language-js/printer-estree.js +++ b/src/language-js/printer-estree.js @@ -4440,10 +4440,11 @@ function printMemberChain(path, options, print) { // .map(x => x) // // In order to detect those cases, we use an heuristic: if the first - // node is an identifier with the name starting with a capital letter. - // The rationale is that they are likely to be factories. + // node is an identifier with the name starting with a capital + // letter or just a sequence of _$. The rationale is that they are + // likely to be factories. function isFactory(name) { - return /^[A-Z]/.test(name); + return /^[A-Z]|^[_$]+$/.test(name); } // In case the Identifier is shorter than tab width, we can keep the diff --git a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap index 132c9a896..c87349a4b 100644 --- a/tests/method-chain/__snapshots__/jsfmt.spec.js.snap +++ b/tests/method-chain/__snapshots__/jsfmt.spec.js.snap @@ -607,6 +607,16 @@ Object.keys( .forEach(locale => { // ... }); + +this.layoutPartsToHide = this.utils.hashset( + _.flatMap(this.visibilityHandlers, fn => fn()) + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean) +); + +var jqxhr = $.ajax("example.php") + .done(doneFn) + .fail(failFn); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Object.keys( availableLocales({ @@ -616,6 +626,16 @@ Object.keys( // ... }); +this.layoutPartsToHide = this.utils.hashset( + _.flatMap(this.visibilityHandlers, fn => fn()) + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean) +); + +var jqxhr = $.ajax("example.php") + .done(doneFn) + .fail(failFn); + `; exports[`logical.js 1`] = ` diff --git a/tests/method-chain/inline_merge.js b/tests/method-chain/inline_merge.js index 7a1623fb7..a9ef2445a 100644 --- a/tests/method-chain/inline_merge.js +++ b/tests/method-chain/inline_merge.js @@ -6,3 +6,13 @@ Object.keys( .forEach(locale => { // ... }); + +this.layoutPartsToHide = this.utils.hashset( + _.flatMap(this.visibilityHandlers, fn => fn()) + .concat(this.record.resolved_legacy_visrules) + .filter(Boolean) +); + +var jqxhr = $.ajax("example.php") + .done(doneFn) + .fail(failFn);