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

eslint-plugin-no-type-assertion

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-no-type-assertion

Disallow type assertions in TypeScript code

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32K
increased by30.98%
Maintainers
1
Weekly downloads
 
Created
Source

eslint-plugin-no-type-assertion

Disallow type assertions in TypeScript code. The rule will forbid both as operator and the angle-bracketed syntax, unless used for const assertions.

The following code becomes invalid:

const foo: unknown = 42;

const bar = <number>foo;
const baz = foo as number;

Installation

Ensure you have ESLint and @typescript-eslint/parser installed:

$ yarn add eslint @typescript-eslint/parser -D

Next, install this plugin:

$ yarn add eslint-plugin-no-type-assertion -D

Configuration

In your ESLint configuratio, ensure you're using @typescript-eslint/parser as a parser and it's set up correctly:

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2018
  }
}

Add eslint-plugin-no-type-assertion to the plugin list:

{
  "plugins": ["no-type-assertion"]
}

Enable the rule:

{
  "rules": {
    "no-type-assertion/no-type-assertion": "error"
  }
}

Keywords

FAQs

Package last updated on 28 Nov 2021

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