Skip to content

prefer-dom-node-dataset: Use [] accessor, rather than object (works better with TypeScript) #2699

@KieranP

Description

@KieranP

Description

Unicorn converted newDiv.setAttribute('data-field', 'value') to newDiv.dataset.field = 'value'. However, this doesn't play nicely with TypeScript.

Property 'field' comes from an index signature, so it must be accessed with ['field']. (ts 4111)

Instead, would be better if unicorn replaced it with:

newDiv.dataset['field'] = 'value'

which TypeScript prefers.

Examples

See above

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions