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 = "1";arr = "2"; JSON.stringifyarr; //results in [1,2]
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:
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.