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

eslint-plugin-ban-type-assertion

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-ban-type-assertion

Disallow type assertions in TypeScript code

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
110
decreased by-24.14%
Maintainers
1
Weekly downloads
 
Created
Source

Ban specified Typescript type assertions (as MyType and <MyType>) (ban-type-assertion)

Allow type assertions to certain types to be banned. Built-in types may not be banned.

Rule Details

This rule allows you to specify a list of types that you don't want to be used as type assertions.

These examples assume that the following configuration is specified:

{
    "rules": {
        "ban-type-assertion": ["error", {"typeName": "BannedType", "message": "Do not coerce to BannedType. Instead use the constructor createBannedType"}, {"typeName": "AnotherBannedType"}']
    }
}

Examples of incorrect code for this rule:

const x = foo as BannedType;
const x = <BannedType>foo;

Examples of correct code for this rule:

const x = foo as AllowedType;
const x = <AllowedType>foo;
// Built-in types may not be banned
const x = foo as string;

Options

This rule takes an array of objects with the following properties:

  • typeName: The name of the type to ban.
  • message: The message to display when the type is banned. This property is optional.

Keywords

FAQs

Package last updated on 07 Mar 2023

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