11use std:: fmt;
22use std:: fs;
33use std:: path:: { Path , PathBuf } ;
4+ use std:: collections:: HashMap ;
5+ use serde_json:: Value ;
46use log:: { debug, error, trace} ;
57use serde:: { Deserialize , Serialize } ;
68use rules:: { instantiate_rules, CurrentRules , RuleType } ;
@@ -31,6 +33,10 @@ pub fn parse_lint_cfg(path: PathBuf) -> Result<LintCfg, String> {
3133pub fn maybe_parse_lint_cfg ( path : PathBuf ) -> Option < LintCfg > {
3234 match parse_lint_cfg ( path) {
3335 Ok ( mut cfg) => {
36+ if !cfg. unknown_fields . is_empty ( ) {
37+ // Log the unknown fields as a comma-separated list
38+ error ! ( "Unknown lint config fields: {}" , cfg. unknown_fields. keys( ) . cloned( ) . collect:: <Vec <_>>( ) . join( ", " ) ) ;
39+ }
3440 setup_indentation_size ( & mut cfg) ;
3541 Some ( cfg)
3642 } ,
@@ -43,8 +49,9 @@ pub fn maybe_parse_lint_cfg(path: PathBuf) -> Option<LintCfg> {
4349
4450#[ derive( Clone , Debug , Serialize , Deserialize , PartialEq ) ]
4551#[ serde( default ) ]
46- #[ serde( deny_unknown_fields) ]
4752pub struct LintCfg {
53+ #[ serde( flatten) ]
54+ pub unknown_fields : HashMap < String , Value > ,
4855 #[ serde( default ) ]
4956 pub sp_brace : Option < SpBraceOptions > ,
5057 #[ serde( default ) ]
@@ -84,6 +91,7 @@ fn get_true() -> bool {
8491impl Default for LintCfg {
8592 fn default ( ) -> LintCfg {
8693 LintCfg {
94+ unknown_fields : HashMap :: new ( ) ,
8795 sp_brace : Some ( SpBraceOptions { } ) ,
8896 sp_punct : Some ( SpPunctOptions { } ) ,
8997 nsp_funpar : Some ( NspFunparOptions { } ) ,
0 commit comments