eslint-plugin-resulto

1.0.0 • Public • Published

eslint-plugin-resulto

Build Size Version Maintained Issues

Installation

npm install --save-dev eslint typescript @typescript-eslint/parser eslint-plugin-resulto @typescript-eslint/eslint-plugin

Configuration

  1. Create/modify your tsconfig.json.
{
  "compilerOptions": {
    "strict": true
  }
}
  1. 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.

Hint

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:

  1. Add this rule to your ESLint configuration file, i.e. .eslintrc.json
{
  "rules": {
    "@typescript-eslint/no-unused-vars": [
      "warn",
      {
        "varsIgnorePattern": "^_"
      }
    ]
  }
}
  1. Make sure you do not have noUnusedLocals set to true in tsconfig.json

Available configs

  • resulto/recommended - recommended rules.

Rules

💼 Configurations enabled in.
✅ Set in the recommended configuration.

Name Description 💼
must-use-result Result must be used to make sure errors are handled.

Package Sidebar

Install

npm i eslint-plugin-resulto

Weekly Downloads

18

Version

1.0.0

License

MIT

Unpacked Size

15.8 kB

Total Files

6

Last publish

Collaborators

  • adjsky