项目作者: nwtgck

项目描述 :
Exaggerated Non-Null Assertion
高级语言: JavaScript
项目地址: git://github.com/nwtgck/eslint-plugin-exaggerated-non-null-assertion.git
创建时间: 2020-06-07T06:00:00Z
项目社区:https://github.com/nwtgck/eslint-plugin-exaggerated-non-null-assertion

开源协议:MIT License

下载


eslint-plugin-exaggerated-non-null-assertion

Rule Details

Example of incorrect code for this rule:

  1. const foo: number | undefined = undefined;
  2. const bar = foo!;

Example of correct code for this rule:

  1. const foo: number | undefined = undefined;
  2. const bar = foo!!!;

Installation

  1. npm i -D nwtgck/eslint-plugin-exaggerated-non-null-assertion

Add the following settings to .eslintrc.js or the other ESLint setting file.

  1. ...
  2. "plugins": [
  3. ...
  4. "exaggerated-non-null-assertion"
  5. ],
  1. ...
  2. "rules": {
  3. ...
  4. // NOTE: Disable no-extra-non-null-assertion and no-non-null-assertion
  5. "@typescript-eslint/no-extra-non-null-assertion": "off",
  6. "@typescript-eslint/no-non-null-assertion": "off",
  7. // Enable Exaggerated Non-Null Assertion
  8. "exaggerated-non-null-assertion/exaggerated-non-null-assertion": "error",
  9. }

Example

Here is an example using this lint.
https://github.com/nwtgck/eslint-plugin-exaggerated-non-null-assertion-example