Skip to content

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

Open
@khanakia

Description

Tell us about your environment

  • eslint version: 8.57.0
  • eslint-plugin-autofix version: ^2.0.0
  • eslint config:
/**
 * This is intended to be a basic starting point for linting in your app.
 * It relies on recommended configs out of the box for simplicity, but you can
 * and should modify this configuration to best suit your team's needs.
 */

/** @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 <img> 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 (
    <>
      <DynamicSection id={team?.section_footer_id} />
      <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

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions