Skip to content

Style critique on no-unused-vars. #726

@EvanCarroll

Description

@EvanCarroll

You have no-unused-vars set in your eslint profile to 'args': 'after-used'. That's not always good because it forces a callback to forgo arguments if it's not using them...

view.model.login.call(view.model, {
  error: function (model, xhr, options) {
    // only use model, xhr
  }
}

If it only uses model (the first argument), that means it has to look like this..

view.model.login.call(view.model, {
  error: function (model) {
    // only use model
  }
}

Which means finding out the order of subsequent arguments means you have to look it up. It also means the signature of the function is in some cases forced to not-match the invocation as in the case where you provide a callback, and the callback is always invoked with three whether or not you need those arguments (as is the case above). This really kills a clean form of code-documentation.

My suggestion is to go from

"no-unused-vars": [2, {"vars": "all", "args": "after-used"}]

to

"no-unused-vars": [2, {"vars": "all", "args": "none"}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions