Skip to content

Commit e214236

Browse files
authored
docs: add remove unused imports docs (#9)
2 parents b5cdd1e + 6b21a77 commit e214236

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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,46 @@ 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' remove-unused-imports
674+
675+
# or use non-default engine
676+
spotless --target '**/src/**/*.java' remove-unused-imports --engine=CLEAN_THAT
677+
```
678+
638679
## Tipps & Tricks
639680

640681
### Using a configuration file

0 commit comments

Comments
 (0)