close

no-duplicates

Configuration

rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/no-duplicates': 'error',
    },
  },
]);

Rule Details

Reports if a resolved path is imported more than once.

This rule is similar to ESLint core's no-duplicate-imports, but differs in two key ways:

  1. The paths in the source code don't have to exactly match — they just have to point to the same module on the filesystem (e.g., ./foo and ./foo.js).
  2. This version distinguishes type imports from standard imports.

Examples of incorrect code for this rule:

import { x } from './foo';
import { y } from './foo';
import SomeDefaultClass from './mod';
import * as names from './mod';
import { something } from './mod.js';

Examples of correct code for this rule:

import SomeDefaultClass, * as names from './mod';
import type SomeType from './mod';
import { x } from './foo';
import { y } from './bar';

Options

considerQueryString

When set to true, imports with different query strings are treated as different modules.

"import/no-duplicates": ["error", { "considerQueryString": true }]

prefer-inline

When set to true, supports TypeScript inline type imports, allowing import type { X } to be merged into import { type X }.

"import/no-duplicates": ["error", { "prefer-inline": true }]

Original Documentation