New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule Request: Duplicate Imports #1881

Closed
jpsim opened this Issue Oct 4, 2017 · 2 comments

Comments

Projects
None yet
2 participants
@jpsim
Copy link
Collaborator

jpsim commented Oct 4, 2017

New Issue Checklist

Rule Request

  1. Why should this rule be added? Share links to existing discussion about what
    the community thinks about this.

Duplicate imports are unnecessary.

  1. Provide several examples of what would and wouldn't trigger violations.
// Should Trigger
import Foundation
import Dispatch
import Foundation

// Should Trigger
import Foundation
import Foundation.NSString

// Should Not Trigger
Import Foundation.NSString
Import Foundation.NSRange
  1. Should the rule be configurable, if so what parameters should be configurable?

Shouldn't be configurable. Either there are duplicates or not.

  1. Should the rule be opt-in or enabled by default? Why?
    See README.md for guidelines on when to mark a
    rule as opt-in.

Enabled by default.

@marcelofabri removing this duplicate import motivated me to write this rule request: https://github.com/realm/SwiftLint/pull/1872/files#diff-71e28580a5fd3b8b3f701a7c8ca9f6a9

There are gotchas around conditional imports, so I suggest we just not count imports in a conditional compilation expression.

@jpsim jpsim added the rule-request label Oct 4, 2017

@marcelofabri

This comment has been minimized.

Copy link
Collaborator

marcelofabri commented Oct 4, 2017

Nice, I thought about filling an issue requesting this rule but I completely forgot later.

@marcelofabri

This comment has been minimized.

Copy link
Collaborator

marcelofabri commented Jan 18, 2019

Implemented in #2004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment