I have the following function:
export const getDocumentFile = async (
docInstance: DocumentInstance,
callback: ({message}: Error) => void, // <---- ERROR HERE
): Promise<string | null> => {
let document = null
await axiosInstance
.get('example.com')
.then(response => {
document = response.data;
})
.catch(error => {
callback(error);
});
return document;
};
It accepts a callback which has the exact signature specified above, so I've typed it this way here, however I'm getting an error:
'message' is defined but never used. eslint(no-unused-vars)
This is the exact signature that the callback that I pass to this function has, so I'm unsure why it's throwing an error at all.
Changing the function signature so something else like callback: (error: Error) => void
resultsin the exact same error.
I just just recently updated my react-scripts to 4.0.0 and I believe this has something to do with the error.
eslintrc.js
module.exports = {
parser: '@typescript-eslint/parser',
env: {
es6: true,
node: true,
browser: true,
},
parserOptions: {
ecmaVersion: 6,
tsconfigRootDir: __dirname,
project: './tsconfig.json',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react', 'react-hooks', '@typescript-eslint'],
rules: {
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
},
extends: [
'eslint:recommended',
'plugin:react/recommended',
// 'plugin:prettier/recommended',
],
}
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"lib": ["es6", "dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noFallthroughCasesInSwitch": true,
"noEmit": true,
"jsx": "react"
},
"include": [
"build-system",
"src",
".eslintrc.js",
"pretty.js",
"gulpfile.js"
],
"exclude": ["node_modules"]
}