JSPM

eslint-plugin-no-type-assertion

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 66625
  • Score
    100M100P100Q175727F
  • License MIT

Disallow type assertions in TypeScript code

Package Exports

  • eslint-plugin-no-type-assertion

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (eslint-plugin-no-type-assertion) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

eslint-plugin-no-type-assertion

Disallow type assertions in TypeScript code. The rule will forbid as operator when used for changing the expression type, unless it's used for const assertions.

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"
  }
}

Changelog

1.0.1

  • Fix rule name

1.0.0

  • Initial version