I am currently getting a eslint warning on function parameters within Types
or Interfaces
.
Doing the following:
type Test = {
fn: (param: string) => void
}
Results in the following warning:
'param' is defined but never used. Allowed unused args must match /^_/u.
Here's what my .eslintrc.json
looks like:
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"env": {
"node": true
},
"plugins": ["@typescript-eslint"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
],
"rules": {
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off"
}
}
Package versions:
"eslint": "^7.23.0"
"@typescript-eslint/eslint-plugin": "^4.22.1"
"@typescript-eslint/parser": "^4.22.1"
Similar questions have been asked already here and here , but the provided answers do not seem to be doing it for me.
Any suggestions as to what could be happening?
I solved it this way, put these two lines in rules in the eslint configuration file.
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error"]
Instead of setting the no-unused-vars
globally in your eslint config, you could set it to the line by placing this comment just above it:
// eslint-disable-next-line @typescript-eslint/no-unused-vars
or to the entire file, just add this comment on the top:
/* eslint-disable @typescript-eslint/no-unused-vars */
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.