Here is an example of an object that I have:
{
element: 'tool-app',
file: '/tool-app.js',
icon: 'csr-icon',
name: 'Planning view',
id: 'planning-view'
}
To simplify things, I want to store the value of the icon in a variable and then use that variable in the object. First, I create a constant:
const icon = 'csr-icon';
Next, I try to use the icon variable in the object:
{
element: 'tool-app',
file: '/tool-app.js',
icon: icon, ///change here
name: 'Planning view',
id: 'planning-view'
}
Even though it should be the same, Tslint is showing an error:
Expected property shorthand in object literal ('{icon}'). (object-literal-shorthand)tslint(1)
Why is this happening?