https://github.com/inlustra/tslint-ngrx
A repository for opinionated ngrx rules.
https://github.com/inlustra/tslint-ngrx
ngrx ngrx-effects ngrx-store tslint tslint-rules typescript
Last synced: 2 months ago
JSON representation
A repository for opinionated ngrx rules.
- Host: GitHub
- URL: https://github.com/inlustra/tslint-ngrx
- Owner: Inlustra
- Created: 2017-04-20T23:52:38.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-01T10:31:41.000Z (almost 7 years ago)
- Last Synced: 2025-02-11T04:12:10.918Z (2 months ago)
- Topics: ngrx, ngrx-effects, ngrx-store, tslint, tslint-rules, typescript
- Language: TypeScript
- Size: 15.6 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NGRX TSLint Rules
This was hastily thrown together but fully tested, welcome any feedback.
#### Deprecated:
These rules no longer reflect how to accurately manage NGRX. Consider using typescript enums to manage Action Names.## `ngrx-action-class-suffix`
### **AutoFixable**
### Description
Will pick up any class that `implements Action` and enforce a suffix to be placed on that class name, **Defaults to 'Action'**
### Example
`"ngrx-action-class-suffix": [true, "CustomSuffix"]`
Error:
export class UserButtonSubmit implements Action { }
Success:
export class UserButtonSubmitCustomSuffix implements Action { }
## `ngrx-action-type-property-name`
### **AutoFixable**
### Description
Will enforce case naming conventions on any object terminating with the desired suffix, **Defaults to ActionTypes and CONSTANT_CASE**
### Example
```
"ngrx-action-type-property-name": [
true,
"ActionTypes",
"constant"
]
```Error:
export const UserActionTypes = {
userButtonSubmit: 'user submit button',
userTextSubmit: type('user submit text')
}Success:
export const UserActionTypes = {
USER_BUTTON_SUBMIT: 'user submit button',
USER_TEXT_SUBMIT: type('user submit text')
}## `ngrx-action-type-property-value`
### **AutoFixable**
### Description
Will require the property name to be displayed within the property value with case changes when the object name terminates with the given suffix, **Defaults to ActionTypes and 'Title Case'**.
### Example
"ngrx-action-type-property-value": [
true,
"ActionTypes",
"title",
true,
"title"
]Error:
export const UserActionTypes = {
USER_BUTTON_SUBMIT: 'user submit button',
USER_TEXT_SUBMIT: type('user submit text')
}Success:
export const UserActionTypes = {
USER_BUTTON_SUBMIT: '[User] User Button Submit',
USER_TEXT_SUBMIT: type('[User] User Text Submit')
}### **New**
Added the rule to require the ActionType prefix inside the property value.## Notes
All of the above case strings can be replaced with those available here: [NPM Case](https://www.npmjs.com/package/case)
Supports:
- camel: 'thisIsNiceAndTidyNathan',
- snake: 'this_is_nice_and_tidy_nathan',
- kebab: 'this-is-nice-and-tidy-nathan',
- upper: 'THIS IS NICE AND TIDY, NATHAN.',
- lower: 'this is nice and tidy, nathan.',
- header: 'This-Is-Nice-And-Tidy-Nathan',
- sentence: 'This is nice and tidy, nathan.',
- capital: 'This Is Nice And Tidy, Nathan.',
- title: 'This Is Nice and Tidy, Nathan.',
- constant: 'THIS_IS_NICE_AND_TIDY_NATHAN'## TODO
- Write a rule that will detect when an action class uses a type outside of the allowed rules, example:```
export class MyAction implements Action {
type = QuoteActionsList.MY_ACTION;
}
```Should Be
```
export class MyAction implements Action {
type = QuoteActionTypes.MY_ACTION;
}
```