@@ -191,6 +191,7 @@ Spotless CLI supports the following formatter steps in alphabetical order:
191191- [ license-header] ( #license-header )
192192- [ palantir-java-format] ( #palantir-java-format )
193193- [ prettier] ( #prettier )
194+ - [ remove-unused-imports] ( #remove-unused-imports )
194195
195196### clang-format
196197
@@ -635,6 +636,55 @@ spotless --target='src/**/*.java' prettier \
635636 --dev-dependency=' prettier-plugin-java=2.3.0'
636637```
637638
639+ ### remove-unused-imports
640+
641+ This removes unused imports from Java files.
642+
643+ To see usage instructions for the format-annotations formatter, run: ` spotless remove-unused-imports --help `
644+
645+ <!-- -freshmark usage_remove_unused_imports
646+ output =
647+ '```\n' +
648+ {{usage.remove-unused-imports.array}}.join('\n') +
649+ '\n```';
650+ -->
651+
652+ ```
653+ Usage: spotless remove-unused-imports [-hV] [-e=<engine>]
654+ Removes unused imports from Java files.
655+ -e, --engine=<engine> The backing engine to use for detecting and removing
656+ unused imports.
657+ One of: GOOGLE_JAVA_FORMAT, CLEAN_THAT
658+ (default: GOOGLE_JAVA_FORMAT)
659+ -h, --help Show this help message and exit.
660+ -V, --version Print version information and exit.
661+
662+ ✅ This step supports the following file type: Java
663+
664+ 🌎 Additional info:
665+ https://github.com/diffplug/spotless/tree/main/plugin-gradle#removeunusedimports
666+ ```
667+
668+ <!-- -freshmark /usage_remove_unused_imports -->
669+
670+ Example usage:
671+
672+ ``` shell
673+ spotless --target ' **/src/**/*.java' format-annotations
674+
675+ # or add/remove annotations to the default set using list syntax
676+ spotless --target ' **/src/**/*.java' format-annotations \
677+ --add-type-annotation=' MyAnnotation1,MyAnnotation2' \
678+ --remove-type-annotation=' MyAnnotation3,MyAnnotation4'
679+
680+ # or add/remove annotations to the default set using repeated options
681+ spotless --target ' **/src/**/*.java' format-annotations \
682+ --add-type-annotation=' MyAnnotation1' \
683+ --add-type-annotation=' MyAnnotation2' \
684+ --remove-type-annotation=' MyAnnotation3' \
685+ --remove-type-annotation=' MyAnnotation4'
686+ ```
687+
638688## Tipps & Tricks
639689
640690### Using a configuration file
0 commit comments