eslint object-shorthand error with variable passed in

Solution 1:

An excerpt from eslint regarding the issue:

Require Object Literal Shorthand Syntax (object-shorthand) - Rule Details

This rule enforces the use of the shorthand syntax. This applies to all methods (including generators) defined in object literals and any properties defined where the key name matches name of the assigned variable.

Change

closeOnSelect: closeOnSelect

to just

closeOnSelect

Solution 2:

This rule checks that object literal shorthand syntax is used, e.g {a, b} instead of {a: a, b: b}. The rule is configurable, see options for more details.

Despite this shorthand syntax is convenient, in some cases you may not want to force it usage. You can disable the check in your config:

// .eslintrc.json

{
  "rules": {
    // Disables the rule. You can just remove it,
    // if it is not enabled by a parent config.
    "object-shorthand": 0
  }
}

In case of TSLint there is a different option:

// tslint.json

{
  "rules": {
    // Disables the rule. You can just remove it,
    // if it is not enabled by a parent config.
    "object-literal-shorthand": false
  }
}