Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

on:
pull_request:
branches:
- master
- main
push:
branches:
- master
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Nix
uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Build project
run: nix build

- name: Run tests
run: nix flake check
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# ReScript Linter Changelog

### 2026-01-27 - v0.4.0
* Updated the AST to ReScript v12.1.0

### 2025-09-30 - v0.3.3
* Adds support for JSON output
* To enable JSON output, use the `--json` flag when running the linter
Expand Down
10 changes: 5 additions & 5 deletions jscomp/common/bs_loc.ml → compiler/common/bs_loc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type t = Location.t = {
loc_start : Lexing.position;
loc_end : Lexing.position;
loc_ghost : bool;
loc_start: Lexing.position;
loc_end: Lexing.position;
loc_ghost: bool;
}

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

(* let none = Location.none *)
6 changes: 3 additions & 3 deletions jscomp/common/bs_loc.mli → compiler/common/bs_loc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type t = Location.t = {
loc_start : Lexing.position;
loc_end : Lexing.position;
loc_ghost : bool;
loc_start: Lexing.position;
loc_end: Lexing.position;
loc_ghost: bool;
}

(* val is_ghost : t -> bool *)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
let version = "11.1.4"
let version = "12.1.0"
let header = "// Generated by ReScript, PLEASE EDIT WITH CARE"
let package_name = ref "rescript"
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@
val version : string

val header : string

val package_name : string ref
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

let warn_missing_primitive loc txt =
Location.prerr_warning loc (Bs_unimplemented_primitive txt)

let warn_literal_overflow loc =
Location.prerr_warning loc Bs_integer_literal_overflow

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

val warn_missing_primitive : Location.t -> string -> unit

val warn_literal_overflow : Location.t -> unit

val error_unescaped_delimiter : Location.t -> string -> unit
9 changes: 9 additions & 0 deletions compiler/common/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library
(name common)
(wrapped false)
(preprocess
(action
(run %{bin:cppo} %{env:CPPO_FLAGS=} %{input-file})))
(flags
(:standard -w +a-9-40-42))
(libraries syntax))
6 changes: 3 additions & 3 deletions jscomp/common/ext_log.ml → compiler/common/ext_log.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let dwarn ?(__POS__ : (string * int * int * int) option) f =
match __POS__ with
| None -> Format.fprintf Format.err_formatter ("WARN: " ^^ f ^^ "@.")
| Some (file, line, _, _) ->
Format.fprintf Format.err_formatter
("WARN: %s,%d " ^^ f ^^ "@.")
file line
Format.fprintf Format.err_formatter
("WARN: %s,%d " ^^ f ^^ "@.")
file line
else Format.ifprintf Format.err_formatter ("WARN: " ^^ f ^^ "@.")
File renamed without changes.
37 changes: 10 additions & 27 deletions jscomp/common/js_config.ml → compiler/common/js_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@

(** Browser is not set via command line only for internal use *)

type jsx_version = Jsx_v3 | Jsx_v4
type jsx_module = React | Generic of {moduleName: string}
type jsx_mode = Classic | Automatic
type jsx_version = Jsx_v4
type jsx_module = React | Generic of {module_name: string}

let no_version_header = ref false

Expand All @@ -51,41 +50,25 @@ let force_cmi = ref false
let force_cmj = ref false
let jsx_version = ref None
let jsx_module = ref React
let jsx_mode = ref Automatic
let jsx_preserve = ref false
let js_stdout = ref true
let all_module_aliases = ref false
let no_stdlib = ref false
let no_export = ref false
let as_ppx = ref false

let int_of_jsx_version = function
| Jsx_v3 -> 3
| Jsx_v4 -> 4
| Jsx_v4 -> 4

let string_of_jsx_module = function
| React -> "react"
| Generic {moduleName} -> moduleName

let string_of_jsx_mode = function
| Classic -> "classic"
| Automatic -> "automatic"
| React -> "react"
| Generic {module_name} -> module_name

let jsx_version_of_int = function
| 3 -> Some Jsx_v3
| 4 -> Some Jsx_v4
| _ -> None
| 4 -> Some Jsx_v4
| _ -> None

let jsx_module_of_string = function
| "react" -> React
| moduleName -> Generic {moduleName}

let jsx_mode_of_string = function
| "classic" -> Classic
| "automatic" -> Automatic
| _ -> Classic
| "react" -> React
| module_name -> Generic {module_name}

(* option to config `@rescript/std`*)
let customize_runtime : string option ref = ref None
let as_pp = ref false
let self_stack : string Stack.t = Stack.create ()
let modules = ref false
19 changes: 4 additions & 15 deletions jscomp/common/js_config.mli → compiler/common/js_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type jsx_version = Jsx_v3 | Jsx_v4
type jsx_module = React | Generic of {moduleName: string}
type jsx_mode = Classic | Automatic
type jsx_version = Jsx_v4
type jsx_module = React | Generic of {module_name: string}

(* val get_packages_info :
unit -> Js_packages_info.t *)
Expand Down Expand Up @@ -79,9 +78,9 @@ val force_cmj : bool ref

val jsx_version : jsx_version option ref

val jsx_module: jsx_module ref
val jsx_module : jsx_module ref

val jsx_mode: jsx_mode ref
val jsx_preserve : bool ref

val js_stdout : bool ref

Expand All @@ -91,24 +90,14 @@ val no_stdlib : bool ref

val no_export : bool ref

val as_ppx : bool ref

val int_of_jsx_version : jsx_version -> int

val string_of_jsx_module : jsx_module -> string

val string_of_jsx_mode : jsx_mode -> string

val jsx_version_of_int : int -> jsx_version option

val jsx_module_of_string : string -> jsx_module

val jsx_mode_of_string : string -> jsx_mode

val customize_runtime : string option ref

val as_pp : bool ref

val self_stack : string Stack.t

val modules : bool ref
57 changes: 57 additions & 0 deletions compiler/common/ml_binary.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

type _ kind = Ml : Parsetree.structure kind | Mli : Parsetree.signature kind

type ast0 = Impl of Parsetree0.structure | Intf of Parsetree0.signature

let magic_of_ast0 : ast0 -> string = function
| Impl _ -> Config.ast_impl_magic_number
| Intf _ -> Config.ast_intf_magic_number

let to_ast0 : type a. a kind -> a -> ast0 =
fun kind ast ->
match kind with
| Ml ->
Impl
(Ast_mapper_to0.default_mapper.structure Ast_mapper_to0.default_mapper ast)
| Mli ->
Intf
(Ast_mapper_to0.default_mapper.signature Ast_mapper_to0.default_mapper ast)

let ast0_to_structure : ast0 -> Parsetree.structure = function
| Impl str0 ->
Ast_mapper_from0.default_mapper.structure Ast_mapper_from0.default_mapper
str0
| Intf _ -> assert false

let ast0_to_signature : ast0 -> Parsetree.signature = function
| Impl _ -> assert false
| Intf sig0 ->
Ast_mapper_from0.default_mapper.signature Ast_mapper_from0.default_mapper
sig0

let magic_of_kind : type a. a kind -> string = function
| Ml -> Config.ast_impl_magic_number
| Mli -> Config.ast_intf_magic_number
8 changes: 5 additions & 3 deletions jscomp/common/ml_binary.mli → compiler/common/ml_binary.mli
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
*)
type _ kind = Ml : Parsetree.structure kind | Mli : Parsetree.signature kind

val read_ast : 'a kind -> in_channel -> 'a

val write_ast : 'a kind -> string -> 'a -> out_channel -> unit
type ast0 = Impl of Parsetree0.structure | Intf of Parsetree0.signature

val magic_of_kind : 'a kind -> string
val magic_of_ast0 : ast0 -> string
val to_ast0 : 'a kind -> 'a -> ast0
val ast0_to_structure : ast0 -> Parsetree.structure
val ast0_to_signature : ast0 -> Parsetree.signature
Loading