@@ -255,6 +255,16 @@ spotless --target '**/src/**/*.java' license-header --header='/* (c) Diffplug $Y
255255
256256### prettier
257257
258+ <!-- -freshmark prettiershields
259+ output = [
260+ link(shield('Default prettier version', '(default)-prettier', '{{libs.versions.bundled.prettier}}', 'blue'), 'https://www.npmjs.com/package/prettier/v/{{libs.versions.bundled.prettier}}'),
261+ ].join('\n')
262+ -->
263+
264+ [ ![ 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 )
265+
266+ <!-- -freshmark /prettiershields -->
267+
258268[ Prettier] ( https://prettier.io/ ) is an opinionated code formatter that supports many languages. Some are supported out of the box such as
259269JavaScript, JSX, Angular, Vue, Flow, TypeScript, CSS, Less, SCSS, HTML, Ember/Handlebars, JSON, GraphQL, Markdown and YAML.
260270
@@ -303,6 +313,60 @@ Example usage:
303313``` shell
304314spotless --target ' **/*.json' prettier
305315
306- # or using a custom version and plugin
307- TODO TODO TODO
316+ # or using a custom version and plugin (prettier <= 2)
317+ spotless --target=' src/**/*.java' prettier \
318+ --prettier-config-option=' printWidth=120' \
319+ --dev-dependency=' prettier=2.8.7' \
320+ --dev-dependency=' prettier-plugin-java=2.1.0'
321+
322+ # or using a custom version and plugin (prettier 3+)
323+ # → prettier 3 needs you to enable plugins explicitly (see 'plugins' config option)
324+ spotless --target=' src/**/*.java' prettier \
325+ --prettier-config-option=' printWidth=120' \
326+ --prettier-config-option=' plugins=["prettier-plugin-java"]' \
327+ --dev-dependency=' prettier=3.0.3' \
328+ --dev-dependency=' prettier-plugin-java=2.3.0'
329+ ```
330+
331+ ## Tipps & Tricks
332+
333+ ### Using a configuration file
334+
335+ Since spotless-cli is based on ` picocli ` , you can use configuration files to store long or complex command lines
336+ (called @files in picocli terminology).
337+
338+ :point_right : For details see [ picocli documentation] ( https://picocli.info/#AtFiles )
339+
340+ Example usage:
341+
342+ Store a configuration file ` /path/to/my/project/spotless-prettier-java.config ` with the following content:
343+
344+ ```
345+ --target 'src/**/*.java'
346+ prettier
347+ --prettier-config-option 'printWidth=120'
348+ --prettier-config-option 'plugins=["prettier-plugin-java"]'
349+ --dev-dependency 'prettier=3.0.3'
350+ --dev-dependency 'prettier-plugin-java=2.3.0'
351+ license-header
352+ --header-file=/path/to/my/project/license-header.txt
353+ ```
354+
355+ Then you can run spotless-cli with just the following command:
356+
357+ ``` shell
358+ spotless @/path/to/my/project/spotless-prettier-java.config
359+ ```
360+
361+ which behind the scenes will be expanded into:
362+
363+ ``` shell
364+ spotless --target=' src/**/*.java' \
365+ prettier \
366+ --prettier-config-option=' printWidth=120' \
367+ --prettier-config-option=' plugins=["prettier-plugin-java"]' \
368+ --dev-dependency=' prettier=3.0.3' \
369+ --dev-dependency=' prettier-plugin-java=2.3.0' \
370+ license-header \
371+ --header-file=' /path/to/my/project/license-header.txt'
308372```
0 commit comments