Commit Graph

13 Commits

Author SHA1 Message Date
JP Simard d10ccacb45 Add unused_import config options to require imports for each module used (#3123)
For example, if `CGFloat` is used in a file where only `UIKit` is imported but not `CoreGraphics`, this will be a violation even if the file previously compiled.

This is because Swift allows referencing some declarations that are only transitively imported.

Enabling the `require_explicit_imports` configuration option will require that the module of every declaration referenced in a source file be explicitly imported.

This will add significant noise to the imports list, but has a few advantages:

1. It will be easier to understand all the dependencies explicitly referenced in a source file.
2. Correcting the `unused_import` rule will no longer introduce compilation errors in files that compiled prior to the correction.

If missing imports are added to a file when correcting it, the `sorted_imports` rule will be automatically run on that file.

If you with to allow some imports to be implicitly importable transitively, you may specify the `allowed_transitive_imports` configuration:

```yaml
unused_import:
  require_explicit_imports: true
  allowed_transitive_imports:
    - module: Foundation
      allowed_transitive_imports:
        - CoreFoundation
        - Darwin
        - ObjectiveC
```
2020-02-22 14:39:07 -08:00
JP Simard b83e0991b9 Remove all file headers
The MIT license doesn't require that all files be prepended with this
licensing or copyright information. Realm confirmed that they're ok with this
change. This will enable some companies to contribute to SwiftLint and the
date & authorship information will remain accessible via git source control.
2018-05-04 13:42:02 -07:00
Marcelo Fabri 0be8c855d2 Move functions to properties and Sets instead of Arrays 2017-10-04 14:34:00 -07:00
Marcelo Fabri 13b0cfe623 Fixing inconsistencies 2016-12-08 18:29:57 -02:00
Norio Nomura 3ff76e7ce8 Update SourceKitten 2016-11-04 20:24:21 +09:00
Norio Nomura 8bf15f1dba Migrate to Swift 3.0 2016-10-09 01:09:50 +09:00
JP Simard c66c5c8df0 formatting fixes
found running `swiftlint autocorrect --format`
2016-05-29 14:58:28 -07:00
Norio Nomura 669fbf09d0 Refine ForceUnwrappingRule
Fix #535
The duration of `ForceUnwrappingRule` on linting Carthage 0.14 is reduced from 1415ms to 339ms by Instruments.
2016-02-14 23:07:18 +09:00
Scott Hoyt 2f60e0b8f1 Removed unneeded rule disable. 2016-01-25 10:02:55 -08:00
Scott Hoyt 2974a81c54 Switched out SyntaxKind(shortName:) implementation for something simpler. 2016-01-25 07:26:31 -08:00
Scott Hoyt 615873adc2 Added to SyntaxKind+SwiftLint. RegexConfig now defaults to allKinds(). 2016-01-25 07:26:31 -08:00
Marcelo Fabri 04b2510926 FunctionBodyLengthRule should not count comment lines 2016-01-14 20:24:47 -08:00
JP Simard 4a5ac44897 add SyntaxKind.commentAndStringKinds() 2015-11-17 10:11:04 -08:00