@@ -71,19 +71,47 @@ function loadImmutabilityOverrides(
71
71
? overridesSetting
72
72
: overridesSetting . values ?? [ ] ;
73
73
74
- const upgraded = raw . map (
75
- ( { type, to, from } ) =>
76
- ( {
77
- type,
78
- to : typeof to === "string" ? Immutability [ to ] : to ,
79
- from :
80
- from === undefined
81
- ? undefined
82
- : typeof from === "string"
83
- ? Immutability [ from ]
84
- : from ,
85
- } ) as ImmutabilityOverrides [ number ] ,
86
- ) ;
74
+ const upgraded = raw . map ( ( rawValue ) => {
75
+ const { type, to, from, ...rest } = rawValue ;
76
+ const value = {
77
+ type,
78
+ to : typeof to === "string" ? Immutability [ to ] : to ,
79
+ from :
80
+ from === undefined
81
+ ? undefined
82
+ : typeof from === "string"
83
+ ? Immutability [ from ]
84
+ : from ,
85
+ } as ImmutabilityOverrides [ number ] ;
86
+
87
+ if ( value . type === undefined ) {
88
+ // eslint-disable-next-line functional/no-throw-statements
89
+ throw new Error (
90
+ `Override is missing required "type" property. Value: "${ JSON . stringify (
91
+ rawValue ,
92
+ ) } "`,
93
+ ) ;
94
+ }
95
+ if ( value . to === undefined ) {
96
+ // eslint-disable-next-line functional/no-throw-statements
97
+ throw new Error (
98
+ `Override is missing required "to" property. Value: "${ JSON . stringify (
99
+ rawValue ,
100
+ ) } "`,
101
+ ) ;
102
+ }
103
+ const restKeys = Object . keys ( rest ) ;
104
+ if ( restKeys . length > 0 ) {
105
+ // eslint-disable-next-line functional/no-throw-statements
106
+ throw new Error (
107
+ `Override is contains unknown property(s) "${ restKeys . join (
108
+ ", " ,
109
+ ) } ". Value: "${ JSON . stringify ( rawValue ) } "`,
110
+ ) ;
111
+ }
112
+
113
+ return value ;
114
+ } ) ;
87
115
88
116
const keepDefault =
89
117
Array . isArray ( overridesSetting ) || overridesSetting . keepDefault !== false ;
0 commit comments