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've 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"]
You can configure the no-unused-vars
rule to ignore arguments named param
by adding this line to your .eslintrc.json
rules: "no-unused-vars": ["error", { "argsIgnorePattern": "params"}]
. See the docs: https://eslint.org/docs/latest/rules/no-unused-vars#argsignorepattern
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With