sweepline/eslint-plugin-unused-imports

Needs Flat version of rules

deprecated-guy opened this issue · 1 comments

I use the antfu eslint config and flat config for eslint, and getting those error
TypeError: Key "plugins": Cannot redefine plugin "unused-imports".

my config

const antfu = require('@antfu/eslint-config').default;
const cfg = antfu(
	{
		stylistic: {
			semi: true,
			indent: 'tab',
			quotes: 'single',
		},
		ignores: ['*.json', 'node_modules', 'tslint.json'],
		typescript: true,
		jsonc: false,
		overrides: {
			typescript: true,
		},
	},
	{
		plugins: {
			'unused-imports': {
				'no-unused-imports': 'error',
				'unused-imports/no-unused-vars': [
					'warn',
					{
						vars: 'all',
						varsIgnorePattern: '^_',
						args: 'after-used',
						argsIgnorePattern: '^_',
					},
				],
			}
		},
		rules: {
			'prefer-arrow-callback': 0,
			'array-bracket-spacing': 1,
			'import/no-restricted-paths': 1,
			'no-restricted-syntax': [
				'error',
				{
					selector: 'ImportDeclaration[specifiers.length = 0]',
					message: 'Empty imports are not allowed',
				},
			],
			'indent': ['error', 'tab', { ignoredNodes: ['PropertyDefinition'] }],
			'semi': 'error',
			'style/semi': 'error',
			'max-len': ['error', 120],
			'style/jsx-quotes': 'error',
			'antfu/consistent-list-newline': 'error',
			'no-trailing-spaces': 'error',
			'no-console': 'warn',
			'no-alert': 'warn',
			'quotes': ['error', 'single'],
			'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off",
			'unused-imports/no-unused-imports': 'error',
			'unused-imports/no-unused-vars': [
				'warn',
				{
					vars: 'all',
					varsIgnorePattern: '^_',
					args: 'after-used',
					argsIgnorePattern: '^_',
				},
			],
		},
		ignores: ['*.json', 'tsconfig.*.json', 'node_modules', 'tslint.json'],
	},
)

module.exports = cfg;

I don't know anything about this '@antfu/eslint-config'. I assume that they also set it up. At the same time you also have the rules for unused-import defined in rules and plugins.