@@ -135,9 +135,57 @@ void Configuration::load_from_json(Padded_String_View json,
135135 this ->report_json_error (json, out_diags);
136136 return ;
137137 }
138+
139+ auto jsx_mode = document[" jsx-mode" ];
140+ std::string_view jsx_mode_string;
141+ switch (jsx_mode.get (jsx_mode_string)) {
142+ case ::simdjson::error_code::SUCCESS: {
143+ if (jsx_mode_string == " auto" sv) {
144+ this ->jsx_mode = Parser_JSX_Mode::auto_detect;
145+ } else if (jsx_mode_string == " react" sv) {
146+ this ->jsx_mode = Parser_JSX_Mode::react;
147+ } else if (jsx_mode_string == " none" sv) {
148+ this ->jsx_mode = Parser_JSX_Mode::none;
149+ } else {
150+ ::simdjson::ondemand::value v;
151+ if (jsx_mode.get (v) == ::simdjson::SUCCESS) {
152+ out_diags->add (Diag_Config_JSX_Mode_Unrecognized{
153+ .value = span_of_json_value (v),
154+ });
155+ } else {
156+ this ->report_json_error (json, out_diags);
157+ }
158+ }
159+ break ;
160+ }
161+
162+ case ::simdjson::error_code::INCORRECT_TYPE: {
163+ // Either "jsx-mode" has the wrong type or there is a syntax error. simdjson
164+ // gives us INCORRECT_TYPE in both cases.
165+ ::simdjson::ondemand::value v;
166+ if (jsx_mode.get (v) == ::simdjson::SUCCESS &&
167+ v.type ().error () == ::simdjson::SUCCESS) {
168+ out_diags->add (Diag_Config_JSX_Mode_Type_Mismatch{
169+ .value = span_of_json_value (v),
170+ });
171+ } else {
172+ this ->report_json_error (json, out_diags);
173+ return ;
174+ }
175+ break ;
176+ }
177+
178+ case ::simdjson::error_code::NO_SUCH_FIELD:
179+ break ;
180+
181+ default :
182+ this ->report_json_error (json, out_diags);
183+ return ;
184+ }
138185}
139186
140187void Configuration::reset () {
188+ this ->jsx_mode = Parser_JSX_Mode::auto_detect;
141189 this ->globals_ .clear ();
142190 this ->globals_to_remove_ .clear ();
143191 this ->did_add_globals_from_groups_ = false ;
0 commit comments