File tree Expand file tree Collapse file tree 6 files changed +23
-4
lines changed
Expand file tree Collapse file tree 6 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,15 @@ use project_root::get_project_root;
88#[ test]
99fn test_schema_json ( ) {
1010 let path = get_project_root ( ) . unwrap ( ) . join ( "npm/oxfmt/configuration_schema.json" ) ;
11- let schema = schemars:: schema_for!( Oxfmtrc ) ;
11+ let mut schema = schemars:: schema_for!( Oxfmtrc ) ;
12+ // Allow comments and trailing commas for vscode-json-languageservice
13+ // NOTE: This is NOT part of standard JSON Schema specification
14+ // https://github.com/microsoft/vscode-json-languageservice/blob/fb83547762901f32d8449d57e24666573016b10c/src/jsonLanguageTypes.ts#L151-L159
15+ schema. schema . extensions . insert ( "allowComments" . to_string ( ) , serde_json:: Value :: Bool ( true ) ) ;
16+ schema
17+ . schema
18+ . extensions
19+ . insert ( "allowTrailingCommas" . to_string ( ) , serde_json:: Value :: Bool ( true ) ) ;
1220 let json = serde_json:: to_string_pretty ( & schema) . unwrap ( ) ;
1321 let existing_json = fs:: read_to_string ( & path) . unwrap_or_default ( ) ;
1422 if existing_json. trim ( ) != json. trim ( ) {
Original file line number Diff line number Diff line change @@ -174,6 +174,8 @@ expression: json
174174 ]
175175 }
176176 },
177+ " allowComments" : true ,
178+ " allowTrailingCommas" : true ,
177179 " definitions" : {
178180 " ArrowParensConfig" : {
179181 " type" : " string" ,
Original file line number Diff line number Diff line change @@ -204,9 +204,14 @@ impl Oxlintrc {
204204 /// Panics if the schema generation fails.
205205 pub fn generate_schema_json ( ) -> String {
206206 let mut schema = schema_for ! ( Oxlintrc ) ;
207- // setting `allowComments` to true to allow comments in JSON schema files
208- // https://github.com/microsoft/vscode-json-languageservice/blob/356d5dd980d49c6ac09ec8446614a6f94016dcea/src/jsonLanguageTypes.ts#L127-L131
207+ // Allow comments and trailing commas for vscode-json-languageservice
208+ // NOTE: This is NOT part of standard JSON Schema specification
209+ // https://github.com/microsoft/vscode-json-languageservice/blob/fb83547762901f32d8449d57e24666573016b10c/src/jsonLanguageTypes.ts#L151-L159
209210 schema. schema . extensions . insert ( "allowComments" . to_string ( ) , serde_json:: Value :: Bool ( true ) ) ;
211+ schema
212+ . schema
213+ . extensions
214+ . insert ( "allowTrailingCommas" . to_string ( ) , serde_json:: Value :: Bool ( true ) ) ;
210215 serde_json:: to_string_pretty ( & schema) . unwrap ( )
211216 }
212217
Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ expression: json
127127 }
128128 },
129129 " allowComments" : true ,
130+ " allowTrailingCommas" : true ,
130131 " definitions" : {
131132 " AllowWarnDeny" : {
132133 " oneOf" : [
Original file line number Diff line number Diff line change 170170 ]
171171 }
172172 },
173+ "allowComments" : true ,
174+ "allowTrailingCommas" : true ,
173175 "definitions" : {
174176 "ArrowParensConfig" : {
175177 "type" : " string" ,
Original file line number Diff line number Diff line change 123123 }
124124 },
125125 "allowComments" : true ,
126+ "allowTrailingCommas" : true ,
126127 "definitions" : {
127128 "AllowWarnDeny" : {
128129 "oneOf" : [
620621 }
621622 }
622623 }
623- }
624+ }
You can’t perform that action at this time.
0 commit comments