Skip to content

Commit 56a019c

Browse files
Update README.md
Enhance prettier plugin configuration docs to better differentiate v2 and v3.
1 parent 409902d commit 56a019c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

plugin-gradle/README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,16 +1086,32 @@ 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']).config(['parser': 'java', 'tabWidth': 4, 'plugins': ['prettier-plugin-java']])
1111+
}
1112+
format 'php', {
1113+
target 'src/**/*.php'
1114+
prettier(['prettier': '3.0.3', '@prettier/plugin-php': '0.20.1']).config(['parser': 'php', 'tabWidth': 3, 'plugins': ['@prettier/plugin-php']])
10991115
}
11001116
}
11011117
```

0 commit comments

Comments
 (0)