0

I am attempting to make use of typescript-eslint in an existing react project, and eslint is detecting an issue that I don't think is correct, and I'm curious of the proper way to get around it. As an example to demonstrate the issue, here is a simple interface with a functional member:

export interface MyInterface {
  myProperty: number,
  myFunction: (myParam: string) => string
}

eslint underlines myParam: string in yellow and supplies the following warning:

'myParam' is defined but never used. eslint(no-unused-vars)

Here are my eslint configuration settings:

{
  "env": {
    "browser": true,
    "es6": true
  },
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:@typescript-eslint/recommended"
  ],
  "globals": {
    "module": true,
    "__dirname": true,
    "require": false,
    "$": false
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true,
      "modules": true
    },
    "ecmaVersion": 6,
    "sourceType": "module"
  },
  "plugins": [
    "react"
  ],
  "rules": {
    "indent": [
      "off",
      2
    ],
    "linebreak-style": [
      "off",
      "windows"
    ],
    "quotes": [
      "warn",
      "single"
    ],
    "semi": [
      "error",
      "always"
    ],
    "no-console": [
      "off"
    ],
    "no-debugger": [
      "warn"
    ],
    "no-extra-semi": [
      "warn"
    ],
    "no-unused-vars": [
      "warn"
    ]
  },
  "settings": {
    "react": {
      "version": "detect"
    }
  }
}

I understand that I have "no-unused-vars": ["warn"] in my rules, but it seems to me no-unused-vars should not apply to a function definition. Has anyone else come across this issue? Thank you so much in advance for any help!

  • 1
    Does this answer your question? [ESLint - Configuring "no-unused-vars" for TypeScript](https://stackoverflow.com/questions/57802057/eslint-configuring-no-unused-vars-for-typescript) – Eldar Mar 12 '21 at 20:05
  • @Eldar unfortunately that solution does not work for me, I am already using the recommended extends options – Michael Kietzman Mar 12 '21 at 21:12
  • @MichaelKietzman did you try the second solution? https://stackoverflow.com/a/61555310/2837427 – hendrixchord Mar 13 '21 at 17:59

0 Answers0