For some reason, my .eslintrc.json has some option, or has a lack of some option to catch the warning
Object is possibly 'null'
What I need to change to eslint notify my about this warning?
IMPORTANT this is on my unit tests, so adding strictNullChecks does not work for my project, that why I asked if eslint has an option for that.
{
"settings": {
"react": {
"version": "latest"
}
},
"env": {
"browser": true,
"es2021": true
},
"extends": ["eslint:recommended", "plugin:react/recommended", "plugin:@typescript-eslint/recommended", "prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint"],
"rules": {
"@typescript-eslint/no-inferrable-types": "off"
},
"ignorePatterns": ["dist/*"]
}
My tsconfig.json
{
"exclude": ["lib/**/*.spec.tsx", "lib/**/*.stories.tsx", "lib/**/*.styles.tsx", "settings/**/*", "dist/**/*"],
"compilerOptions": {
"skipLibCheck": true,
"target": "es5",
"lib": ["es5", "dom"],
"jsx": "react",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "dist",
"rootDirs": ["lib"],
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strictNullChecks": true
}
}
In your tsconfig.json file under "compilerOptions", you want to set "strictNullChecks" to "true":
{
"compilerOptions": {
"strictNullChecks": true,
}
}
That will make typescript warn you when a value is possibly null. I don't think you can make eslint do it for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With