# swift/swiftlint

> Lints Swift files with the SwiftLint files of each scope and nested folder, and treats warnings as errors.

Lints Swift files with the SwiftLint files of each scope and nested folder, and treats warnings as errors.

Part of the [`swift`](/reference/configurations/swift/) configuration, at the `recommended` [level](/start/concepts/#levels). It runs at the `commit` [stage](/start/concepts/#stage), per file. It runs swiftlint. `gspot check --fix` fixes what it can.

## Why

Forced casts and tries can crash, and a strong delegate can keep its owner alive.

## What to do

Run `gspot check --fix` for the rules that fix themselves. Turn one rule off with `gspot ignore swift/swiftlint --rule <id> --reason "<why>"`.

## Example

`value as! NSString` reports `force_cast`. Use `as?` and handle the failure, or change the input type so no cast remains.

## Turn it off

Turn it off for some files, or one of its lint rules, with a reason:

```shell
gspot ignore swift/swiftlint --paths "<glob>" --reason "<why>"
gspot ignore swift/swiftlint --rule <rule> --reason "<why>"
```

To silence one place, write a comment such as:

```text
// swiftlint:disable:next force_unwrapping - the URL is a literal
```
