Skip to content

Commit fc8e962

Browse files
authored
Format jscomp/common (#6806)
1 parent ccb0589 commit fc8e962

File tree

7 files changed

+48
-50
lines changed

7 files changed

+48
-50
lines changed

jscomp/common/.ocamlformat

Lines changed: 0 additions & 1 deletion
This file was deleted.

jscomp/common/bs_loc.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525
type t = Location.t = {
26-
loc_start : Lexing.position;
27-
loc_end : Lexing.position;
28-
loc_ghost : bool;
26+
loc_start: Lexing.position;
27+
loc_end: Lexing.position;
28+
loc_ghost: bool;
2929
}
3030

3131
let is_ghost x = x.loc_ghost
@@ -35,7 +35,7 @@ let merge (l : t) (r : t) =
3535
else if is_ghost r then l
3636
else
3737
match (l, r) with
38-
| { loc_start; _ }, { loc_end; _ } (* TODO: improve*) ->
39-
{ loc_start; loc_end; loc_ghost = false }
38+
| {loc_start; _}, {loc_end; _} (* TODO: improve*) ->
39+
{loc_start; loc_end; loc_ghost = false}
4040

4141
(* let none = Location.none *)

jscomp/common/bs_loc.mli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
2424

2525
type t = Location.t = {
26-
loc_start : Lexing.position;
27-
loc_end : Lexing.position;
28-
loc_ghost : bool;
26+
loc_start: Lexing.position;
27+
loc_end: Lexing.position;
28+
loc_ghost: bool;
2929
}
3030

3131
(* val is_ghost : t -> bool *)

jscomp/common/ext_log.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let dwarn ?(__POS__ : (string * int * int * int) option) f =
3030
match __POS__ with
3131
| None -> Format.fprintf Format.err_formatter ("WARN: " ^^ f ^^ "@.")
3232
| Some (file, line, _, _) ->
33-
Format.fprintf Format.err_formatter
34-
("WARN: %s,%d " ^^ f ^^ "@.")
35-
file line
33+
Format.fprintf Format.err_formatter
34+
("WARN: %s,%d " ^^ f ^^ "@.")
35+
file line
3636
else Format.ifprintf Format.err_formatter ("WARN: " ^^ f ^^ "@.")

jscomp/common/js_config.ml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,33 +58,33 @@ let no_export = ref false
5858
let as_ppx = ref false
5959

6060
let int_of_jsx_version = function
61-
| Jsx_v3 -> 3
62-
| Jsx_v4 -> 4
61+
| Jsx_v3 -> 3
62+
| Jsx_v4 -> 4
6363

6464
let string_of_jsx_module = function
65-
| React -> "react"
66-
| Generic {module_name} -> module_name
65+
| React -> "react"
66+
| Generic {module_name} -> module_name
6767

6868
let string_of_jsx_mode = function
69-
| Classic -> "classic"
70-
| Automatic -> "automatic"
69+
| Classic -> "classic"
70+
| Automatic -> "automatic"
7171

7272
let jsx_version_of_int = function
73-
| 3 -> Some Jsx_v3
74-
| 4 -> Some Jsx_v4
75-
| _ -> None
73+
| 3 -> Some Jsx_v3
74+
| 4 -> Some Jsx_v4
75+
| _ -> None
7676

7777
let jsx_module_of_string = function
78-
| "react" -> React
79-
| module_name -> Generic {module_name}
78+
| "react" -> React
79+
| module_name -> Generic {module_name}
8080

8181
let jsx_mode_of_string = function
82-
| "classic" -> Classic
83-
| "automatic" -> Automatic
84-
| _ -> Classic
82+
| "classic" -> Classic
83+
| "automatic" -> Automatic
84+
| _ -> Classic
8585

8686
(* option to config `@rescript/std`*)
8787
let customize_runtime : string option ref = ref None
8888
let as_pp = ref false
8989
let self_stack : string Stack.t = Stack.create ()
90-
let modules = ref false
90+
let modules = ref false

jscomp/common/js_config.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ val force_cmj : bool ref
7979

8080
val jsx_version : jsx_version option ref
8181

82-
val jsx_module: jsx_module ref
82+
val jsx_module : jsx_module ref
8383

84-
val jsx_mode: jsx_mode ref
84+
val jsx_mode : jsx_mode ref
8585

8686
val js_stdout : bool ref
8787

jscomp/common/pattern_printer.ml

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,35 @@ let mkpat desc = Ast_helper.Pat.mk desc
77
let untype typed =
88
let rec loop pat =
99
match pat.pat_desc with
10-
| Tpat_or (p1, { pat_desc = Tpat_or (p2, p3, r_i) }, r_o) ->
10+
| Tpat_or (p1, {pat_desc = Tpat_or (p2, p3, r_i)}, r_o) ->
1111
(* Turn A | (B | C) into (A | B) | C for pretty printing without parens *)
12-
let new_inner = { pat with pat_desc = Tpat_or (p1, p2, r_i) } in
13-
let new_outer = { pat with pat_desc = Tpat_or (new_inner, p3, r_o) } in
14-
loop new_outer
12+
let new_inner = {pat with pat_desc = Tpat_or (p1, p2, r_i)} in
13+
let new_outer = {pat with pat_desc = Tpat_or (new_inner, p3, r_o)} in
14+
loop new_outer
1515
| Tpat_or (pa, pb, _) -> mkpat (Ppat_or (loop pa, loop pb))
1616
| Tpat_any | Tpat_var _ -> mkpat Ppat_any
1717
| Tpat_constant c -> mkpat (Ppat_constant (Untypeast.constant c))
1818
| Tpat_alias (p, _, _) -> loop p
1919
| Tpat_tuple lst -> mkpat (Ppat_tuple (List.map loop lst))
2020
| Tpat_construct (cstr_lid, cstr, lst) ->
21-
let lid = { cstr_lid with txt = Longident.Lident cstr.cstr_name } in
22-
let arg =
23-
match List.map loop lst with
24-
| [] -> None
25-
| [ p ] -> Some p
26-
| lst -> Some (mkpat (Ppat_tuple lst))
27-
in
28-
mkpat (Ppat_construct (lid, arg))
21+
let lid = {cstr_lid with txt = Longident.Lident cstr.cstr_name} in
22+
let arg =
23+
match List.map loop lst with
24+
| [] -> None
25+
| [p] -> Some p
26+
| lst -> Some (mkpat (Ppat_tuple lst))
27+
in
28+
mkpat (Ppat_construct (lid, arg))
2929
| Tpat_variant (label, p_opt, _row_desc) ->
30-
let arg = Option.map loop p_opt in
31-
mkpat (Ppat_variant (label, arg))
30+
let arg = Option.map loop p_opt in
31+
mkpat (Ppat_variant (label, arg))
3232
| Tpat_record (subpatterns, closed_flag) ->
33-
let fields =
34-
List.map
35-
(fun (_, lbl, p) ->
36-
(mknoloc (Longident.Lident lbl.lbl_name), loop p))
37-
subpatterns
38-
in
39-
mkpat (Ppat_record (fields, closed_flag))
33+
let fields =
34+
List.map
35+
(fun (_, lbl, p) -> (mknoloc (Longident.Lident lbl.lbl_name), loop p))
36+
subpatterns
37+
in
38+
mkpat (Ppat_record (fields, closed_flag))
4039
| Tpat_array lst -> mkpat (Ppat_array (List.map loop lst))
4140
| Tpat_lazy p -> mkpat (Ppat_lazy (loop p))
4241
in

0 commit comments

Comments
 (0)