I am working with create-react-app + typescript + eslint application and during build have such error:
Line 1:8: \'React\' was used before it was defined @t
If you are only getting this error for .js
files, make sure @typescript-eslint/parser
is being used exclusively on Typescript files.
.eslintrc.json (abbreviated)
{
"overrides": [
{
"files": ["**/*.ts", "**/*.tsx"],
"plugins": ["@typescript-eslint"],
"rules": {
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": ["error"],
},
}
],
// WRONG: Do not use @typescript-eslint/parser on JS files
// "parser": "@typescript-eslint/parser",
"plugins": [
"react",
// "@typescript-eslint"
],
}