question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ES6 rest args triggers warnings

See original GitHub issue

This code

"use strict";
module.exports.b = function foo(...args) {
  return args;
};

With this config

settings:
  ecmascript: 6
env:
  node: true
rules:
  block-scoped-var: 1

Results in this

eslint-test.js
  2:35  warning  "args" used outside of binding context  block-scoped-var
  3:9   warning  "args" used outside of binding context  block-scoped-var
  3:9   error    'args' is not defined                   no-undef

✖ 3 problems

The obvious problem here is that rest args just aren’t supported in these rules. (v0.11.0-alpha.0)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
platinumazurecommented, Apr 5, 2017

@Willibaur The spread operator needs to be used on a defined variable. Usually, you would do so by declaring a rest parameter in the method definition.

Try this:

  didTransition(...args) { // <-- Variable definition: args
    this._super(...args);
    Ember.run.scheduleOnce('afterRender', this, () => {
      this._trackPage(this.get('url'), document.title);
    });
  },

If you still have trouble or have any follow-ups, please create a new issue or stop by our Gitter chat. Thanks!

0reactions
Willibaurcommented, Apr 5, 2017

Awesome, thanks @platinumazure it worked straight away, thank you very much for you quick answer

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rest parameters and spread syntax
Here the first two arguments go into variables and the rest go into titles array: function showName(firstName, lastName, ...titles) { alert( ...
Read more >
Rest parameters - JavaScript - MDN Web Docs
The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent variadic ......
Read more >
How To Use ES6 Arguments And Parameters
We can now use rest parameters, default values and destructuring, among other new features. In this tutorial, we will explore arguments and ...
Read more >
What is spread, default and rest parameters in JavaScript
Rest Operator: It allows a function to accept an indefinite number of arguments if we are not sure how many arguments will receive....
Read more >
Destructuring and parameter handling in ECMAScript 6 - 2ality
ECMAScript 6 (ES6) supports destructuring, a convenient way to extract values ... The rest operator triggers the following destructuring:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found