npm install --save-dev eslint typescript @typescript-eslint/parser eslint-plugin-resulto @typescript-eslint/eslint-plugin
- Create/modify your
tsconfig.json
.
{
"compilerOptions": {
"strict": true
}
}
- Create/modify your
ESLint
configuration file, i.e..eslintrc.json
.
{
"root": true,
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": true
},
"plugins": ["@typescript-eslint", "resulto"],
"rules": {
"resulto/must-use-result": "error"
}
}
See typescript-eslint docs for more info.
In Rust it is idiomatic to assign a must-used value to a variable named _
when
you want to purposely discard this value.
To make this work in TypeScript without making ESLint or tsc angry you need to:
- Add this rule to your
ESLint
configuration file, i.e..eslintrc.json
{
"rules": {
"@typescript-eslint/no-unused-vars": [
"warn",
{
"varsIgnorePattern": "^_"
}
]
}
}
- Make sure you do not have
noUnusedLocals
set totrue
intsconfig.json
-
resulto/recommended
- recommended rules.
💼 Configurations enabled in.
✅ Set in the recommended
configuration.
Name | Description | 💼 |
---|---|---|
must-use-result | Result must be used to make sure errors are handled. | ✅ |