You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`ts-immutable/readonly-keyword`](./docs/rules/readonly-keyword.md)| Enforce readonly modifiers are used where possible.|:heavy_check_mark:|:wrench:||
83
-
|[`ts-immutable/readonly-array`](./docs/rules/readonly-array.md)| Prefer readonly array over mutable arrays.|:heavy_check_mark:|:wrench:||
|[`ts-immutable/no-method-signature`](./docs/rules/no-method-signature.md)| Prefer property signatures with readonly modifiers over method signatures.|:heavy_check_mark:|||
|[`ts-immutable/readonly-keyword`](./docs/rules/readonly-keyword.md)| Enforce readonly modifiers are used where possible |:heavy_check_mark:|:wrench:||
83
+
|[`ts-immutable/readonly-array`](./docs/rules/readonly-array.md)| Prefer readonly array over mutable arrays |:heavy_check_mark:|:wrench:||
|[`ts-immutable/no-mixed-interface`](./docs/rules/no-mixed-interface.md)| Restrict interfaces so that only members of the same kind of are allowed in them.|:heavy_check_mark:|||
97
-
|[`ts-immutable/no-expression-statement`](./docs/rules/no-expression-statement.md)| Using expressions to cause side-effects not allowed.|:heavy_check_mark:|||
98
-
|[`ts-immutable/no-if-statement`](./docs/rules/no-if-statement.md)| Disallow if statements.|:heavy_check_mark:|||
|[`ts-immutable/no-mixed-interface`](./docs/rules/no-mixed-interface.md)| Restrict interfaces so that only members of the same kind of are allowed in them |:heavy_check_mark:|||
97
+
|[`ts-immutable/no-expression-statement`](./docs/rules/no-expression-statement.md)| Using expressions to cause side-effects not allowed |:heavy_check_mark:|||
98
+
|[`ts-immutable/no-if-statement`](./docs/rules/no-if-statement.md)| Disallow if statements |:heavy_check_mark:|||
[![Type Info Required][type-info-badge]][type-info-url]
3
+
This rule prohibits mutating an array via assignment to or deletion of their elements/properties. This rule enforces array immutability without the use of `ReadonlyArray<T>` (as apposed to [readonly-array](./readonly-array.md)).
4
4
5
-
This rule prohibits mutating an array via assignment to or deletion of their elements/properties. This rule enforces array immutability without the use of `ReadonlyArray<T>` (as apposed to [readonly-array](#readonly-array)).
5
+
## Rule Details
6
6
7
7
```typescript
8
8
const x = [0, 1, 2];
@@ -12,28 +12,34 @@ x.length = 1; // <- Mutating an array is not allowed.
12
12
x.push(3); // <- Mutating an array is not allowed.
13
13
```
14
14
15
-
#### Has Fixer
15
+
##Options
16
16
17
-
No
17
+
The rule accepts an options object with the following properties:
const sorted =original.slice().sort((a, b) =>a.localeCompare(b)); // This is OK with ignore-new-array - note the use of the `slice` method which returns a copy of the original array.
35
41
```
36
42
37
-
```javascript
38
-
"no-array-mutation": [true, "ignore-new-array"]
39
-
```
43
+
### `ignorePattern`
44
+
45
+
See the [ignorePattern](./options-ignore-pattern.md) docs.
Copy file name to clipboardExpand all lines: docs/rules/no-class.md
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,8 @@
1
-
### no-class
1
+
# Disallow classes (no-class)
2
+
3
+
Disallow use of the `class` keyword.
4
+
5
+
## Rule Details
2
6
3
7
Thanks to libraries like [recompose](https://github.com/acdlite/recompose) and Redux's [React Container components](http://redux.js.org/docs/basics/UsageWithReact.html), there's not much reason to build Components using `React.createClass` or ES6 classes anymore. The `no-this` rule makes this explicit.
Copy file name to clipboardExpand all lines: docs/rules/no-if-statement.md
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
-
### no-if-statement
1
+
#Disallow if statements (no-if-statement)
2
2
3
-
If statements is not a good fit for functional style programming as they are not expresssions and do not return a value. This rule disallows if statements.
3
+
This rule disallows if statements.
4
+
5
+
## Rule Details
6
+
7
+
If statements is not a good fit for functional style programming as they are not expresssions and do not return a value.
4
8
5
9
```typescript
6
10
let x;
@@ -18,3 +22,7 @@ const x = i === 1 ? 2 : 3;
18
22
```
19
23
20
24
For more background see this [blog post](https://hackernoon.com/rethinking-javascript-the-if-statement-b158a61cd6cb) and discussion in [#54](https://github.com/jonaskello/tslint-immutable/issues/54).
This rule should be combined with tslint's built-in `no-var-keyword` rule to enforce that all variables are declared as `const`.
4
4
5
+
## Rule Details
6
+
5
7
There's no reason to use `let` in a Redux/React application, because all your state is managed by either Redux or React. Use `const` instead, and avoid state bugs altogether.
Copy file name to clipboardExpand all lines: docs/rules/no-loop-statement.md
+10-2Lines changed: 10 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,10 @@
1
-
### no-loop-statement
1
+
#Disallow imperative loops (no-loop-statement)
2
2
3
-
In functional programming we want everthing to be an expression that returns a value. Loops in typescript are statements so they are not a good fit for a functional programming style. This rule disallows for loop statements, including `for`, `for...of`, `for...in`, `while`, and `do...while`.
3
+
This rule disallows for loop statements, including `for`, `for...of`, `for...in`, `while`, and `do...while`.
4
+
5
+
## Rule Details
6
+
7
+
In functional programming we want everthing to be an expression that returns a value. Loops in typescript are statements so they are not a good fit for a functional programming style.
For more background see this [blog post](https://hackernoon.com/rethinking-javascript-death-of-the-for-loop-c431564c84a8) and discussion in [#54](https://github.com/jonaskello/tslint-immutable/issues/54).
Copy file name to clipboardExpand all lines: docs/rules/no-method-signature.md
+9-1Lines changed: 9 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,8 @@
1
-
### no-method-signature
1
+
# Prefer property signatures with readonly modifiers over method signatures (no-method-signature)
2
+
3
+
Prefer property signatures with readonly modifiers over method signatures.
4
+
5
+
## Rule Details
2
6
3
7
There are two ways function members can be declared in an interface or type alias:
4
8
@@ -10,3 +14,7 @@ interface Zoo {
10
14
```
11
15
12
16
The `MethodSignature` and the `PropertySignature` forms seem equivalent, but only the `PropertySignature` form can have a `readonly` modifier. Becuase of this any `MethodSignature` will be mutable. Therefore the `no-method-signature` rule disallows usage of this form and instead proposes to use the `PropertySignature` which can have a `readonly` modifier. It should be noted however that the `PropertySignature` form for declaring functions does not support overloading.
#Restrict interfaces so that only members of the same kind of are allowed in them (no-mixed-interface)
2
2
3
-
Mixing functions and data properties in the same interface is a sign of object-orientation style. This rule enforces that an inteface only has one type of members, eg. only data properties or only functions.
3
+
This rule enforces that an inteface only has one type of members, eg. only data properties or only functions.
4
+
5
+
## Rule Details
6
+
7
+
Mixing functions and data properties in the same interface is a sign of object-orientation style.
0 commit comments