eslint-plugin-immutable icon indicating copy to clipboard operation
eslint-plugin-immutable copied to clipboard

no mutation error

Open ha404 opened this issue 8 years ago • 4 comments

Should this error on mutation?

  const formattedQuery = {
    ...query,
  }

  delete formattedQuery['access-token']

ha404 avatar Feb 14 '17 18:02 ha404

Yes. delete should be entirely forbidden.

You probably want const { 'access-token': unused, ...formattedQuery } = query; instead.

ljharb avatar Feb 14 '17 19:02 ljharb

Thanks! I don't see an error thrown for using delete what am I missing in the config?

ha404 avatar Feb 14 '17 19:02 ha404

It probably just doesn't check for it yet, but it should.

ljharb avatar Feb 14 '17 19:02 ljharb

I believe it should be possible to write a simple rule for this, by adding a visitor for the UnaryExpression node, and checking that the node.operator === 'delete'

AlanFoster avatar Mar 28 '17 23:03 AlanFoster