diff --git a/CHANGELOG.md b/CHANGELOG.md index abdcb81cd3..34c91b0443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,37 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.34.0] - 2019-07-15 + +### Added +- Support for Kotlin 1.3.41 +- Support for globally disabling rules via custom `disabled_rules` property in `.editorconfig` ([#503](https://github.com/pinterest/ktlint/pull/503)) +- `experimental:no-empty-first-line-in-method-block` ([#474](https://github.com/pinterest/ktlint/pull/474)) +- Unit tests for ruleset providers + +### Upgraded +- AssertJ from 3.9.0 to 3.12.2 ([#520](https://github.com/pinterest/ktlint/pull/520)) + +### Enabled +- Final newline by default ([#446](https://github.com/pinterest/ktlint/pull/446)) +- `no-wildcard-import` (Re-enabled after temporarily disabling in 0.33.0) +- `experimental:annotation` ([#509](https://github.com/pinterest/ktlint/pull/509)) +- `experimental:multiline-if-else` (no autocorrection) +- `experimental:package-name` (currently only disallows underscores in package names) + +### Deprecated +- `MavenDependencyResolver`. Scheduled to be removed in 0.35.0 ([#468](https://github.com/pinterest/ktlint/pull/468) +- `--install-git-pre-commit-hook` flag; use `installGitPreCommitHook` subcommand instead ([#487](https://github.com/pinterest/ktlint/pull/487)) +- `--print-ast` flag; use `printAST` subcommand instead ([#500](https://github.com/pinterest/ktlint/pull/500)) + +### Removed +- Support for `--ruleset-repository` and `--ruleset-update` flags + +### Fixed +- `import-ordering` will now refuse to format import lists that contain top-level comments ([#408](https://github.com/pinterest/ktlint/issues/408)) +- `no-unused-imports` reporting false negatives or false positives in some cases ([#405](https://github.com/pinterest/ktlint/issues/405)) and ([#506](https://github.com/pinterest/ktlint/issues/506)) +- `experimental:indent` incorrectly formatting a lambda's closing brace ([#479](https://github.com/pinterest/ktlint/issues/479)) + ## [0.33.0] - 2019-05-28 ### Added @@ -558,7 +589,8 @@ set in `[*{kt,kts}]` section). ## 0.1.0 - 2016-07-27 -[0.32.0]: https://github.com/shyiko/ktlint/compare/0.32.0...0.33.0 +[0.34.0]: https://github.com/shyiko/ktlint/compare/0.33.0...0.34.0 +[0.33.0]: https://github.com/shyiko/ktlint/compare/0.32.0...0.33.0 [0.32.0]: https://github.com/shyiko/ktlint/compare/0.31.0...0.32.0 [0.31.0]: https://github.com/shyiko/ktlint/compare/0.30.0...0.31.0 [0.30.0]: https://github.com/shyiko/ktlint/compare/0.29.0...0.30.0 diff --git a/README.md b/README.md index f8dc8972a1..a09ce762b6 100644 --- a/README.md +++ b/README.md @@ -40,28 +40,25 @@ It's also [easy to create your own](#creating-a-reporter). - No empty (`{}`) class bodies - No spaces around range (`..`) operator - No newline before (binary) `+` & `-`, `*`, `/`, `%`, `&&`, `||` +- No wildcard `import`s - When wrapping chained calls `.`, `?.` and `?:` should be placed on the next line - When a line is broken at an assignment (`=`) operator the break comes after the symbol - When class/function signature doesn't fit on a single line, each parameter must be on a separate line - Consistent string templates (`$v` instead of `${v}`, `${p.v}` instead of `${p.v.toString()}`) - Consistent order of modifiers - Consistent spacing after keywords, commas; around colons, curly braces, parens, infix operators, comments, etc -- Newline at the end of each file (not enabled by default, but recommended) -(set `insert_final_newline=true` in .editorconfig to enable (see [EditorConfig](#editorconfig) section for more)). +- Newline at the end of each file (enabled by default) +(set `insert_final_newline=false` in .editorconfig to disable (see [EditorConfig](#editorconfig) section for more)). +- Imports ordered in alphabetic order with no spaces between major groups ## Experimental rules New rules will be added into the [experimental ruleset](https://github.com/pinterest/ktlint/tree/master/ktlint-ruleset-experimental), which can be enabled by passing the `--experimental` flag to `ktlint`. -- Indentation formatting -- Import ordering - -## Disabled rules -- No wildcard `import`s -- Annotation formatting +- Indentation formatting - respects `.editorconfig` `indent_size` with no continuation indent +- Annotation formatting - multiple annotations should be on a separate line than the annotated declaration; annotations with parameters should each be on separate lines - No underscores in package names -- Braces required for if/else statements -- Multi-line lambdas must name `it` param +- Braces required for multiline if/else statements ## EditorConfig @@ -76,6 +73,10 @@ insert_final_newline=unset # possible values: number (e.g. 120) (package name, imports & comments are ignored), "off" # it's automatically set to 100 on `ktlint --android ...` (per Android Kotlin Style Guide) max_line_length=off +# Comma-separated list of rules to disable (Since 0.34.0) +# Note that rules in any ruleset other than the standard ruleset will need to be prefixed +# by the ruleset identifier. +disabled_rules=no-wildcard-imports,experimental:annotation,my-custom-ruleset:my-custom-rule ``` ## Installation @@ -83,7 +84,7 @@ max_line_length=off > Skip all the way to the "Integration" section if you don't plan to use `ktlint`'s command line interface. ```sh -curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.33.0/ktlint && +curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.34.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/ ``` @@ -178,7 +179,7 @@ $ ktlint installGitPreCommitHook com.pinterest ktlint - 0.33.0 + 0.34.0 @@ -226,7 +227,7 @@ configurations { } dependencies { - ktlint "com.pinterest:ktlint:0.33.0" + ktlint "com.pinterest:ktlint:0.34.0" // additional 3rd party ruleset(s) can be specified here // just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and // ktlint will pick them up @@ -328,7 +329,7 @@ A complete sample project (with tests and build files) is included in this repo #### AST While writing/debugging [Rule](ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/Rule.kt)s it's often helpful to have an AST -printed out to see the structure rules have to work with. ktlint >= 0.15.0 has `printAST` subcommand specifically for this purpose +printed out to see the structure rules have to work with. ktlint >= 0.15.0 has a `printAST` subcommand (or `--print-ast` flag for ktlint < 0.34.0) specifically for this purpose (usage: `ktlint --color printAST `). An example of the output is shown below. @@ -402,7 +403,7 @@ Absolutely, "no configuration" doesn't mean "no extensibility". You can add your See [Creating A Ruleset](#creating-a-ruleset). -### How do I suppress an error? +### How do I suppress an error for a line/block/file? > This is meant primarily as an escape latch for the rare cases when **ktlint** is not able to produce the correct result (please report any such instances using [GitHub Issues](https://github.com/pinterest/ktlint/issues)). @@ -425,6 +426,9 @@ To disable all checks: import package.* // ktlint-disable ``` +### How do I globally disable a rule? +See the [EditorConfig section](https://github.com/pinterest/ktlint#editorconfig) for details on how to use the `disabled_rules` property. + ## Development > Make sure to read [CONTRIBUTING.md](CONTRIBUTING.md).