No setting array properties rule

A TSLint rule which forbids setting array properties, because they aren't handled by JSON.stringify .

Description

When you call JSON.stringify on an array with custom properties, those properties aren't serialized. Example:

; ; arr [ " prop1 " ] = " 1 " ; arr [ prop2 ] = " 2 " ; JSON . stringify ( arr ) ;

This rule forbids property assignment and access on array types, so it forbids these two statements in the example above:

arr["prop1"] = "1";

arr[prop2] = "2";

Usage

Install it using npm install no-setting-array-properties-rule --save-dev .

. Add it to your tslint.json, like this:

{ " rulesDirectory " : [ " node_modules/no-setting-array-properties-rule/dist/src " ] , " rules " : { " no-setting-array-properties " : true } }

Note that this rule doesn't work in vscode-tslint at the moment, because it's a TypedRule . See this vscode-tslint issue for more details.

Changelog

See CHANGELOG.md.