no-duplicate-load-rules

January 30, 2025 · View on GitHub

Disallow duplicate @import, @use and @forward rules.

    @import "a.css";
    @import "a.css";
/** ↑
 * These are duplicates */
    @use "a" as a;
    @use "a" as b;
/** ↑
 * These are duplicates */
    @forward "a" with ($blue: #333);
    @forward "a" with ($blue: #333);
/** ↑
 * With @forward, they are only considered duplicates if they have the exact same confuguration. */

The message secondary option can accept the arguments of this rule.

Options

true

The following patterns are considered problems:

@import 'a.css';
@import 'a.css';
@import url("a.css");
@import url("a.css");
@import "a.css";
@import 'a.css';
@import "a.css";
@import 'b.css';
@import url(a.css);
@use "a";
@use "a";
@use "a" as abc;
@use "a" as xyz;
@use 'a' with (
$black: #222,
$border-radius: 0.1rem
);
@use 'a' with ($blue: #333);
@forward 'a' with ($blue: #333);
@forward 'a' with ($blue: #333);
@forward "a" hide $vertical-list-gap;
@forward "a" hide $vertical-list-gap;

The following patterns are not considered problems:

@import "a.css";
@import "b.css";
@import url('a.css') projection;
@import url('a.css') tv;
@use "a";
@use "b";
@use "a" as abc;
@use "b" as xyz;
@use 'a' with (
$black: #222,
$border-radius: 0.1rem
);
@use 'b' with ($blue: #333);
@forward 'a' with (
$black: #222,
$border-radius: 0.1rem
);
@forward 'a' with ($blue: #333);
@forward "a" hide list-reset, $horizontal-list-gap;
@forward "a" hide $vertical-list-gap;