Javascript: Unused variables when destructuring?

Created on 23 Jul 2015  路  2Comments  路  Source: airbnb/javascript

I just wrote this code:

  dirtyProperties() {
    return this._getProperties()
      .filter(([ prop ]) => prop.isDirty())
      .map(([ _, propName ]) => propName);
  }

and eslint threw a no-unused-vars error because of the _ variable.

Is this against the Airbnb style guide? I feel like using _ to ignore the first destructured variable should be pretty well understood and not using destructuring would make the code more verboe.

Most helpful comment

Ooops, I just realized I can do [ , propName ].

All 2 comments

_ is just a convention. However, https://github.com/airbnb/javascript/blob/master/linters/.eslintrc#L46-L49 allows what you want in _arguments_ - I think this is just something eslint hasn't handled yet.

If I'm correct (and we're not just missing a rule for this) I'd suggest opening a bug on eslint itself, and request that rule exception.

Ooops, I just realized I can do [ , propName ].

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielfttorres picture danielfttorres  路  3Comments

zurfyx picture zurfyx  路  3Comments

ar
mbifulco picture mbifulco  路  3Comments

tunnckoCore picture tunnckoCore  路  3Comments

brendanvinson picture brendanvinson  路  4Comments