Skip to content
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

Unused import rule transitive dependencies #5622

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PaulTaykalo
Copy link
Collaborator

@PaulTaykalo PaulTaykalo commented Jun 12, 2024

This PR tries to resolve an issue, when unused import resolved incorrectly, since swiflint doesn't check transitive imports

For example, if we have

import Cocoa

let viewController = NSViewController()

Cocoa module is actually

import AppKit
import Foundation
import CoreData

So this PR actually tries to account transitive_modules configuration to prevent incorrect import removals

Alternative

As an alternative we can try to generate interfaces of all imported modules (once per module)
And parse their imports on the top level

So , for example, if we found some missing modules, we'll check if those can be found in the generated interface.

For example,

import SwiftUI

Will allow to use any of the underlying modules

/// Generated SwifTUI interface
import Accessibility
import AppKit
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreTransferable
import Darwin
import DeveloperToolsSupport
import Foundation
import OSLog
import Observation
import Spatial
import SwiftUICore
import Symbols
import TargetConditionals
import UniformTypeIdentifiers
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
import os
import os.log
import simd

Related Issues:
#5167

@PaulTaykalo PaulTaykalo force-pushed the experiment/update-unused-import-rule branch from 6f8a308 to 7e92f70 Compare June 12, 2024 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant