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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#### :bug: Bug fix

- Reanalyze: make optional args analysis liveness-aware, preventing false positives when functions are only called from dead code. https://github.com/rescript-lang/rescript/pull/8082
- Fix: do not warn for "editor" field in `rescript.json`. https://github.com/rescript-lang/rescript/pull/8084

#### :memo: Documentation

Expand Down
2 changes: 1 addition & 1 deletion rewatch/CompilerConfigurationSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ This document contains a list of all bsconfig parameters with remarks, and wheth

| Parameter | JSON type | Remark | Implemented? |
| --------------------- | ----------------------- | ------ | :----------: |
| version | string | | [_] |
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version field is unused

| name | string | | [x] |
| namespace | boolean | | [x] |
| namespace | string | | [x] |
Expand Down Expand Up @@ -33,6 +32,7 @@ This document contains a list of all bsconfig parameters with remarks, and wheth
| suffix | Suffix | | [x] |
| reanalyze | Reanalyze | | [_] |
| experimental-features | ExperimentalFeatures | | [x] |
| editor | object | VS Code tooling only; ignored by rewatch | [x] |

### Source

Expand Down
27 changes: 26 additions & 1 deletion rewatch/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,9 @@ pub struct Config {
pub experimental_features: Option<HashMap<ExperimentalFeature, bool>>,
#[serde(rename = "gentypeconfig")]
pub gentype_config: Option<GenTypeConfig>,
// Used by the VS Code extension; ignored by rewatch but should not emit warnings.
// Payload is not validated here, only in the VS Code extension.
pub editor: Option<serde_json::Value>,
// this is a new feature of rewatch, and it's not part of the rescript.json spec
#[serde(rename = "namespace-entry")]
pub namespace_entry: Option<String>,
Expand Down Expand Up @@ -698,7 +701,6 @@ impl Config {

fn is_unsupported_field(&self, field: &str) -> bool {
const UNSUPPORTED_TOP_LEVEL_FIELDS: &[&str] = &[
"version",
"ignored-dirs",
"generators",
"cut-generators",
Expand Down Expand Up @@ -779,6 +781,7 @@ pub mod tests {
namespace: None,
jsx: None,
gentype_config: None,
editor: None,
namespace_entry: None,
deprecation_warnings: vec![],
experimental_features: None,
Expand Down Expand Up @@ -1114,6 +1117,28 @@ pub mod tests {
assert!(config.get_unknown_fields().is_empty());
}

#[test]
fn test_editor_field_supported() {
let json = r#"
{
"name": "testrepo",
"sources": {
"dir": "src",
"subdirs": true
},
"editor": {
"reason": {
"profile": "development"
}
}
}
"#;

let config = Config::new_from_json_string(json).expect("a valid json string");
assert!(config.get_unsupported_fields().is_empty());
assert!(config.get_unknown_fields().is_empty());
}

#[test]
fn test_compiler_flags() {
let json = r#"
Expand Down
Loading