# no-setting-array-properties-rule

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

Latest version **0.0.3** (published 2017-11-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install no-setting-array-properties-rule
pnpm add no-setting-array-properties-rule
yarn add no-setting-array-properties-rule
bun add no-setting-array-properties-rule
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2017-11-04 |
| First published | 2017-11-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Leroy Witteveen |
| Maintainers | leroydev |

## Links

- npm: https://www.npmjs.com/package/no-setting-array-properties-rule
- Repository: https://github.com/leroydev/no-setting-array-properties-rule
- Homepage: https://github.com/leroydev/no-setting-array-properties-rule#readme
- Issues: https://github.com/leroydev/no-setting-array-properties-rule/issues
- npm.io page: https://npm.io/package/no-setting-array-properties-rule

## Dependencies (1)

- [tsutils](https://npm.io/package/tsutils.md) ^2.12.1

## Recent versions

- 0.0.3 (latest) — 2017-11-04
- 0.0.2 — 2017-11-02
- 0.0.1 — 2017-11-02

## README

[![NPM version](https://badge.fury.io/js/no-setting-array-properties-rule.svg)](http://badge.fury.io/js/no-setting-array-properties-rule)
[![Downloads](http://img.shields.io/npm/dm/no-setting-array-properties-rule.svg)](https://npmjs.org/package/no-setting-array-properties-rule)

No setting array properties rule
======

A [TSLint](https://github.com/palantir/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:
```ts
let arr: number[] = [1, 2];
const prop2: string = "prop2";

arr["prop1"] = "1";
arr[prop2] = "2";

JSON.stringify(arr); //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:
```json
{
   "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`](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.

Changelog
---------

See [CHANGELOG.md](CHANGELOG.md).

---
_Source: https://npm.io/package/no-setting-array-properties-rule · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
