Skip to content

Feature: Add linter for duplicate excludes in ns forms #2741

@jramosg

Description

@jramosg

[ Leave this text in if you want to promote it. ]

  • I have read the Clojure etiquette and will respect it when communicating on this platform.

[ To keep development of this project going, consider sponsoring. If you are
already a sponsor, thank you! You can remove this message. ]

Is your feature request related to a problem? Please describe.
clj-kondo currently doesn't warn about duplicate symbols in :exclude clauses within ns forms. This can lead to redundant and potentially confusing namespace declarations, similar to how duplicate refers are already detected.

Describe the solution you'd like
Add a new linter (e.g., :duplicate-exclude) that detects and warns about duplicate symbols in:

  1. (:refer-clojure :exclude [sym1 sym2 sym1]) - duplicate in refer-clojure exclude
  2. (:require [some.ns :exclude [sym1 sym2 sym1]]) - duplicate in require exclude

The warning should be similar to the existing :duplicate-refer linter.

Describe alternatives you've considered

  • Keep relying on manual code review to catch duplicates

Additional context
Currently, clj-kondo successfully detects duplicate refers:

;; This produces: "Duplicate refer: split"
(ns foo (:require [clojure.string :refer [split split]]))

But does not detect duplicate excludes:

;; This produces no duplicate warning, only "Unused excluded var: map"
(ns foo (:refer-clojure :exclude [map map]))

The new linter would provide consistency with the existing duplicate detection capabilities and help catch redundant namespace declarations early.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions