Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
ESLint activate option to notify "Object is possibly null"

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
  }
}
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

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.

about 4 years ago · Juan Pablo Isaza Denunciar

0

ESLint cannot lint or warn about types only typescript can do it.

You want to have 2 tsconfig.json fles, tsconfig.test.json and tsconfig.json

The tsconfig.json should be like:

{
    ...
    "compilerOptions": {
        "strictNullChecks": true,
    }
}

and the tsconfig.test.json should be like:

{
    "extends": "./tsconfig.json",
    ...
    "compilerOptions": {
        "strictNullChecks": false,
    }
}

This way the script null check will not be checked during test run.

about 4 years ago · Juan Pablo Isaza Denunciar

0

The problem was on the line:

"exclude": ["lib/**/*.spec.tsx", ...

Because of that, the tests are being ignored.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda