{"id":28507717,"url":"https://github.com/diffplug/spotless-cli","last_synced_at":"2025-08-16T22:32:15.823Z","repository":{"id":280526990,"uuid":"931748646","full_name":"diffplug/spotless-cli","owner":"diffplug","description":"A CLI for Spotless","archived":false,"fork":false,"pushed_at":"2025-07-30T19:47:06.000Z","size":789,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-30T21:59:16.568Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/diffplug.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-12T19:42:56.000Z","updated_at":"2025-06-30T06:51:44.000Z","dependencies_parsed_at":"2025-03-23T20:26:51.739Z","dependency_job_id":"4687406b-f4d9-4e89-b881-55f1db4d173f","html_url":"https://github.com/diffplug/spotless-cli","commit_stats":null,"previous_names":["diffplug/spotless-cli"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/diffplug/spotless-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diffplug%2Fspotless-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diffplug%2Fspotless-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diffplug%2Fspotless-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diffplug%2Fspotless-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/diffplug","download_url":"https://codeload.github.com/diffplug/spotless-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/diffplug%2Fspotless-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270781196,"owners_count":24643804,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T21:06:13.200Z","updated_at":"2025-08-16T22:32:15.775Z","avatar_url":"https://github.com/diffplug.png","language":"Java","readme":"# \u003cimg align=\"left\" src=\"docs/logo/spotless_banner.png\" alt=\"Banner introducing spotless cli\"\u003e Spotless Command Line Interface CLI\n\n_Keep your code Spotless from the command line_\n\n\u003c!---freshmark shields\noutput = [\n  link(shield('SpotlessCLI Version', 'latest-version', '{{spotlessVersion}}', 'blue'), 'CHANGELOG.md'),\n  '',\n  link(shield('OS Win', 'OS', 'Windows', 'blueviolet'), '#installation-on-windows'),\n  link(shield('OS Linux', 'OS', 'Linux', 'blueviolet'), '#installation-on-macos-and-linux'),\n  link(shield('OS macOS', 'OS', 'macOS', 'blueviolet'), '#installation-on-macos-and-linux'),\n  ].join('\\n')\n--\u003e\n\n[![SpotlessCLI Version](https://img.shields.io/badge/latest--version-0.2.0-blue.svg)](CHANGELOG.md)\n\n[![OS Win](https://img.shields.io/badge/OS-Windows-blueviolet.svg)](#installation-on-windows)\n[![OS Linux](https://img.shields.io/badge/OS-Linux-blueviolet.svg)](#installation-on-macos-and-linux)\n[![OS macOS](https://img.shields.io/badge/OS-macOS-blueviolet.svg)](#installation-on-macos-and-linux)\n\n\u003c!---freshmark /shields --\u003e\n\n\u003e [!NOTE]\n\u003e This project is a work in progress :hourglass_flowing_sand: and not yet released.\n\u003e\n\u003e Please check back later for the first release. :heart:\n\n`spotless` is a command line interface (CLI) for the [spotless code formatter](../README.md).\nIt intends to be a simple alternative to its siblings: the plugins for [gradle](../plugin-gradle/README.md), [maven](../plugin-maven/README.md)\nand others. It supports formatting a plethora of file types and can be easily configured.\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' \\\n    google-java-format \\\n    license-header --header='/* (c) DiffPlug $YEAR */'\n```\n\nThis command formats all java files in any `src` folder with the [google-java-format](https://github.com/google/google-java-format) and adds (or updates an existing) license header.\n\nUsing the above command line you go\n\n\u003c!---freshmark example_usage_before_after\noutput = [\n  '| From this | to this |',\n    '| --- | --- |',\n  '| ' + image('before', 'docs/examples/intro/FormattingExample.png') + ' | ' + image('after', 'docs/examples/intro/FormattingExampleFormatted.png') + ' |',\n  ].join('\\n')\n--\u003e\n\n| From this                                            | to this                                                      |\n| ---------------------------------------------------- | ------------------------------------------------------------ |\n| ![before](docs/examples/intro/FormattingExample.png) | ![after](docs/examples/intro/FormattingExampleFormatted.png) |\n\n\u003c!---freshmark /example_usage_before_after --\u003e\n\n## Installation\n\n### Installation on macOS and Linux\n\nTo install with [Homebrew](https://brew.sh/) on macOS or Linux:\n\n```shell\nbrew install diffplug/tap/spotless-cli\n\n# or if you prefer\nbrew tap diffplug/tap\nbrew install spotless-cli\n```\n\n### Installation on Windows\n\nTo install with [Chocolatey](https://chocolatey.org/) on Windows:\n\n```shell\nchoco install spotless-cli\n```\n\nAlternatively, you can download the latest binary for your system from the [releases page](https://...) and add it to your PATH.\n\n## General usage\n\nThe general principle is to specify the files to format, configure global options and then add one or more formatter steps - with configuration if needed.\n\n```shell\n# general structure of the invocation\nspotless --target [... more options] formatter1 [config-of-formatter1] formatter2 [config-of-formatter2] ...\n```\n\nBe aware that the order of the formatter steps is important. The formatters are applied in the order they are specified.\n\nTo see all available options and formatters, run:\n\n```shell\nspotless --help\n```\n\nThis will show you the available options and formatters as such:\n\n\u003c!---freshmark usage_main\noutput =\n   '```\\n' +\n   {{usage.main.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\n                     __  __\n   _________  ____  / /_/ /__  __________\n  / ___/ __ \\/ __ \\/ __/ / _ \\/ ___/ ___/\n (__  ) /_/ / /_/ / /_/ /  __(__  |__  )\n/____/ .___/\\____/\\__/_/\\___/____/____/   Spotless CLI\n    /_/\n\n\nUsage: spotless [-hV] [-e=\u003cencoding\u003e] [-l=\u003clineEnding\u003e] [--log-file=\u003clogFile\u003e]\n                [-m=\u003cspotlessMode\u003e] [-p=N] [-t=\u003ctargets\u003e]... [-q | -v [-v]...]\n                [FORMATTING_STEPS]\n\nspotless is a command line interface (CLI) for the spotless code formatter.\nIt can either check if your files are formatted according to your configuration\nor apply the formatting to the files.\n\n  -e, --encoding=\u003cencoding\u003e  The encoding of the files to format.\n                             (default: UTF-8)\n  -h, --help                 Show this help message and exit.\n  -l, --line-ending=\u003clineEnding\u003e\n                             The line ending of the files to format.\n                             One of: GIT_ATTRIBUTES,\n                               GIT_ATTRIBUTES_FAST_ALLSAME, PLATFORM_NATIVE,\n                               WINDOWS, UNIX, MAC_CLASSIC, PRESERVE\n                             (default: UNIX)\n      --log-file=\u003clogFile\u003e   The log file to write the output to.\n  -m, --mode=\u003cspotlessMode\u003e  The mode to run spotless in.\n                             One of: CHECK, APPLY\n                             (default: APPLY)\n                             APPLY: Apply the correct formatting where needed\n                               (replace file contents with formatted content).\n                             CHECK: Check if the files are formatted or show\n                               the diff of the formatting.\n  -p, --parallelity=N        The number of parallel formatter threads to run.\n                             (default: #cores * 0.5)\n  -q, --quiet                Disable as much output as possible.\n  -t, --target=\u003ctargets\u003e     The target files to format. Blobs are supported.\n                             Examples:\n                             -t 'src/**/*.java'\n                             -t 'src/**/*.kt'\n                             -t 'README.md'\n  -v                         Enable verbose output. Multiple -v options\n                               increase the verbosity (max 5).\n  -V, --version              Print version information and exit.\n\nAvailable formatting steps:\n  clang-format           Runs clang-format\n  clean-that             CleanThat enables automatic refactoring of Java code.\n  format-annotations     Corrects line break formatting of type annotations in\n                           java files.\n  google-java-format     Runs google java format\n  license-header         Runs license header\n  palantir-java-format   Runs palantir java format\n  prettier               Runs prettier, the opinionated code formatter.\n  remove-unused-imports  Removes unused imports from Java files.\n\nPossible exit codes:\n  0    Successful formatting.\n       In APPLY mode, this means all files were formatted successfully.\n       In CHECK mode, this means all files were already formatted properly.\n  1    Some files need to be formatted.\n       In APPLY mode, this means some files failed to be formatted (see output\n         for details).\n       In CHECK mode, this means some files are currently not formatted\n         properly (and might be fixed in APPLY mode).\n  -1   Some files did not converge. This can happen when one formatter does not\n         converge on the file content.\n       You can find more about this special case here:\n         \u003chttps://github.com/diffplug/spotless/blob/main/PADDEDCELL.md\u003e\n  -2   An exception occurred during execution.\n```\n\n\u003c!---freshmark /usage_main --\u003e\n\n## Available Formatter Steps\n\nSpotless CLI supports the following formatter steps in alphabetical order:\n\n- [clang-format](#clang-format)\n- [clean-that](#clean-that)\n- [format-annotations](#format-annotations)\n- [google-java-format](#google-java-format)\n- [license-header](#license-header)\n- [palantir-java-format](#palantir-java-format)\n- [prettier](#prettier)\n- [remove-unused-imports](#remove-unused-imports)\n\n### clang-format\n\nFormats C/C++/Objective-C and more files according to the [clang-format](https://clang.llvm.org/docs/ClangFormat.html) style guide.\n\nTo see usage instructions for the clang-format formatter, run: `spotless clang-format --help`\n\n\u003c!---freshmark usage_clang_format\noutput =\n   '```\\n' +\n   {{usage.clang-format.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless clang-format [-hV] [-c=\u003cpathToExec\u003e] [-s=\u003cstyle\u003e] [-v=\u003cversion\u003e]\nRuns clang-format\n  -c, --clang-format-exec=\u003cpathToExec\u003e\n                        The path to the clang-format executable.\n                        (default: looks on your PATH)\n  -h, --help            Show this help message and exit.\n  -s, --style=\u003cstyle\u003e   The style to use for clang-format.\n  -v, --clang-version=\u003cversion\u003e\n                        The version of clang-format to use.\n                        (default: 10.0.1)\n  -V, --version         Print version information and exit.\n\n✅ This step supports the following file types:\n   * C\n   * C++\n   * Java\n   * JavaScript\n   * JSON\n   * Objective-C\n   * Protobuf\n   * C#\n\n🌎 Additional info:\nhttps://clang.llvm.org/docs/ClangFormat.html\n```\n\n\u003c!---freshmark /usage_clang_format --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.cpp' clang-format --clang-version=20.1.2 --style=Google\n```\n\n\u003e [!IMPORTANT]\n\u003e Running a clang-format step requires a working installation of the clang-format binary.\n\n### clean-that\n\n\u003c!---freshmark ctshields\noutput = [\n  link(shield('CleanThat version', 'clean-that', '{{libs.versions.native.include.cleanThat}}', 'blue'), 'https://github.com/solven-eu/cleanthat'),\n  ].join('\\n')\n--\u003e\n\n[![CleanThat version](https://img.shields.io/badge/clean--that-2.23-blue.svg)](https://github.com/solven-eu/cleanthat)\n\n\u003c!---freshmark /ctshields --\u003e\n\nCleanthat is a project enabling automatic code cleaning, from formatting to refactoring.\n\nTo see usage instructions for the clean-that formatter, run: `spotless clean-that --help`\n\n\u003c!---freshmark usage_clean_that\noutput =\n   '```\\n' +\n   {{usage.clean-that.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless clean-that [-dDhV] [-s=\u003csourceCompatibility\u003e] [-a[=mutator[,\n                           mutator...]...]]... [-e[=mutator[,mutator...]...]]...\nCleanThat enables automatic refactoring of Java code.\n  -a, --add-mutator[=mutator[,mutator...]...]\n                  Add a mutator to the list of mutators to use. Mutators are\n                    the individual refactoring steps CleanThat applies. A list\n                    of available mutators can be found in the \"Additional Info\"\n                    section.\n  -d, --use-default-mutators\n                  Use the default mutators provided by CleanThat. Default\n                    mutators are: \u003cSafeAndConsensual\u003e.\n                  (default: true)\n  -D, --include-draft-mutators\n                  Include draft mutators in the list of mutators to use. Draft\n                    mutators are experimental and may not be fully tested or\n                    stable.\n                  (default: false)\n  -e, --exclude-mutator[=mutator[,mutator...]...]\n                  Remove a mutator from the list of mutators to use. This might\n                    make sense for composite mutators\n  -h, --help      Show this help message and exit.\n  -s, --source-compatibility=\u003csourceCompatibility\u003e\n                  The source JDK version to use for the CleanThat mutators.\n                    This is used to determine the Java language features\n                    available.\n                  (default: 1.8)\n  -V, --version   Print version information and exit.\n\n✅ This step supports the following file type: Java\n\n🌎 Additional info:\n   * https://github.com/solven-eu/cleanthat\n   * https://github.com/solven-eu/cleanthat/blob/master/MUTATORS.generated.MD\n```\n\n\u003c!---freshmark /usage_clean_that --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' clean-that --exclude-mutator=StreamAnyMatch\n```\n\n### format-annotations\n\nIn Java, type annotations should be on the same line as the type that they qualify. This formatter fixes this for you.\n\nTo see usage instructions for the format-annotations formatter, run: `spotless format-annotations --help`\n\n\u003c!---freshmark usage_format_annotations\noutput =\n   '```\\n' +\n   {{usage.format-annotations.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless format-annotations [-hV] [-a[=annotation[,\n                                   annotation...]...]]... [-r[=annotation[,\n                                   annotation...]...]]...\nCorrects line break formatting of type annotations in java files.\n  -a, --add-type-annotation[=annotation[,annotation...]...]\n                  Add annotations to the list of type annotations to keep on\n                    the same line as the type.\n  -h, --help      Show this help message and exit.\n  -r, --remove-type-annotation[=annotation[,annotation...]...]\n                  Remove annotations from the list of type annotations to keep\n                    on the same line as the type.\n  -V, --version   Print version information and exit.\n\n✅ This step supports the following file type: Java\n\n🌎 Additional info:\nhttps://github.com/diffplug/spotless/tree/main/plugin-gradle#formatAnnotations\n```\n\n\u003c!---freshmark /usage_format_annotations --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' format-annotations\n\n# or add/remove annotations to the default set using list syntax\nspotless --target '**/src/**/*.java' format-annotations \\\n    --add-type-annotation='MyAnnotation1,MyAnnotation2' \\\n    --remove-type-annotation='MyAnnotation3,MyAnnotation4'\n\n# or add/remove annotations to the default set using repeated options\nspotless --target '**/src/**/*.java' format-annotations \\\n    --add-type-annotation='MyAnnotation1' \\\n    --add-type-annotation='MyAnnotation2' \\\n    --remove-type-annotation='MyAnnotation3' \\\n    --remove-type-annotation='MyAnnotation4'\n```\n\n### google-java-format\n\n\u003c!---freshmark gjfshields\noutput = [\n  link(shield('Google Java Format version', 'google-java-format', '{{libs.versions.native.include.googleJavaFormat}}', 'blue'), 'https://github.com/google/google-java-format'),\n  ].join('\\n')\n--\u003e\n\n[![Google Java Format version](https://img.shields.io/badge/google--java--format-1.27.0-blue.svg)](https://github.com/google/google-java-format)\n\n\u003c!---freshmark /gjfshields --\u003e\n\nFormats Java files according to the [google-java-format](https://github.com/google/google-java-format) style guide.\n\nTo see usage instructions for the google-java-format formatter, run: `spotless google-java-format --help`\n\n\u003c!---freshmark usage_google_java_format\noutput =\n   '```\\n' +\n   {{usage.google-java-format.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless google-java-format [-hijrV] [-s=\u003cstyle\u003e]\nRuns google java format\n  -h, --help              Show this help message and exit.\n  -i, --reorder-imports   Reorder imports.\n                          (default: false)\n  -j, --format-javadoc    Format javadoc.\n                          (default: true)\n  -r, --reflow-long-strings\n                          Reflow long strings.\n                          (default: false)\n  -s, --style=\u003cstyle\u003e     The style to use for the google java format.\n                          One of: AOSP, GOOGLE\n                          (default: GOOGLE)\n  -V, --version           Print version information and exit.\n\n✅ This step supports the following file type: Java\n\n🌎 Additional info:\nhttps://github.com/google/google-java-format\n```\n\n\u003c!---freshmark /usage_google_java_format --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' google-java-format --reorder-imports=true\n```\n\n### license-header\n\nAdd or update a license header to the files.\n\nTo see usage instructions for the license-header formatter, run: `spotless license-header --help`\n\n\u003c!---freshmark usage_license_header\noutput =\n   '```\\n' +\n   {{usage.license-header.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless license-header [-hV] [-c=\u003ccontentPattern\u003e] [-d=\u003cdelimiter\u003e]\n                               [-m=\u003cyearMode\u003e] [-s=\u003cskipLinesMatching\u003e]\n                               [-Y=\u003cyearSeparator\u003e] (-H=\u003cheader\u003e |\n                               -f=\u003cheaderFile\u003e)\nRuns license header\n  -c, --content-pattern=\u003ccontentPattern\u003e\n                          The pattern to match the content of the file before\n                            inserting the licence header. (If the file content\n                            does not match the pattern, the header will not be\n                            inserted/updated.)\n  -d, --delimiter=\u003cdelimiter\u003e\n                          The delimiter to use for the license header. If not\n                            provided, the delimiter will be guessed based on\n                            the first few files we find. Otherwise, 'java' will\n                            be assumed.\n  -f, --header-file=\u003cheaderFile\u003e\n                          The license header content in a file to apply.\n                            May contain $YEAR as placeholder.\n  -h, --help              Show this help message and exit.\n  -H, --header=\u003cheader\u003e   The license header content to apply. May contain\n                            $YEAR as placeholder.\n  -m, --year-mode=\u003cyearMode\u003e\n                          How and if the year in the copyright header should be\n                            updated.\n                          One of: PRESERVE, UPDATE_TO_TODAY, SET_FROM_GIT\n                          (default: PRESERVE)\n  -s, --skip-lines-matching=\u003cskipLinesMatching\u003e\n                          Skip lines matching the given regex pattern before\n                            inserting the licence header.\n  -V, --version           Print version information and exit.\n  -Y, --year-separator=\u003cyearSeparator\u003e\n                          The separator to use for the year range in the\n                            license header.\n                          (default: -)\n\n✅ This step supports the following file type: any\n\n🌎 Additional info:\nhttps://github.com/diffplug/spotless/tree/main/plugin-gradle#license-header\n```\n\n\u003c!---freshmark /usage_license_header --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' license-header --header='/* (c) DiffPlug $YEAR */'\n```\n\n### palantir-java-format\n\n\u003c!---freshmark pjfshields\noutput = [\n  link(shield('Palantir Java Format version', 'palantir-java-format', '{{libs.versions.native.include.palantirJavaFormat}}', 'blue'), 'https://github.com/palantir/palantir-java-format'),\n  ].join('\\n')\n--\u003e\n\n[![Palantir Java Format version](https://img.shields.io/badge/palantir--java--format-2.67.0-blue.svg)](https://github.com/palantir/palantir-java-format)\n\n\u003c!---freshmark /pjfshields --\u003e\n\nFormats java files according to the [palantir-java-format](https://github.com/palantir/palantir-java-format) style guide. Palantir Java Format is a modern, lambda-friendly,\n120 character Java formatter. It is based on the Google Java Format project.\n\nTo see usage instructions for the palantir-java-format formatter, run `spotless palantir-java-format --help`\n\n\u003c!---freshmark usage_palantir_java_format\noutput =\n   '```\\n' +\n   {{usage.palantir-java-format.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless palantir-java-format [-hjV] [-s=\u003cstyle\u003e]\nRuns palantir java format\n  -h, --help             Show this help message and exit.\n  -j, --format-javadoc   Format javadoc.\n                         (default: false)\n  -s, --style=\u003cstyle\u003e    The style to use for the palantir java format.\n                         One of: PALANTIR, AOSP, GOOGLE\n                         (default: PALANTIR)\n  -V, --version          Print version information and exit.\n\n✅ This step supports the following file type: Java\n\n🌎 Additional info:\nhttps://github.com/palantir/palantir-java-format\n```\n\n\u003c!---freshmark /usage_palantir_java_format --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' palantir-java-format --format-javadoc=true\n```\n\n### prettier\n\n\u003c!---freshmark prettiershields\noutput = [\n  link(shield('Default prettier version', '(default)-prettier', '{{libs.versions.bundled.prettier}}', 'blue'), 'https://www.npmjs.com/package/prettier/v/{{libs.versions.bundled.prettier}}'),\n  ].join('\\n')\n--\u003e\n\n[![Default prettier version](https://img.shields.io/badge/%28default%29--prettier-2.8.8-blue.svg)](https://www.npmjs.com/package/prettier/v/2.8.8)\n\n\u003c!---freshmark /prettiershields --\u003e\n\n[Prettier](https://prettier.io/) is an opinionated code formatter that supports many languages. Some are supported out of the box such as\nJavaScript, JSX, Angular, Vue, Flow, TypeScript, CSS, Less, SCSS, HTML, Ember/Handlebars, JSON, GraphQL, Markdown and YAML.\n\nEven more languages can be supported by including [prettier-plugins](https://prettier.io/docs/plugins).\n\n\u003e [!IMPORTANT]\n\u003e Running a prettier formatter step requires a working installation of [Node.js](https://nodejs.org/en/) and [npm](https://www.npmjs.com/).\n\nTo see usage instructions for the prettier formatter, run: `spotless prettier --help`\n\n\u003c!---freshmark usage_prettier\noutput =\n   '```\\n' +\n   {{usage.prettier.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless prettier [-hV] [-C=\u003cnpmInstallCacheDir\u003e]\n                         [-n=\u003cexplicitNpmExecutable\u003e]\n                         [-N=\u003cexplicitNodeExecutable\u003e]\n                         [-P=\u003cprettierConfigPath\u003e] [-R=\u003cexplicitNpmrcFile\u003e]\n                         [-A=\u003cadditionalNpmrcLocations\u003e]...\n                         [-c='OPTION=VALUE']... [-D='PACKAGE=VERSION']...\nRuns prettier, the opinionated code formatter.\n  -A, --additional-npmrc-location=\u003cadditionalNpmrcLocations\u003e\n                  Additional locations to search for .npmrc files.\n  -c, --prettier-config-option='OPTION=VALUE'\n                  A prettier configuration options.\n                  The format is 'OPTION=VALUE'.\n                  example: 'printWidth=80'\n  -C, --npm-install-cache-dir=\u003cnpmInstallCacheDir\u003e\n                  The directory to use for caching libraries retrieved by 'npm\n                    install'.\n  -D, --dev-dependency='PACKAGE=VERSION'\n                  An entry to add to the package.json for running prettier.\n                  The format is 'PACKAGE=VERSION'.\n                  example: 'prettier=2.8.7'\n  -h, --help      Show this help message and exit.\n  -n, --npm-exec=\u003cexplicitNpmExecutable\u003e\n                  The explicit path to the npm executable.\n  -N, --node-exec=\u003cexplicitNodeExecutable\u003e\n                  The explicit path to the node executable.\n  -P, --prettier-config-path=\u003cprettierConfigPath\u003e\n                  The path to the prettier configuration file.\n  -R, --npmrc-file=\u003cexplicitNpmrcFile\u003e\n                  The explicit path to the .npmrc file.\n  -V, --version   Print version information and exit.\n\n✅ This step supports the following file types:\n   * JavaScript\n   * JSX\n   * Angular\n   * Vue\n   * Flow\n   * TypeScript\n   * CSS\n   * Less\n   * SCSS\n   * HTML\n   * Ember/Handlebars\n   * JSON\n   * GraphQL\n   * Markdown\n   * YAML\n   * Java (only with plugins)\n   * and more (using plugins)\n\n🌎 Additional info:\n   * https://prettier.io/\n   * 🧩 Find plugins at https://prettier.io/docs/plugins.html#official-plugins\n```\n\n\u003c!---freshmark /usage_prettier --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/*.json' prettier\n\n# or using a custom version and plugin (prettier \u003c= 2)\nspotless --target='src/**/*.java' prettier \\\n    --prettier-config-option='printWidth=120' \\\n    --dev-dependency='prettier=2.8.7' \\\n    --dev-dependency='prettier-plugin-java=2.1.0'\n\n# or using a custom version and plugin (prettier 3+)\n# → prettier 3 needs you to enable plugins explicitly (see 'plugins' config option)\nspotless --target='src/**/*.java' prettier \\\n    --prettier-config-option='printWidth=120' \\\n    --prettier-config-option='plugins=[\"prettier-plugin-java\"]' \\\n    --dev-dependency='prettier=3.0.3' \\\n    --dev-dependency='prettier-plugin-java=2.3.0'\n```\n\n### remove-unused-imports\n\nThis removes unused imports from Java files.\n\nTo see usage instructions for the remove-unused-imports formatter, run: `spotless remove-unused-imports --help`\n\n\u003c!---freshmark usage_remove_unused_imports\noutput =\n   '```\\n' +\n   {{usage.remove-unused-imports.array}}.join('\\n') +\n    '\\n```';\n--\u003e\n\n```\nUsage: spotless remove-unused-imports [-hV] [-e=\u003cengine\u003e]\nRemoves unused imports from Java files.\n  -e, --engine=\u003cengine\u003e   The backing engine to use for detecting and removing\n                            unused imports.\n                          One of: GOOGLE_JAVA_FORMAT, CLEAN_THAT\n                          (default: GOOGLE_JAVA_FORMAT)\n  -h, --help              Show this help message and exit.\n  -V, --version           Print version information and exit.\n\n✅ This step supports the following file type: Java\n\n🌎 Additional info:\nhttps://github.com/diffplug/spotless/tree/main/plugin-gradle#removeunusedimports\n```\n\n\u003c!---freshmark /usage_remove_unused_imports --\u003e\n\nExample usage:\n\n```shell\nspotless --target '**/src/**/*.java' remove-unused-imports\n\n# or use non-default engine\nspotless --target '**/src/**/*.java' remove-unused-imports --engine=CLEAN_THAT\n```\n\n## Tipps \u0026 Tricks\n\n### Using a configuration file\n\nSince spotless-cli is based on `picocli`, you can use configuration files to store long or complex command lines\n(called @files in picocli terminology).\n\n:point_right: For details see [picocli documentation](https://picocli.info/#AtFiles)\n\nExample usage:\n\nStore a configuration file `/path/to/my/project/spotless-prettier-java.config` with the following content:\n\n```\n--target 'src/**/*.java'\nprettier\n--prettier-config-option 'printWidth=120'\n--prettier-config-option 'plugins=[\"prettier-plugin-java\"]'\n--dev-dependency 'prettier=3.0.3'\n--dev-dependency 'prettier-plugin-java=2.3.0'\nlicense-header\n--header-file=/path/to/my/project/license-header.txt\n```\n\nThen you can run spotless-cli with just the following command:\n\n```shell\nspotless @/path/to/my/project/spotless-prettier-java.config\n```\n\nwhich behind the scenes will be expanded into:\n\n```shell\nspotless --target='src/**/*.java' \\\n    prettier \\\n        --prettier-config-option='printWidth=120' \\\n        --prettier-config-option='plugins=[\"prettier-plugin-java\"]' \\\n        --dev-dependency='prettier=3.0.3' \\\n        --dev-dependency='prettier-plugin-java=2.3.0' \\\n    license-header \\\n        --header-file='/path/to/my/project/license-header.txt'\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiffplug%2Fspotless-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiffplug%2Fspotless-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiffplug%2Fspotless-cli/lists"}