From 6b21a7790bc3dc462122c90be92ac06b58d4413b Mon Sep 17 00:00:00 2001 From: Simon Gamma Date: Thu, 31 Jul 2025 10:44:48 +0200 Subject: [PATCH] docs: add README info for remove-unused-imports --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index f53598c..983044a 100644 --- a/README.md +++ b/README.md @@ -191,6 +191,7 @@ Spotless CLI supports the following formatter steps in alphabetical order: - [license-header](#license-header) - [palantir-java-format](#palantir-java-format) - [prettier](#prettier) +- [remove-unused-imports](#remove-unused-imports) ### clang-format @@ -635,6 +636,46 @@ spotless --target='src/**/*.java' prettier \ --dev-dependency='prettier-plugin-java=2.3.0' ``` +### remove-unused-imports + +This removes unused imports from Java files. + +To see usage instructions for the format-annotations formatter, run: `spotless remove-unused-imports --help` + + + +``` +Usage: spotless remove-unused-imports [-hV] [-e=] +Removes unused imports from Java files. + -e, --engine= The backing engine to use for detecting and removing + unused imports. + One of: GOOGLE_JAVA_FORMAT, CLEAN_THAT + (default: GOOGLE_JAVA_FORMAT) + -h, --help Show this help message and exit. + -V, --version Print version information and exit. + +✅ This step supports the following file type: Java + +🌎 Additional info: +https://github.com/diffplug/spotless/tree/main/plugin-gradle#removeunusedimports +``` + + + +Example usage: + +```shell +spotless --target '**/src/**/*.java' remove-unused-imports + +# or use non-default engine +spotless --target '**/src/**/*.java' remove-unused-imports --engine=CLEAN_THAT +``` + ## Tipps & Tricks ### Using a configuration file