Skip to content

Commit

Permalink
Updated CHANGELOG and CONTRIBUTING.
Browse files Browse the repository at this point in the history
  • Loading branch information
scottrhoyt committed Jan 11, 2016
1 parent 6473715 commit 97c6b5c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 3 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,24 @@

##### Breaking

* None.
* `ParameterizedRule` is deprecated. Use `ConfigurableRule` instead.
[Scott Hoyt](https://github.com/scottrhoyt)

* To activate a `Rule`, it must be added to the global `masterRuleList`.
[Scott Hoyt](https://github.com/scottrhoyt)

##### Enhancements

* `ConfigurableRule` protocol allows for improved rule configuration. See
`CONTRIBUTING` for more details.
[Scott Hoyt](https://github.com/scottrhoyt)
[#303](https://github.com/realm/SwiftLint/issues/303)

* `VariableNameMinLengthRule` now supports excluding certain variable names
(e.g. "id")
[Scott Hoyt](https://github.com/scottrhoyt)
[#231](https://github.com/realm/SwiftLint/issues/231)

* Add AutoCorrect for StatementPositionRule.
[Raphael Randschau](https://github.com/nicolai86)

Expand Down
36 changes: 34 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

New rules should be added in the `Source/SwiftLintFramework/Rules` directory.

Rules should conform to either the `Rule`, `ASTRule` or `ParameterizedRule`
protocols.
Rules should conform to either the `Rule`, `ASTRule` or `ConfigurableRule`
protocols. To activate a rule, add the rule to `masterRuleList` in
`RuleList.swift`.

All new rules or changes to existing rules should be accompanied by unit tests.

Expand All @@ -13,6 +14,37 @@ those test cases in the unit tests directly. This makes it easier to understand
what rules do by reading their source, and simplifies adding more test cases
over time.

### `ConfigurableRule`

If your rule supports user-configurable options via `.swiftlint.yml`, you can
accomplish this by conforming to `ConfigurableRule`:

* `init?(config: AnyObject)` will be passed the result of parsing the value
from `.swiftlint.yml` associated with your rule's `identifier` as a key (if
present).
* `config` may be of any type supported by YAML (e.g. `Int`, `String`, `Array`,
`Dictionary`, etc.).
* This initializer must fail if it does not understand the configuration, or
it cannot be fully initialized with the configuration.
* If this initializer fails, your rule will be initialized with its default
values by calling `init()`.

See [VariableNameMinLengthRule](https://github.com/realm/SwiftLint/blob/647371517e57de3499a77781e45f181605b21045/Source/SwiftLintFramework/Rules/VariableNameMinLengthRule.swift)
for an example that supports the following configurations:

``` yaml
variable_name_min_length: 3

variable_name_min_length:
- 3
- 2

variable_name_min_length:
warning: 3
error: 2
excluded: id
```
## Tracking changes
All changes should be made via pull requests on GitHub.
Expand Down

0 comments on commit 97c6b5c

Please sign in to comment.