Enforcing best practices for teactn
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-teactn
:
$ npm install eslint-plugin-teactn --save-dev
Note: If you installed ESLint globally (using the -g
flag) then you must also install eslint-plugin-teactn
globally.
Add teactn
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"teactn"
],
"extends": [
"plugin:teactn/recommended"
]
}
To configure individual rules:
{
"rules": {
"teactn/withGlobal-prefer-named-arguments": 2
}
}
- teactn/withGlobal-prefer-minimum-two-arguments Enforces that connect function has at least 2 arguments.
- teactn/withGlobal-prefer-named-arguments Enforces that all connect arguments have recommended names.
- teactn/mapStateToProps-no-store Prohibits binding a whole store object to a component.
- teactn/mapStateToProps-prefer-hoisted Flags generation of copies of same-by-value but different-by-reference props.
- teactn/mapStateToProps-prefer-parameters-names Enforces that all mapStateToProps parameters have specific names.
- teactn/mapStateToProps-prefer-selectors Enforces that all mapStateToProps properties use selector functions.
- teactn/useSelector-prefer-selectors Enforces that all useSelector properties use selector functions.
- teactn/no-unused-prop-types Extension of a react's no-unused-prop-types rule filtering out false positive used in teactn context.
- teactn/prefer-separate-component-file Enforces that all connected components are defined in a separate file.