I have a project based on create react-app, and it seems since an update of the yup dependency, it stopped launching error on invalid import.
The error "module filename has no exported member X", which used to be launched by react-scripts build, as well as by npm start has completely disappeared, though my IDE still finds such error.
react-scripts build
and npm start
will still launch an error if I try to use the unexisting import as a variable, but not if I try to use it as a type.
I tried looking at i.e this question or this one, or others similar questions, but none was like my case (i.e, the files giving problems DO have import, and the commit introducing the bug was litterally changing just the yup dependency in package.json
, and changing package-lock.json
accordingly. I also tried updating my @typescript-eslint/no-unused-vars rules to error, but it gave me too many errors, and I have no guarantee it'll catch any unexisting type exported and used as type)
In case it helps, here is my tsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react",
"noFallthroughCasesInSwitch": true
},
"include": [
"src"
]
}
and my .eslintrc.json
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"tsconfigRootDir": ".",
"project": [
"./tsconfig.json"
]
},
"extends": [
"react-app",
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"plugins": [
"filenames"
],
"rules": {
//- https://palantir.github.io/tslint/rules/no-null-undefined-union/ should be added once a typescript-eslint equivalent exists
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-explicit-any": 0,
// as per https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/no-unused-vars.md, we must disable the base rule to prefer the typescript one
"no-unused-vars": 0,
"filenames/match-exported": 1,
"@typescript-eslint/prefer-as-const": 1,
"@typescript-eslint/ban-types": 1,
"@typescript-eslint/no-unnecessary-type-assertion": 1,
"@typescript-eslint/strict-boolean-expressions": [
1,
{
"allowNullableString": true,
"allowNullableObject": true,
"allowNullableBoolean": true,
"allowNumber": false,
"allowAny": true
// we use lodash, better allow these any
}
],
"@typescript-eslint/no-unused-vars": 1,
"no-return-await": 2,
"curly": 2,
"@typescript-eslint/no-inferrable-types": [
2,
{
"ignoreParameters": true
}
]
}
}
Thank you for any help.