File tree Expand file tree Collapse file tree 2 files changed +61
-1
lines changed
Expand file tree Collapse file tree 2 files changed +61
-1
lines changed Original file line number Diff line number Diff line change 1+ # Changelog
2+ All notable changes to this project will be documented in this file.
3+
4+ ## [ 0.0.3] - 2017-11-04
5+ ### Added
6+ - Added project description and usage details to README.MD.
7+ - Added CHANGELOG.MD.
8+
9+ ## [ 0.0.2] - 2017-11-02
10+ ### Changed
11+ - Fixed ` dist ` folder not being distributed to NPM.
12+
13+ ## [ 0.0.1] - 2017-11-02
14+ ### Initial release.
Original file line number Diff line number Diff line change 1- # no-setting-array-properties-rule
1+ [ ![ NPM version] ( https://badge.fury.io/js/no-setting-array-properties-rule.svg )] ( http://badge.fury.io/js/no-setting-array-properties-rule )
2+ [ ![ Downloads] ( http://img.shields.io/npm/dm/no-setting-array-properties-rule.svg )] ( https://npmjs.org/package/no-setting-array-properties-rule )
3+
4+ No setting array properties rule
5+ ======
6+
7+ A [ TSLint] ( https://github.com/palantir/tslint/ ) rule which forbids setting array properties, because they aren't handled by ` JSON.stringify ` .
8+
9+ Description
10+ -----------
11+
12+ When you call ` JSON.stringify ` on an array with custom properties, those properties aren't serialized. Example:
13+ ``` ts
14+ let arr: number [] = [1 , 2 ];
15+ const prop2: string = " prop2" ;
16+
17+ arr [" prop1" ] = " 1" ;
18+ arr [prop2 ] = " 2" ;
19+
20+ JSON .stringify (arr ); // results in [1,2]
21+ ```
22+
23+ This rule forbids property assignment and access on ` array ` types, so it forbids these two statements in the example above:
24+ * ` arr["prop1"] = "1"; `
25+ * ` arr[prop2] = "2"; `
26+
27+ Usage
28+ -----
29+
30+ * Install it using ` npm install no-setting-array-properties-rule --save-dev ` .
31+ * Add it to your tslint.json, like this:
32+ ``` json
33+ {
34+ "rulesDirectory" : [
35+ " node_modules/no-setting-array-properties-rule/dist/src"
36+ ],
37+ "rules" : {
38+ "no-setting-array-properties" : true
39+ }
40+ }
41+ ```
42+ Note that this rule doesn't work in [ ` vscode-tslint ` ] ( https://github.com/Microsoft/vscode-tslint ) at the moment, because it's a ` TypedRule ` . See [ this ` vscode-tslint ` issue] ( https://github.com/Microsoft/vscode-tslint/issues/70 ) for more details.
43+
44+ Changelog
45+ ---------
46+
47+ See [ CHANGELOG.md] ( CHANGELOG.md ) .
You can’t perform that action at this time.
0 commit comments