@@ -157,28 +157,40 @@ export const areVersRangesValid = (
157157 return rangesValid ;
158158} ;
159159
160+ export interface AuditDependenciesForInvalidRangeResponse {
161+ hasInvalidRangeVersions : boolean ;
162+ dependenciesWithInvalidVersionRange : string [ ] ;
163+ dependenciesWithoutInvalidVersionRange : string [ ] ;
164+ }
165+
160166/**
161167 * 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.
167173 */
168- export const doVersContainInvalidRange = (
174+ export const auditDependenciesForInvalidRange = (
169175 // eslint-disable-next-line @typescript-eslint/no-explicit-any
170176 packageJsonData : PackageJson | any ,
171177 nodeName : string ,
172178 rangeSpecifier : string ,
173179 // eslint-disable-next-line @typescript-eslint/no-explicit-any
174180 config : any
175- ) : boolean => {
181+ ) : AuditDependenciesForInvalidRangeResponse => {
182+ let hasInvalidRangeVersions = false ;
183+ const dependenciesWithInvalidVersionRange = [ ] ;
184+ const dependenciesWithoutInvalidVersionRange = [ ] ;
185+
176186 if ( ! packageJsonData . hasOwnProperty ( nodeName ) ) {
177- return false ;
187+ return {
188+ hasInvalidRangeVersions,
189+ dependenciesWithInvalidVersionRange,
190+ dependenciesWithoutInvalidVersionRange,
191+ } ;
178192 }
179193
180- let containsInvalidVersion = false ;
181-
182194 // eslint-disable-next-line no-restricted-syntax
183195 for ( const dependencyName in packageJsonData [ nodeName ] ) {
184196 if ( hasExceptions ( config ) && config . exceptions . includes ( dependencyName ) ) {
@@ -189,11 +201,18 @@ export const doVersContainInvalidRange = (
189201 const dependencyVersion = packageJsonData [ nodeName ] [ dependencyName ] ;
190202
191203 if ( doesVersStartsWithRange ( dependencyVersion , rangeSpecifier ) ) {
192- containsInvalidVersion = true ;
204+ hasInvalidRangeVersions = true ;
205+ dependenciesWithInvalidVersionRange . push ( dependencyName ) ;
206+ } else {
207+ dependenciesWithoutInvalidVersionRange . push ( dependencyName ) ;
193208 }
194209 }
195210
196- return containsInvalidVersion ;
211+ return {
212+ hasInvalidRangeVersions,
213+ dependenciesWithInvalidVersionRange,
214+ dependenciesWithoutInvalidVersionRange,
215+ } ;
197216} ;
198217
199218export interface AbsoluteVersionCheckerResult {
0 commit comments