aladdin-add / eslint-plugin

autofix some errors reported by eslint rules.
107 stars 10 forks source link

eslint-plugin-autofix: `no-unused-vars` complains about TypeScript function type parameters #75

Closed osdiab closed 3 years ago

osdiab commented 3 years ago

Tell us about your environment

Config ``` /* eslint-disable unicorn/prefer-module */ module.exports = { env: { browser: true, es2021: true, node: true, }, extends: [ "eslint:recommended", "plugin:react/recommended", "plugin:react-hooks/recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "plugin:import/errors", "plugin:import/warnings", "plugin:import/typescript", "plugin:unicorn/recommended", // Excludes ESLint's rules that conflict with prettier "prettier", ], parser: "@typescript-eslint/parser", parserOptions: { ecmaFeatures: { jsx: true, }, ecmaVersion: 12, sourceType: "module", }, plugins: ["react", "@typescript-eslint", "unicorn", "autofix"], rules: { "react/react-in-jsx-scope": "off", // not necessary anymore "react/prop-types": "off", // typescript handles types already "react/display-name": "off", // this is messing with a pattern for react-table which I like. Can turn on if bad. "import/order": ["warn", { "newlines-between": "always" }], "@typescript-eslint/consistent-type-definitions": ["warn", "interface"], // interfaces more performant "unicorn/no-null": "off", // useful when dealing with db types, distinguishing missing from uninitialized "unicorn/prevent-abbreviations": "off", "unicorn/prefer-node-protocol": "off", // breaks eslint-plugin-import and other tools "autofix/no-unused-vars": "warn", }, settings: { react: { version: "detect" }, "import/resolver": "eslint-import-resolver-typescript", }, }; ```
interface ResultItemProps<ItemType>
  extends ClassAttributes<HTMLLIElement>,
    LiHTMLAttributes<HTMLLIElement> {
  highlighted: boolean;
  item: ItemType;
  itemToString: ((item: ItemType | null) => string) | undefined;
}

Expected behavior

No error, it's just a type

Actual behavior error in itemToString params: item is not used.

aladdin-add commented 3 years ago

You need to enable @typescript-eslint/no-unused-vars if you are writing ts. the plugin is to implement additional fixing to eslint core rules, but not rules from 3rd-party plugins.

osdiab commented 3 years ago

ah worked now! was not clear from the docs that that was the case, might be worthwhile to specify that.