Skip to content

Commit 217c561

Browse files
committed
fix: adapt for prettier upgrades
1 parent 7be049e commit 217c561

File tree

6 files changed

+46
-45
lines changed

6 files changed

+46
-45
lines changed

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/NpmInstallCacheIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ private BuildResult runPhpPrettierOnDir(File projDir, File cacheDir) throws IOEx
112112
"prettierConfig['tabWidth'] = 3",
113113
"prettierConfig['parser'] = 'php'",
114114
"def prettierPackages = [:]",
115-
"prettierPackages['prettier'] = '2.0.5'",
116-
"prettierPackages['@prettier/plugin-php'] = '0.14.2'",
115+
"prettierPackages['prettier'] = '2.8.8'",
116+
"prettierPackages['@prettier/plugin-php'] = '0.19.6'",
117117
"spotless {",
118118
" format 'php', {",
119119
" target 'php-example.php'",

plugin-gradle/src/test/java/com/diffplug/gradle/spotless/PrettierIntegrationTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void useInlineConfig() throws IOException {
3333
"}",
3434
"repositories { mavenCentral() }",
3535
"def prettierConfig = [:]",
36-
"prettierConfig['printWidth'] = 50",
36+
"prettierConfig['printWidth'] = 20",
3737
"prettierConfig['parser'] = 'typescript'",
3838
"spotless {",
3939
" format 'mytypescript', {",
@@ -44,7 +44,7 @@ void useInlineConfig() throws IOException {
4444
setFile("test.ts").toResource("npm/prettier/config/typescript.dirty");
4545
final BuildResult spotlessApply = gradleRunner().withArguments("--stacktrace", "spotlessApply").build();
4646
Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL");
47-
assertFile("test.ts").sameAsResource("npm/prettier/config/typescript.configfile.clean");
47+
assertFile("test.ts").sameAsResource("npm/prettier/config/typescript.configfile_prettier_2.clean");
4848
}
4949

5050
@Test
@@ -88,7 +88,7 @@ void useFileConfig() throws IOException {
8888
setFile("test.ts").toResource("npm/prettier/config/typescript.dirty");
8989
final BuildResult spotlessApply = gradleRunner().withArguments("--stacktrace", "spotlessApply").build();
9090
Assertions.assertThat(spotlessApply.getOutput()).contains("BUILD SUCCESSFUL");
91-
assertFile("test.ts").sameAsResource("npm/prettier/config/typescript.configfile.clean");
91+
assertFile("test.ts").sameAsResource("npm/prettier/config/typescript.configfile_prettier_2.clean");
9292
}
9393

9494
@Test
@@ -121,8 +121,8 @@ void useJavaCommunityPlugin() throws IOException {
121121
"prettierConfig['tabWidth'] = 4",
122122
"prettierConfig['parser'] = 'java'",
123123
"def prettierPackages = [:]",
124-
"prettierPackages['prettier'] = '2.0.5'",
125-
"prettierPackages['prettier-plugin-java'] = '0.8.0'",
124+
"prettierPackages['prettier'] = '2.8.8'",
125+
"prettierPackages['prettier-plugin-java'] = '2.2.0'",
126126
"spotless {",
127127
" format 'java', {",
128128
" target 'JavaTest.java'",
@@ -145,7 +145,7 @@ void suggestsMissingJavaCommunityPlugin() throws IOException {
145145
"def prettierConfig = [:]",
146146
"prettierConfig['tabWidth'] = 4",
147147
"def prettierPackages = [:]",
148-
"prettierPackages['prettier'] = '2.0.5'",
148+
"prettierPackages['prettier'] = '2.8.8'",
149149
"spotless {",
150150
" format 'java', {",
151151
" target 'JavaTest.java'",
@@ -169,8 +169,8 @@ void usePhpCommunityPlugin() throws IOException {
169169
"prettierConfig['tabWidth'] = 3",
170170
"prettierConfig['parser'] = 'php'",
171171
"def prettierPackages = [:]",
172-
"prettierPackages['prettier'] = '2.0.5'",
173-
"prettierPackages['@prettier/plugin-php'] = '0.14.2'",
172+
"prettierPackages['prettier'] = '2.8.8'",
173+
"prettierPackages['@prettier/plugin-php'] = '0.19.6'",
174174
"spotless {",
175175
" format 'php', {",
176176
" target 'php-example.php'",
@@ -199,14 +199,14 @@ void usePhpAndJavaCommunityPlugin() throws IOException {
199199
"prettierConfigPhp['tabWidth'] = 3",
200200
"prettierConfigPhp['parser'] = 'php'",
201201
"def prettierPackagesPhp = [:]",
202-
"prettierPackagesPhp['prettier'] = '2.0.5'",
203-
"prettierPackagesPhp['@prettier/plugin-php'] = '0.14.2'",
202+
"prettierPackagesPhp['prettier'] = '2.8.8'",
203+
"prettierPackagesPhp['@prettier/plugin-php'] = '0.19.6'",
204204
"def prettierConfigJava = [:]",
205205
"prettierConfigJava['tabWidth'] = 4",
206206
"prettierConfigJava['parser'] = 'java'",
207207
"def prettierPackagesJava = [:]",
208-
"prettierPackagesJava['prettier'] = '2.0.5'",
209-
"prettierPackagesJava['prettier-plugin-java'] = '0.8.0'",
208+
"prettierPackagesJava['prettier'] = '2.8.8'",
209+
"prettierPackagesJava['prettier-plugin-java'] = '2.2.0'",
210210
"spotless {",
211211
" format 'php', {",
212212
" target 'php-example.php'",

plugin-maven/src/test/java/com/diffplug/spotless/maven/prettier/PrettierFormatStepTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ void multiple_prettier_configs() throws Exception {
120120
" <devDependencyProperties>",
121121
" <property>",
122122
" <name>prettier</name>",
123-
" <value>2.0.5</value>",
123+
" <value>2.8.8</value>",
124124
" </property>",
125125
" <property>",
126126
" <name>@prettier/plugin-php</name>",
127-
" <value>0.14.2</value>",
127+
" <value>0.19.6</value>",
128128
" </property>",
129129
" </devDependencyProperties>",
130130
" <config>",
@@ -137,11 +137,11 @@ void multiple_prettier_configs() throws Exception {
137137
" <devDependencyProperties>",
138138
" <property>",
139139
" <name>prettier</name>",
140-
" <value>2.0.5</value>",
140+
" <value>2.8.8</value>",
141141
" </property>",
142142
" <property>",
143143
" <name>prettier-plugin-java</name>",
144-
" <value>0.8.0</value>",
144+
" <value>2.2.0</value>",
145145
" </property>",
146146
" </devDependencyProperties>",
147147
" <config>",
@@ -166,11 +166,11 @@ void custom_plugin() throws Exception {
166166
" <devDependencyProperties>",
167167
" <property>",
168168
" <name>prettier</name>",
169-
" <value>2.0.5</value>",
169+
" <value>2.8.8</value>",
170170
" </property>",
171171
" <property>",
172172
" <name>@prettier/plugin-php</name>",
173-
" <value>0.14.2</value>",
173+
" <value>0.19.6</value>",
174174
" </property>",
175175
" </devDependencyProperties>",
176176
" <config>",

testlib/src/main/resources/npm/prettier/plugins/java-test.clean

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import java.util.List;
44
import java.util.function.Consumer;
55

66
public class JavaTest {
7+
78
private static final String NAME = "JavaTest";
89

910
private List<String> strings = new ArrayList<>();
@@ -30,8 +31,8 @@ public class JavaTest {
3031
JavaTest javaTest = new JavaTest("1", "2", "3");
3132
System.out.println("joined: " + javaTest.join(','));
3233
StringBuilder builder = new StringBuilder();
33-
javaTest.operateOn(
34-
strings -> builder.append(String.join("---", strings))
34+
javaTest.operateOn(strings ->
35+
builder.append(String.join("---", strings))
3536
);
3637
}
3738
}

testlib/src/main/resources/npm/prettier/plugins/php.clean

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ abstract class ReallyReallyReallyLongClassName
2727
// variable doc
2828
public $test;
2929
public $other = 1;
30-
public static $staticTest = ['hi'];
30+
public static $staticTest = ["hi"];
3131
static $cache;
3232
protected static $_instance;
33-
protected $fillable = ['title', 'requester_id', 'type', 'summary', 'proof'];
33+
protected $fillable = ["title", "requester_id", "type", "summary", "proof"];
3434
protected $fillable2 = [
35-
'title',
36-
'description',
37-
'requester_id',
38-
'type',
39-
'summary',
40-
'proof',
35+
"title",
36+
"description",
37+
"requester_id",
38+
"type",
39+
"summary",
40+
"proof",
4141
];
4242
protected $test = [
4343
//test
@@ -52,7 +52,7 @@ abstract class ReallyReallyReallyLongClassName
5252
*
5353
* @return \Some\Test
5454
*/
55-
public function __construct($test, $test_int = null, $test_string = 'hi')
55+
public function __construct($test, $test_int = null, $test_string = "hi")
5656
{
5757
parent::__construct($test_int ?: 1);
5858
$this->other = $test_string;
@@ -108,7 +108,7 @@ abstract class ReallyReallyReallyLongClassName
108108

109109
public function returnTypeTest(): string
110110
{
111-
return 'hi';
111+
return "hi";
112112
}
113113

114114
final public static function bar()
@@ -125,17 +125,17 @@ abstract class ReallyReallyReallyLongClassName
125125

126126
public function method1()
127127
{
128-
return 'hi';
128+
return "hi";
129129
}
130130

131131
public function method2()
132132
{
133-
return 'hi';
133+
return "hi";
134134
}
135135

136136
public function method3()
137137
{
138-
return 'hi';
138+
return "hi";
139139
}
140140

141141
public function testReturn(?string $name): ?string
@@ -164,15 +164,15 @@ abstract class ReallyReallyReallyLongClassName
164164
string $bar,
165165
int $baz
166166
): string {
167-
return 'foo';
167+
return "foo";
168168
}
169169

170170
public function longLongAnotherFunctionOther(
171171
string $foo,
172172
string $bar,
173173
int $baz
174174
) {
175-
return 'foo';
175+
return "foo";
176176
}
177177

178178
public function testReturnTypeDeclaration(): object
@@ -297,22 +297,22 @@ class field extends \models\base
297297
{
298298
protected function pre_save($input, $fields)
299299
{
300-
$input['configs'] = json_encode(
300+
$input["configs"] = json_encode(
301301
array_merge(
302302
$configs,
303-
$field_type->process_field_config_from_user($input['definition'])
303+
$field_type->process_field_config_from_user($input["definition"])
304304
)
305305
);
306-
unset($input['definition']);
306+
unset($input["definition"]);
307307
}
308308
}
309309

310310
class test
311311
{
312312
public function test_method()
313313
{
314-
$customer = (object) ['name' => 'Bob'];
315-
$job = (object) ['customer' => $customer];
314+
$customer = (object) ["name" => "Bob"];
315+
$job = (object) ["customer" => $customer];
316316

317317
return "The customer for that job, {$job->customer->name} has an error that shows up after the line gets waaaaay toooo long.";
318318
}
@@ -488,9 +488,9 @@ class User
488488
{
489489
public int $id;
490490
public string $name;
491-
public ?string $b = 'foo';
491+
public ?string $b = "foo";
492492
private Foo $prop;
493-
protected static string $static = 'default';
493+
protected static string $static = "default";
494494

495495
public function __construct(int $id, string $name)
496496
{

testlib/src/test/java/com/diffplug/spotless/npm/PrettierFormatterStepTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void parserInferenceBasedOnFilenameIsWorking(String prettierVersion) throws Exce
128128
@Test
129129
void verifyPrettierErrorMessageIsRelayed() throws Exception {
130130
FormatterStep formatterStep = PrettierFormatterStep.create(
131-
PrettierFormatterStep.defaultDevDependenciesWithPrettier("2.0.5"),
131+
PrettierFormatterStep.defaultDevDependenciesWithPrettier("2.8.8"),
132132
TestProvisioner.mavenCentral(),
133133
projectDir(),
134134
buildDir(),

0 commit comments

Comments
 (0)