Why eslint consider JSX or some react @types undefined, since upgrade typescript-eslint/parser to version 4.0.0
Official answer is here
https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/FAQ.md#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors and it says indeed to add them to globals
or to disable the no-undef
rule because typescript has already its own checks
I had the same issue when trying to declare variables as of type JSX.Element
in typescript. I added "JSX":"readonly"
to globals
in .eslintrc.json
and the problem was gone. In your case it would be:
globals: {
React: true,
google: true,
mount: true,
mountWithRouter: true,
shallow: true,
shallowWithRouter: true,
context: true,
expect: true,
jsdom: true,
JSX: true,
},
From the following link, I got that you actually use several options after JSX
. You could use true
,false
, writable
or readonly
(but not off
).
https://eslint.org/docs/user-guide/configuring