Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 935 Bytes

no-useless-computed-properties.md

File metadata and controls

39 lines (27 loc) · 935 Bytes

Prevent the usage of unnecessary computed properties. (no-useless-computed-properties)

Computed properties allow you to define methods and properties of an object or class without having to know exact name of the key.

Rule Details

This rule aims to prevent the use of a computed property when the value being computed is a literal (and could therefore omit the computed property altogether).

The following patterns are considered warnings:

var foo = {
  ['bar']: true,
}

class Foo {
  ['bar']() {}
  static [123]() {}
}

The following patterns are not warnings:

var foo = {
  'bar': true,
  baz: true,
  [qux]: true,
  [buzz()]: true,
}

When Not To Use It

If you do not care about unnecessarily computed properties, you can safely disable this rule.

Further Reading