Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rule proposal: no-array-delete #4432

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin
@davidmaxwaterman

Description

@davidmaxwaterman

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

>varmyArray=[1,2,3];undefined>deletemyArray[1];true>myArray(3) [1,empty,3]>myArray[1]undefined>myArray.length3

Pass

>varmyArray=[1,2,3];(3) [1,2,3]>myArray.splice(1,1)[2]>myArray(2) [1,3]

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: new plugin ruleNew rule request for eslint-pluginpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp