Home | javascript

react-beautify breaking chained methods

Problem

If you ae using VS Code, and uses react-beautify to fomat your code, Your chained methods sometimes load in different lines as follows

$
.get('/api/data')
.then(process)
.error(handleError)

Solution

Create a .jsbeautifyrc file, if you dont have already, add the following lines

{
    "methodchain": "chain"
}