@@ -157,28 +157,40 @@ export const areVersRangesValid = (
157
157
return rangesValid ;
158
158
} ;
159
159
160
+ export interface AuditDependenciesForInvalidRangeResponse {
161
+ hasInvalidRangeVersions : boolean ;
162
+ dependenciesWithInvalidVersionRange : string [ ] ;
163
+ dependenciesWithoutInvalidVersionRange : string [ ] ;
164
+ }
165
+
160
166
/**
161
167
* Determines if any dependencies have a version string that starts with the specified invalid range
162
- * @param { object } packageJsonData Valid JSON
163
- * @param { string } nodeName Name of a node in the package.json file
164
- * @param { string } rangeSpecifier A version range specifier
165
- * @param { object } config Rule configuration
166
- * @return { Boolean } True if any dependencies versions start with the invalid range, false if they don't.
168
+ * @param packageJsonData Valid JSON
169
+ * @param nodeName Name of a node in the package.json file
170
+ * @param rangeSpecifier A version range specifier
171
+ * @param config Rule configuration
172
+ * @return True if any dependencies versions start with the invalid range, false if they don't.
167
173
*/
168
- export const doVersContainInvalidRange = (
174
+ export const auditDependenciesForInvalidRange = (
169
175
// eslint-disable-next-line @typescript-eslint/no-explicit-any
170
176
packageJsonData : PackageJson | any ,
171
177
nodeName : string ,
172
178
rangeSpecifier : string ,
173
179
// eslint-disable-next-line @typescript-eslint/no-explicit-any
174
180
config : any
175
- ) : boolean => {
181
+ ) : AuditDependenciesForInvalidRangeResponse => {
182
+ let hasInvalidRangeVersions = false ;
183
+ const dependenciesWithInvalidVersionRange = [ ] ;
184
+ const dependenciesWithoutInvalidVersionRange = [ ] ;
185
+
176
186
if ( ! packageJsonData . hasOwnProperty ( nodeName ) ) {
177
- return false ;
187
+ return {
188
+ hasInvalidRangeVersions,
189
+ dependenciesWithInvalidVersionRange,
190
+ dependenciesWithoutInvalidVersionRange,
191
+ } ;
178
192
}
179
193
180
- let containsInvalidVersion = false ;
181
-
182
194
// eslint-disable-next-line no-restricted-syntax
183
195
for ( const dependencyName in packageJsonData [ nodeName ] ) {
184
196
if ( hasExceptions ( config ) && config . exceptions . includes ( dependencyName ) ) {
@@ -189,11 +201,18 @@ export const doVersContainInvalidRange = (
189
201
const dependencyVersion = packageJsonData [ nodeName ] [ dependencyName ] ;
190
202
191
203
if ( doesVersStartsWithRange ( dependencyVersion , rangeSpecifier ) ) {
192
- containsInvalidVersion = true ;
204
+ hasInvalidRangeVersions = true ;
205
+ dependenciesWithInvalidVersionRange . push ( dependencyName ) ;
206
+ } else {
207
+ dependenciesWithoutInvalidVersionRange . push ( dependencyName ) ;
193
208
}
194
209
}
195
210
196
- return containsInvalidVersion ;
211
+ return {
212
+ hasInvalidRangeVersions,
213
+ dependenciesWithInvalidVersionRange,
214
+ dependenciesWithoutInvalidVersionRange,
215
+ } ;
197
216
} ;
198
217
199
218
export interface AbsoluteVersionCheckerResult {
0 commit comments