@@ -85,129 +85,64 @@ void formattingUsingRulesetsFile(String ruleSetName) throws Exception {
85
85
}
86
86
}
87
87
}
88
- /*
89
- @NpmTest
90
- @Nested
91
- class PrettierFormattingOfFileTypesIsWorking extends NpmFormatterStepCommonTests {
92
-
93
- @ParameterizedTest(name = "{index}: prettier can be applied to {0}")
94
- @ValueSource(strings = {"html", "typescript", "json", "javascript-es5", "javascript-es6", "css", "scss", "markdown", "yaml"})
95
- void formattingUsingConfigFile(String fileType) throws Exception {
96
- String filedir = "npm/prettier/filetypes/" + fileType + "/";
97
-
98
- final File prettierRc = createTestFile(filedir + ".prettierrc.yml");
99
- final String dirtyFile = filedir + fileType + ".dirty";
100
- final String cleanFile = filedir + fileType + ".clean";
101
-
102
- final FormatterStep formatterStep = PrettierFormatterStep.create(
103
- PrettierFormatterStep.defaultDevDependencies(),
104
- TestProvisioner.mavenCentral(),
105
- buildDir(),
106
- npmPathResolver(),
107
- new PrettierConfig(prettierRc, null));
108
-
109
- try (StepHarness stepHarness = StepHarness.forStep(formatterStep)) {
110
- stepHarness.testResource(dirtyFile, cleanFile);
111
- }
112
- }
113
- }
114
88
115
89
@ NpmTest
116
90
@ Nested
117
- class SpecificPrettierFormatterStepTests extends NpmFormatterStepCommonTests {
91
+ class EslintInlineConfigFormattingStepTest extends NpmFormatterStepCommonTests {
118
92
119
- @Test
120
- void parserInferenceBasedOnExplicitFilepathIsWorking() throws Exception {
121
- String filedir = "npm/prettier/filetypes/json/";
122
-
123
- final String dirtyFile = filedir + "json.dirty";
124
- final String cleanFile = filedir + "json.clean";
125
-
126
- final FormatterStep formatterStep = PrettierFormatterStep.create(
127
- PrettierFormatterStep.defaultDevDependencies(),
128
- TestProvisioner.mavenCentral(),
129
- buildDir(),
130
- npmPathResolver(),
131
- new PrettierConfig(null, ImmutableMap.of("filepath", "anyname.json"))); // should select parser based on this name
132
-
133
- try (StepHarness stepHarness = StepHarness.forStep(formatterStep)) {
134
- stepHarness.testResource(dirtyFile, cleanFile);
135
- }
136
- }
137
93
138
94
@ Test
139
- void parserInferenceBasedOnFilenameIsWorking() throws Exception {
140
- String filedir = "npm/prettier/filename/";
141
-
142
- final String dirtyFile = filedir + "dirty.json";
143
- final String cleanFile = filedir + "clean.json";
95
+ void formattingUsingInlineXoConfig () throws Exception {
96
+ String filedir = "npm/eslint/typescript/standard_rules_xo/" ;
97
+
98
+ String testDir = "formatting_ruleset_xo_inline_config/" ;
99
+
100
+
101
+ final String esLintConfig = String .join ("\n " ,
102
+ "{" ,
103
+ " env: {" ,
104
+ " browser: true," ,
105
+ " es2021: true," ,
106
+ " }," ,
107
+ " extends: 'xo/browser'," ,
108
+ " overrides: [" ,
109
+ " {" ,
110
+ " extends: [" ,
111
+ " 'xo-typescript'," ,
112
+ " ]," ,
113
+ " files: [" ,
114
+ " '*.ts'," ,
115
+ " '*.tsx'," ,
116
+ " ]," ,
117
+ " }," ,
118
+ " ]," ,
119
+ " parser: '@typescript-eslint/parser'," ,
120
+ " parserOptions: {" ,
121
+ " ecmaVersion: 'latest'," ,
122
+ " sourceType: 'module'," ,
123
+ " project: './tsconfig.json'," ,
124
+ " }," ,
125
+ " rules: {" ,
126
+ " }," ,
127
+ "}"
128
+ );
129
+
130
+ File tsconfigFile = setFile (testDir + "tsconfig.json" ).toResource (filedir + "tsconfig.json" );
131
+ final String dirtyFile = filedir + "typescript.dirty" ;
132
+ File dirtyFileFile = setFile (testDir + "test.ts" ).toResource (dirtyFile );
133
+ final String cleanFile = filedir + "typescript.clean" ;
144
134
145
- final FormatterStep formatterStep = PrettierFormatterStep.create(
146
- PrettierFormatterStep.defaultDevDependencies(),
147
- TestProvisioner.mavenCentral(),
148
- buildDir(),
149
- npmPathResolver(),
150
- new PrettierConfig(null, Collections.emptyMap()));
135
+ final FormatterStep formatterStep = EslintFormatterStep .create (
136
+ combine (EslintFormatterStep .PopularStyleGuide .XO_TYPESCRIPT .devDependencies (), EslintFormatterStep .defaultDevDependenciesForTypescript ()),
137
+ TestProvisioner .mavenCentral (),
138
+ projectDir (),
139
+ buildDir (),
140
+ npmPathResolver (),
141
+ new EslintTypescriptConfig (null , esLintConfig , tsconfigFile ));
151
142
152
143
try (StepHarnessWithFile stepHarness = StepHarnessWithFile .forStep (formatterStep )) {
153
- stepHarness.testResource(new File("test.json"), dirtyFile, cleanFile);
154
- }
155
- }
156
-
157
- @Test
158
- void verifyPrettierErrorMessageIsRelayed() throws Exception {
159
- FormatterStep formatterStep = PrettierFormatterStep.create(
160
- PrettierFormatterStep.defaultDevDependenciesWithPrettier("2.0.5"),
161
- TestProvisioner.mavenCentral(),
162
- buildDir(),
163
- npmPathResolver(),
164
- new PrettierConfig(null, ImmutableMap.of("parser", "postcss")));
165
- try (StepHarness stepHarness = StepHarness.forStep(formatterStep)) {
166
- stepHarness.testResourceException("npm/prettier/filetypes/scss/scss.dirty", exception -> {
167
- exception.hasMessageContaining("HTTP 501");
168
- exception.hasMessageContaining("Couldn't resolve parser \"postcss\"");
169
- });
144
+ stepHarness .testResource (dirtyFileFile , dirtyFile , cleanFile );
170
145
}
171
146
}
172
147
}
173
-
174
- @NpmTest
175
- @Nested
176
- class PrettierFormattingOptionsAreWorking extends NpmFormatterStepCommonTests {
177
-
178
- private static final String FILEDIR = "npm/prettier/config/";
179
-
180
- void runFormatTest(PrettierConfig config, String cleanFileNameSuffix) throws Exception {
181
-
182
- final String dirtyFile = FILEDIR + "typescript.dirty";
183
- final String cleanFile = FILEDIR + "typescript." + cleanFileNameSuffix + ".clean";
184
-
185
- final FormatterStep formatterStep = PrettierFormatterStep.create(
186
- PrettierFormatterStep.defaultDevDependencies(),
187
- TestProvisioner.mavenCentral(),
188
- buildDir(),
189
- npmPathResolver(),
190
- config); // should select parser based on this name
191
-
192
- try (StepHarness stepHarness = StepHarness.forStep(formatterStep)) {
193
- stepHarness.testResource(dirtyFile, cleanFile);
194
- }
195
- }
196
-
197
- @Test
198
- void defaultsAreApplied() throws Exception {
199
- runFormatTest(new PrettierConfig(null, ImmutableMap.of("parser", "typescript")), "defaults");
200
- }
201
-
202
- @Test
203
- void configFileOptionsAreApplied() throws Exception {
204
- runFormatTest(new PrettierConfig(createTestFile(FILEDIR + ".prettierrc.yml"), null), "configfile");
205
- }
206
-
207
- @Test
208
- void configFileOptionsCanBeOverriden() throws Exception {
209
- runFormatTest(new PrettierConfig(createTestFile(FILEDIR + ".prettierrc.yml"), ImmutableMap.of("printWidth", 300)), "override");
210
- }
211
-
212
- }*/
213
148
}
0 commit comments