Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-plugin-ts-expect-error-validator

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-ts-expect-error-validator

A rule that enforces proper usage and validation of TypeScript's @ts-expect-error comments for easier error management

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
92
increased by10.84%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-ts-expect-error-validator

A rule that enforces proper usage and validation of TypeScript's "@ts-expect-error" comments for easier error management

Installation

yarn add -D eslint-plugin-ts-expect-error-validator

Usage

Add it to your ESLint configuration:

{
  "plugins": [
    "ts-expect-error-validator"
  ],
  "rules": {
    "ts-expect-error-validator/no-empty-expect-error": "error"
  }
}

Configure the rule to use strict or default validation mode:

{
  "plugins": [
    "ts-expect-error-validator"
  ],
  "rules": {
    "ts-expect-error-validator/no-empty-expect-error": [
      "error",
      {
        "validationMode": "strict"
      }
    ]
  }
}

Options:
OptionDescription
validationModeSpecifies the validation mode to use. Can be either default or strict. In default mode, only the expected error codes are validated. In strict mode, the error code and error message are validated. Default is default.

Rule Details

This rule enforces the following rules for @ts-expect-error comments:

  • Each @ts-expect-error comment should contain at least one TypeScript error code, enclosed in square brackets ( e.g. [TS123]).
  • If using the strict validation mode, each error code should be followed by an error description, separated by a hyphen (e.g. [TS2532 - Object is possibly 'undefined']).
  • The TypeScript error code should start with TS.

Example Usage:

// @ts-expect-error [TS6133] - ignore the 'myNumber' is declared but its value is never read message
let myNumber: string | undefined;

// You can also ignore more then one error for a line: 
// @ts-expect-error [TS2322, TS6133]
const object: { a: number } = { b: 5 };

Hits

  • There is a package for validation specified signatures.

License

This library is released under the MIT License.

Keywords

FAQs

Package last updated on 29 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc