I want to allow data!.id
Error:
warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion
Current config:
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'
}
}
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'
},
...
}
If you're attempting to disable a rule on the entire file, adding this comment in the file top to ignore will work:
/* eslint-disable @typescript-eslint/no-non-null-assertion */
If you're attempting to disable a rule on the next line only (rather than for an entire file), adding this comment directly above the line to ignore will work:
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.