Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Chris Shaffer
Chris Shaffer
12,030 Points

Workspace Bug - Chrome - Passing object as param (ES6 syntax) breaks indent

Was able to duplicate this repeatedly with a simple step.

Take this code from ES2015 Workshop for example

'use strict';

class Student {
  constructor({name, age, interestLevel = 5} = {}) {
    this.name = name
    this.age = age
    this.interestLevel = interestLevel
  }
}

The object passed here:

constructor({name, age, interestLevel = 5} = {})

will result in the indent changing from 2 to 15 for tab and the return position on each new line being at 15 spaces, as well.

Removing this object and doing something like

let props = {name, age, interestLevel = 5} = {}

results in the same behavior. In fact, passing anything in the object at all other than improper syntax such as {name: bob} (improper in this context anyway) results in said behavior.

I've produced this issue in Chrome Version 55.0.2883.95 (64-bit) on macOS 10.12.2.

Note that this also breaks syntax highlighting; key values like name go from orange to green highlighting, so this probably has something to do with whatever library you're using for the syntax highlighting.