WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 14721cb

Browse files
authored
Fix rewatch warning for rescript.json "editor" field (#8084)
* Fix rewatch warning for rescript.json "editor" field * CHANGELOG # Conflicts: # CHANGELOG.md
1 parent a1adb9c commit 14721cb

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#### :bug: Bug fix
2222

2323
- 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
24+
- Fix: do not warn for "editor" field in `rescript.json`. https://github.com/rescript-lang/rescript/pull/8084
2425

2526
#### :memo: Documentation
2627

rewatch/CompilerConfigurationSpec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ This document contains a list of all bsconfig parameters with remarks, and wheth
44

55
| Parameter | JSON type | Remark | Implemented? |
66
| --------------------- | ----------------------- | ------ | :----------: |
7-
| version | string | | [_] |
87
| name | string | | [x] |
98
| namespace | boolean | | [x] |
109
| namespace | string | | [x] |
@@ -33,6 +32,7 @@ This document contains a list of all bsconfig parameters with remarks, and wheth
3332
| suffix | Suffix | | [x] |
3433
| reanalyze | Reanalyze | | [_] |
3534
| experimental-features | ExperimentalFeatures | | [x] |
35+
| editor | object | VS Code tooling only; ignored by rewatch | [x] |
3636

3737
### Source
3838

rewatch/src/config.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ pub struct Config {
297297
pub experimental_features: Option<HashMap<ExperimentalFeature, bool>>,
298298
#[serde(rename = "gentypeconfig")]
299299
pub gentype_config: Option<GenTypeConfig>,
300+
// Used by the VS Code extension; ignored by rewatch but should not emit warnings.
301+
// Payload is not validated here, only in the VS Code extension.
302+
pub editor: Option<serde_json::Value>,
300303
// this is a new feature of rewatch, and it's not part of the rescript.json spec
301304
#[serde(rename = "namespace-entry")]
302305
pub namespace_entry: Option<String>,
@@ -698,7 +701,6 @@ impl Config {
698701

699702
fn is_unsupported_field(&self, field: &str) -> bool {
700703
const UNSUPPORTED_TOP_LEVEL_FIELDS: &[&str] = &[
701-
"version",
702704
"ignored-dirs",
703705
"generators",
704706
"cut-generators",
@@ -779,6 +781,7 @@ pub mod tests {
779781
namespace: None,
780782
jsx: None,
781783
gentype_config: None,
784+
editor: None,
782785
namespace_entry: None,
783786
deprecation_warnings: vec![],
784787
experimental_features: None,
@@ -1114,6 +1117,28 @@ pub mod tests {
11141117
assert!(config.get_unknown_fields().is_empty());
11151118
}
11161119

1120+
#[test]
1121+
fn test_editor_field_supported() {
1122+
let json = r#"
1123+
{
1124+
"name": "testrepo",
1125+
"sources": {
1126+
"dir": "src",
1127+
"subdirs": true
1128+
},
1129+
"editor": {
1130+
"reason": {
1131+
"profile": "development"
1132+
}
1133+
}
1134+
}
1135+
"#;
1136+
1137+
let config = Config::new_from_json_string(json).expect("a valid json string");
1138+
assert!(config.get_unsupported_fields().is_empty());
1139+
assert!(config.get_unknown_fields().is_empty());
1140+
}
1141+
11171142
#[test]
11181143
fn test_compiler_flags() {
11191144
let json = r#"

0 commit comments

Comments
 (0)