@@ -69,7 +69,7 @@ private void runTestUsingPrettier(String fileType, Map<String, String> dependenc
69
69
buildDir (),
70
70
null ,
71
71
npmPathResolver (),
72
- new PrettierConfig (prettierRc , null ));
72
+ new PrettierConfig (prettierRc , null , null ));
73
73
74
74
try (StepHarness stepHarness = StepHarness .forStep (formatterStep )) {
75
75
stepHarness .testResource (dirtyFile , cleanFile );
@@ -96,7 +96,7 @@ void parserInferenceBasedOnExplicitFilepathIsWorking(String prettierVersion) thr
96
96
buildDir (),
97
97
null ,
98
98
npmPathResolver (),
99
- new PrettierConfig (null , ImmutableMap .of ("filepath" , "anyname.json" ))); // should select parser based on this name
99
+ new PrettierConfig (null , ImmutableMap .of ("filepath" , "anyname.json" ), null )); // should select parser based on this name
100
100
101
101
try (StepHarness stepHarness = StepHarness .forStep (formatterStep )) {
102
102
stepHarness .testResource (dirtyFile , cleanFile );
@@ -118,7 +118,7 @@ void parserInferenceBasedOnFilenameIsWorking(String prettierVersion) throws Exce
118
118
buildDir (),
119
119
null ,
120
120
npmPathResolver (),
121
- new PrettierConfig (null , Collections .emptyMap ()));
121
+ new PrettierConfig (null , Collections .emptyMap (), null ));
122
122
123
123
try (StepHarnessWithFile stepHarness = StepHarnessWithFile .forStep (this , formatterStep )) {
124
124
stepHarness .testResource ("test.json" , dirtyFile , cleanFile );
@@ -134,7 +134,7 @@ void verifyPrettierErrorMessageIsRelayed() throws Exception {
134
134
buildDir (),
135
135
null ,
136
136
npmPathResolver (),
137
- new PrettierConfig (null , ImmutableMap .of ("parser" , "postcss" )));
137
+ new PrettierConfig (null , ImmutableMap .of ("parser" , "postcss" ), null ));
138
138
try (StepHarnessWithFile stepHarness = StepHarnessWithFile .forStep (this , formatterStep )) {
139
139
stepHarness .expectLintsOfResource ("npm/prettier/filetypes/scss/scss.dirty" )
140
140
.toBe ("LINE_UNDEFINED prettier-format(com.diffplug.spotless.npm.SimpleRestClient$SimpleRestResponseException) Unexpected response status code at /prettier/format [HTTP 500] -- (Error while formatting: Error: Couldn't resolve parser \" postcss\" ) (...)" );
@@ -170,19 +170,27 @@ void runFormatTest(String prettierVersion, PrettierConfig config, String cleanFi
170
170
@ ParameterizedTest (name = "{index}: defaults are applied with prettier {0}" )
171
171
@ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
172
172
void defaultsAreApplied (String prettierVersion ) throws Exception {
173
- runFormatTest (prettierVersion , new PrettierConfig (null , ImmutableMap .of ("parser" , "typescript" )), "defaults_prettier_" + major (prettierVersion ));
173
+ runFormatTest (prettierVersion , new PrettierConfig (null , ImmutableMap .of ("parser" , "typescript" ), null ), "defaults_prettier_" + major (prettierVersion ));
174
174
}
175
175
176
176
@ ParameterizedTest (name = "{index}: config file options are applied with prettier {0}" )
177
177
@ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
178
178
void configFileOptionsAreApplied (String prettierVersion ) throws Exception {
179
- runFormatTest (prettierVersion , new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), null ), "configfile_prettier_" + major (prettierVersion ));
179
+ runFormatTest (prettierVersion , new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), null , null ), "configfile_prettier_" + major (prettierVersion ));
180
180
}
181
181
182
- @ ParameterizedTest (name = "{index}: config file options can be overriden with prettier {0}" )
182
+ @ ParameterizedTest (name = "{index}: config file options can be overridden with prettier {0}" )
183
183
@ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
184
- void configFileOptionsCanBeOverriden (String prettierVersion ) throws Exception {
185
- runFormatTest (prettierVersion , new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), ImmutableMap .of ("printWidth" , 300 )), "override_prettier_" + major (prettierVersion ));
184
+ void configFileOptionsCanBeOverridden (String prettierVersion ) throws Exception {
185
+ runFormatTest (prettierVersion , new PrettierConfig (createTestFile (FILEDIR + ".prettierrc.yml" ), ImmutableMap .of ("printWidth" , 300 ), null ), "override_prettier_" + major (prettierVersion ));
186
+ }
187
+
188
+ @ ParameterizedTest (name = "{index}: config file options can be extended with editorconfig with prettier {0}" )
189
+ @ ValueSource (strings = {PRETTIER_VERSION_2 , PRETTIER_VERSION_3 })
190
+ void configFileOptionsCanBeExtendedWithEditorconfig (String prettierVersion ) throws Exception {
191
+ setFile (".editorconfig" ).toResource (FILEDIR + ".editorconfig_300" );
192
+ File prettierConfigFile = setFile (".prettierrc.yml" ).toResource (FILEDIR + ".prettierrc_noop.yml" );
193
+ runFormatTest (prettierVersion , new PrettierConfig (prettierConfigFile , null , true ), "override_prettier_" + major (prettierVersion ));
186
194
}
187
195
188
196
private String major (String semVer ) {
@@ -194,7 +202,7 @@ private String major(String semVer) {
194
202
void equality () {
195
203
new SerializableEqualityTester () {
196
204
String prettierVersion = "3.0.0" ;
197
- PrettierConfig config = new PrettierConfig (null , Map .of ("parser" , "typescript" ));
205
+ PrettierConfig config = new PrettierConfig (null , Map .of ("parser" , "typescript" ), null );
198
206
199
207
@ Override
200
208
protected void setupTest (API api ) {
@@ -203,7 +211,7 @@ protected void setupTest(API api) {
203
211
// change the groupArtifact, and it's different
204
212
prettierVersion = "2.8.8" ;
205
213
api .areDifferentThan ();
206
- config = new PrettierConfig (null , Map .of ("parser" , "css" ));
214
+ config = new PrettierConfig (null , Map .of ("parser" , "css" ), null );
207
215
api .areDifferentThan ();
208
216
}
209
217
0 commit comments