-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Description
Deleting an array element can lead to unexpected (for some) behaviour since it leaves 'length' unchanged. Some might say that using delete on array elements should best be avoided and there are alternatives - splice() seems to be preferred.
Having a rule to prevent delete being used on arrays would be beneficial.
Fail
> var myArray = [ 1, 2, 3 ];
undefined
> delete myArray[1];
true
> myArray
(3) [1, empty, 3]
> myArray[1]
undefined
> myArray.length
3
Pass
> var myArray = [ 1, 2, 3 ];
(3) [1, 2, 3]
> myArray.splice(1,1)
[2]
> myArray
(2) [1, 3]
omril1, Ginden, JoshuaKGoldberg, NanderTGA and darrylnoakes
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin