Recommended custom eslint rules at Hokla
yarn add --dev @hokla/eslint-plugin-custom-rules
Optional: In case you also need to setup eslint :
yarn add --dev eslint typescript @typescript-eslint/parser @typescript-eslint/eslint-plugin
In your .eslintrc.json
file :
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@hokla/custom-rules/recommended"
],
"plugins": ["@typescript-eslint"],
"parser": "@typescript-eslint/parser",
// In case you want to customize the level of warning (default to 'warn')
"rules": {
"@hokla/custom-rules/react-query-specify-typing": "warn" // "error" | "warn
}
}
Rule | Configuration | Description |
---|---|---|
typeorm-query-runner-release | recommended | Ensure all queryRunner instances finally release their db connection |
react-query-specify-type | recommended | Force to specify data types when using methods useQuery and useMutation |
property-decorator-type-mismatch | recommended | Ensure attribute decorator @Type(...) is consistent with property type |
mutation-decorator-return-type-mismatch | recommended | Ensure GraphQL @Mutation(...) decorator is consistent with method return type |
no-async-in-foreach | recommended | Ensure that we don't use async callbacks in foreach loops |
redux-saga-no-sequential-actions | recommended | Prevent dispatching Redux Saga actions sequentially |
-
Create a new branch and PR: https://github.com/hokla-org/eslint-plugin-custom-rules/compare
-
Write a test with valid and invalid code samples
-
Use online tools to specify AST selectors and implement the rule
-
Ask a review !
-
Let the world know (slack the teams you want to share it with and tell them to upgrade by running
yarn upgrade @hokla/eslint-plugin-custom-rules
ornpm update @hokla/eslint-plugin-custom-rules
)