Skip to content
This repository has been archived by the owner on May 23, 2021. It is now read-only.

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Cooper authored and timdeschryver committed May 29, 2020
1 parent d3de8cc commit 0a7d5ea
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Next, add `ngrx-tslint-rules` to your `tslint.json` file, and the rules to the `
}
```

To enable all rules, use the `recommended` configuration file.
To enable all recommended rules, use the `recommended` configuration file.

```json
{
Expand All @@ -42,7 +42,7 @@ To enable all rules, use the `recommended` configuration file.

> The recommended rules also export the rules from [rxjs-tslint-rules](https://github.com/cartant/rxjs-tslint-rules) that can be applied to NgRx
## Rules
## Recommend Rules

> By default all rules are enabled
Expand All @@ -61,6 +61,23 @@ To enable all rules, use the `recommended` configuration file.
| ngrx-no-typed-store | A store should not be typed | [Example](https://github.com/timdeschryver/ngrx-tslint-rules/tree/master/test/rules/ngrx-no-typed-store/fixture.ts.lint) |
| ngrx-selector-for-select | Using string or props drilling is not preferred, use a selector instead | [Example](https://github.com/timdeschryver/ngrx-tslint-rules/tree/master/test/rules/ngrx-selector-for-select/fixture.ts.lint) |

## Optional Rules

To enable optional rules add them to the `rules` section in your `tslint.json` file.

```json
{
"extends": ["ngrx-tslint-rules"],
"rules": {
"ngrx-on-reducer-explicit-return-type": true
}
}
```

| Rule | Description | Examples |
| ------------------------------------ | ----------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| ngrx-on-reducer-explicit-return-type | Enforces type safety for `on` reducer callbacks | [Example](https://github.com/timdeschryver/ngrx-tslint-rules/tree/master/test/rules/ngrx-on-reducer-explicit-return-type/fixture.ts.lint) |

## License

MIT
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function increaseFunc(state: State, value: number): State {
const reducer = createReducer(
initialState,

// No explicit return type when no action props
// No explicit return type defined means values can be assigned to non-existent properties.
on(increment, s => ({
~~~~~~~
...s,
Expand All @@ -34,12 +34,12 @@ const reducer = createReducer(
counter: s.counter + 1,
}),
),
// Do not require functions to have an explicit return type defined in on method
// Do not require functions to have an explicit return type as likely that the function is typed
on(increment, incrementFunc),
on(increment, s => incrementFunc(s)),
on(increment, (s): State => incrementFunc(s)),

// No explicit return type when action has props
// No explicit return type
on(increase, (s, action) => ({
~~~~~~~~~~~~~~~~~
...s,
Expand All @@ -55,7 +55,7 @@ on(
counter: s.counter + action.value,
}),
),
// No explicit return type when action has props and deconstructed
// No explicit return type
on(increase, (s, { value }) => ({
~~~~~~~~~~~~~~~~~~~~
...s,
Expand Down

0 comments on commit 0a7d5ea

Please sign in to comment.