aladdin-add / eslint-plugin

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

eslint-plugin-autofix bug unused vars and args not removed #94

Open khanakia opened 4 months ago

khanakia commented 4 months ago

Tell us about your environment

/* @type {import('eslint').Linter.Config} / module.exports = { ignorePatterns: ['public/', '*/generated/.ts'], extends: ['next/core-web-vitals'], plugins: [ 'unused-imports', 'simple-import-sort', '@typescript-eslint', 'prettier', 'autofix', ], rules: { 'prettier/prettier': ['error', { singleQuote: true, endOfLine: 'auto' }], // disable warning '@next/next/no-img-element': 'off',

// disable warning  React Hook useMemo has missing dependencies: 'getPageInfo', 'handleTableChange', 'onLoadMore', 'query', and 'setQuery'. Either include them or remove the dependency array  react-hooks/exhaustive-deps
'react-hooks/exhaustive-deps': 'off',

// unused imports - https://typescript-eslint.io/rules/no-unused-vars/
// Note: you must disable the base rule as it can report incorrect errors
'no-unused-vars': 'off',
'unused-imports/no-unused-imports': 'error', // remove unused imports automatically using --fix
'@typescript-eslint/no-unused-vars': [
  // 'unused-imports/no-unused-vars': [
  'warn',
  {
    vars: 'all',
    varsIgnorePattern: '^_',
    args: 'after-used',
    argsIgnorePattern: '^_',
  },
],

// --fix auto sort all the imports
'simple-import-sort/imports': 'error',

'@typescript-eslint/quotes': [
  'error',
  'single',
  {
    allowTemplateLiterals: true,
  },
],

'no-restricted-imports': [
  'error',
  {
    patterns: [
      {
        group: ['@/features/ui/components/*', '!@/features/ui/components'],
      },
    ],
  },
],
'autofix/no-debugger': 'error',

}, }

* **source code:**

import { getCurrentTeam } from '@/features/bite/serverfn' import DynamicSection from '@/features/jeoga/components/other/DynamicSection' import Footer from '@/features/jeoga/components/other/Footer'

export default async function FooterServer(props: any) { const team = await getCurrentTeam() return ( <>

  <Footer />
</>

) }

**Expected behavior**
It should remove the `(props:any)` as it's unused

**Actual behavior**

./src/features/jeoga/components/other/FooterServer.tsx 5:44 Warning: 'props' is defined but never used. Allowed unused args must match /^_/u. @typescript-eslint/no-unused-vars