Skip to content

Commit 6e349d4

Browse files
authored
Update README.md to increase readability of prettier plugin configuration (#2011)
2 parents 409902d + d4b102c commit 6e349d4

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

plugin-gradle/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,16 +1086,34 @@ To apply prettier to more kinds of files, just add more formats
10861086
Since spotless uses the actual npm prettier package behind the scenes, it is possible to use prettier with
10871087
[plugins](https://prettier.io/docs/en/plugins.html#official-plugins) or [community-plugins](https://www.npmjs.com/search?q=prettier-plugin) in order to support even more file types.
10881088
1089+
#### prettier version below 3
1090+
10891091
```gradle
10901092
spotless {
10911093
java {
10921094
prettier(['prettier': '2.8.8', 'prettier-plugin-java': '2.2.0']).config(['parser': 'java', 'tabWidth': 4])
1093-
// prettier(['prettier': '3.0.3', 'prettier-plugin-java': '2.3.0']).config(['parser': 'java', 'tabWidth': 4, 'plugins': ['prettier-plugin-java']]) // Prettier v3 requires additional 'plugins' config
10941095
}
10951096
format 'php', {
10961097
target 'src/**/*.php'
10971098
prettier(['prettier': '2.8.8', '@prettier/plugin-php': '0.19.6']).config(['parser': 'php', 'tabWidth': 3])
1098-
// prettier(['prettier': '3.0.3', '@prettier/plugin-php': '0.20.1']).config(['parser': 'php', 'tabWidth': 3, 'plugins': ['@prettier/plugin-php']]) // Prettier v3 requires additional 'plugins' config
1099+
}
1100+
}
1101+
```
1102+
1103+
#### prettier version 3+
1104+
1105+
With version 3 prettier it is required to pass in an additional 'plugins' parameter to the config block with a list of plugins you want to use.
1106+
1107+
```gradle
1108+
spotless {
1109+
java {
1110+
prettier(['prettier': '3.0.3', 'prettier-plugin-java': '2.3.0'])
1111+
.config(['parser': 'java', 'tabWidth': 4, 'plugins': ['prettier-plugin-java']])
1112+
}
1113+
format 'php', {
1114+
target 'src/**/*.php'
1115+
prettier(['prettier': '3.0.3', '@prettier/plugin-php': '0.20.1'])
1116+
.config(['parser': 'php', 'tabWidth': 3, 'plugins': ['@prettier/plugin-php']])
10991117
}
11001118
}
11011119
```

0 commit comments

Comments
 (0)