@@ -201,6 +201,46 @@ TEST_F(Test_CLI, automatically_find_config_file_given_path_for_config_search) {
201201 EXPECT_EQ (r.exit_status , 0 );
202202}
203203
204+ TEST_F (Test_CLI, path_for_config_search_affects_stdin_file) {
205+ std::string test_directory = this ->make_temporary_directory ();
206+ std::string config_file = test_directory + " /quick-lint-js.config" ;
207+ write_file_or_exit (config_file,
208+ u8R"( {"globals":{"myGlobalVariable": true}})" _sv);
209+
210+ Run_Program_Result r = run_program (
211+ {
212+ get_quick_lint_js_executable_path (),
213+ " --path-for-config-search" ,
214+ test_directory + " /app.js" ,
215+ " --stdin" ,
216+ },
217+ Run_Program_Options{
218+ .input = u8" console.log(myGlobalVariable);" _sv,
219+ });
220+ EXPECT_EQ (r.output , u8" " _sv);
221+ EXPECT_EQ (r.exit_status , 0 );
222+ }
223+
224+ TEST_F (Test_CLI, path_for_stdin_affects_stdin_file_config_search) {
225+ std::string test_directory = this ->make_temporary_directory ();
226+ std::string config_file = test_directory + " /quick-lint-js.config" ;
227+ write_file_or_exit (config_file,
228+ u8R"( {"globals":{"myGlobalVariable": true}})" _sv);
229+
230+ Run_Program_Result r = run_program (
231+ {
232+ get_quick_lint_js_executable_path (),
233+ " --stdin-path" ,
234+ test_directory + " /app.js" ,
235+ " --stdin" ,
236+ },
237+ Run_Program_Options{
238+ .input = u8" console.log(myGlobalVariable);" _sv,
239+ });
240+ EXPECT_EQ (r.output , u8" " _sv);
241+ EXPECT_EQ (r.exit_status , 0 );
242+ }
243+
204244TEST_F (Test_CLI, config_file_parse_error_prevents_lint) {
205245 std::string test_directory = this ->make_temporary_directory ();
206246
@@ -273,6 +313,50 @@ TEST_F(Test_CLI, errors_for_all_config_files_are_printed) {
273313 << r.output ;
274314}
275315
316+ TEST_F (Test_CLI, path_for_stdin_affects_default_language) {
317+ {
318+ Run_Program_Result r = run_program (
319+ {get_quick_lint_js_executable_path (), " --language=experimental-default" ,
320+ " --stdin" , " --stdin-path=hello.js" },
321+ Run_Program_Options{
322+ .input = u8" interface I {}" _sv,
323+ });
324+ EXPECT_EQ (r.exit_status , 1 );
325+ EXPECT_THAT (to_string (r.output .string_view ()), HasSubstr (" E0213" ))
326+ << " expected \" TypeScript's 'interface' feature is not allowed in "
327+ " JavaScript code\"\n "
328+ << r.output ;
329+ }
330+
331+ {
332+ Run_Program_Result r = run_program (
333+ {get_quick_lint_js_executable_path (), " --language=experimental-default" ,
334+ " --stdin" , " --stdin-path=hello.ts" },
335+ Run_Program_Options{
336+ .input = u8" interface I {}" _sv,
337+ });
338+ EXPECT_EQ (r.exit_status , 0 );
339+ EXPECT_THAT (to_string (r.output .string_view ()), Not (HasSubstr (" E0213" )))
340+ << " expected no diagnostics because file should be interpreted as "
341+ " TypeScript\n "
342+ << r.output ;
343+ }
344+ }
345+
346+ TEST_F (Test_CLI, language_overrides_path_for_stdin) {
347+ Run_Program_Result r = run_program ({get_quick_lint_js_executable_path (),
348+ " --language=experimental-typescript" ,
349+ " --stdin" , " --stdin-path=hello.js" },
350+ Run_Program_Options{
351+ .input = u8" interface I {}" _sv,
352+ });
353+ EXPECT_EQ (r.exit_status , 0 );
354+ EXPECT_THAT (to_string (r.output .string_view ()), Not (HasSubstr (" E0213" )))
355+ << " expected no diagnostics because file should be interpreted as "
356+ " TypeScript\n "
357+ << r.output ;
358+ }
359+
276360TEST_F (Test_CLI, language_javascript) {
277361 Run_Program_Result r = run_program (
278362 {get_quick_lint_js_executable_path (), " --language=javascript" , " --stdin" },
0 commit comments