RTW*_*RTW 11 typescript eslint
我想允许 data!.id
错误:
警告禁止非空断言@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'
}
}
Run Code Online (Sandbox Code Playgroud)
Afa*_*han 28
如果您尝试禁用整个文件的规则,可以在文件顶部添加此注释以忽略:
/* eslint-disable @typescript-eslint/no-non-null-assertion */
Run Code Online (Sandbox Code Playgroud)
如果您尝试仅在下一行(而不是整个文件)禁用规则,则将此注释直接添加到要忽略的行上方即可:
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
Run Code Online (Sandbox Code Playgroud)
tat*_*oto 24
请添加'@typescript-eslint/no-non-null-assertion': 'off'到您的配置文件中,如下所示。
module.exports = {
...
rules: {
...
'@typescript-eslint/no-non-null-assertion': 'off'
},
...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11005 次 |
| 最近记录: |