convert_index_to_field
Added in 0.7.0
When an index expression is using a static string (or an expression that can be statically evaluated into a string), this rule replaces it with a field expression. This rule also applies for table declarations: an entry that uses the bracket syntax (e.g. { ["key"] = value }
) will get converted into a field-like entry when possible.
Examples
return var['field']
return var.field
return { ['field'] = true }
return { field=true }
Input | Output |
---|---|
|
|
|
|