Skip to content
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

es6 linting bug: destructuring named parameters with default values #34

Open
keithriver opened this issue Jan 15, 2017 · 0 comments
Open

Comments

@keithriver
Copy link

keithriver commented Jan 15, 2017

Test executes and passes successfully, but linter gives warning message:

Expected "," and instead saw "="
Expected an identifier and instead saw "0"

on lines with constructor parameters.

   describe('es6 parameters', function() {  
        it('constructor destructuring optional object with default values', function() {
    
            class Vector {
                constructor ({x = 0, y = 0} = {}) {
                  this.x = x
                  this.y = y
                }
            }
  
            class VisibleObject extends Vector {
              constructor ({x = 0, y = 0, opacity = 1} = {}) {
                  super({x, y})
                  this.opacity = opacity
                }
            }

            let vo1 = new VisibleObject({x: 10, y: 15})
            let vo2 = new VisibleObject()
    
            assert.equal(co1.x, 10);
            assert.equal(co1.y, 15);
            assert.equal(co1.opacity, 1);
            assert.equal(co2.x, 0);
            assert.equal(co2.y, 0);
            assert.equal(co2.opacity, 1);
        });
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant