如何禁用@ typescript-eslint / no-non-null-assertion规则 [英] How to disable @typescript-eslint/no-non-null-assertion rule
本文介绍了如何禁用@ typescript-eslint / no-non-null-assertion规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要允许 data!.id
错误:
警告禁止的非空断言
@ typescript-eslint / no-non-null-assertion
warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
当前配置:
module.exports = {
parser: '@typescript-eslint/parser',
extends: [
'eslint:recommended',
'plugin:jsx-a11y/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended'
],
plugins: ['react-hooks'],
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: {
jsx: true
}
},
rules: {
'@typescript-eslint/ban-ts-ignore': 0,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/consistent-type-assertions': ['warn', { assertionStyle: 'as' }],
eqeqeq: 1,
'react/prop-types': 0,
'@typescript-eslint/camelcase': 0,
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn'
},
globals: {
React: 'writable'
}
}
推荐答案
请在您的配置文件中添加'@ typescript-eslint / no-non-null-assertion':'off'
Please add '@typescript-eslint/no-non-null-assertion': 'off'
to your config file like below.
module.exports = {
...
rules: {
...
'@typescript-eslint/no-non-null-assertion': 'off'
},
...
}
这篇关于如何禁用@ typescript-eslint / no-non-null-assertion规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文