@@ -4,7 +4,7 @@ import spdxSatisfies from 'spdx-satisfies';
4
4
5
5
type License = string ;
6
6
7
- type PackageID = string ;
7
+ type PackageID = string | RegExp ;
8
8
9
9
// List of licenses considered valid and acceptable for use.
10
10
const licensesWhitelist : License [ ] = [
@@ -57,7 +57,7 @@ const ignoredPackages: PackageID[] = [
57
57
'gitconfiglocal@1.0.0' ,
58
58
59
59
// https://github.com/streetsidesoftware/cspell-dicts/blob/main/dictionaries/en-common-misspellings/LICENSE
60
- ' @cspell/dict-en-common-misspellings@2.0.4'
60
+ / ^ @ c s p e l l \ /d i c t - e n - c o m m o n - m i s s p e l l i n g s @ . * $ /
61
61
] ;
62
62
63
63
// Normalizes the license string to a standard SPDX identifier, handling possible asterisks from guessed licenses.
@@ -90,6 +90,18 @@ const enum ReturnCode {
90
90
InvalidLicense = 2
91
91
}
92
92
93
+ const isLicenseIgnored = ( packageID : string ) : boolean => {
94
+ return ignoredPackages . some ( ( ignoredPackageID ) => {
95
+ if ( typeof ignoredPackageID === 'string' ) {
96
+ return packageID === ignoredPackageID ;
97
+ } else if ( ignoredPackageID instanceof RegExp ) {
98
+ return ignoredPackageID . test ( packageID ) ;
99
+ }
100
+
101
+ return false ;
102
+ } ) ;
103
+ } ;
104
+
93
105
// Main function that initializes the license checker and processes the results.
94
106
async function validateLicense ( ) : Promise < ReturnCode > {
95
107
try {
@@ -111,7 +123,7 @@ async function validateLicense(): Promise<ReturnCode> {
111
123
? json [ key ] . licenses . map ( normalizeLicense )
112
124
: [ normalizeLicense ( json [ key ] . licenses ) ]
113
125
} ) )
114
- . filter ( ( pkg ) => ! ignoredPackages . includes ( pkg . id ) )
126
+ . filter ( ( pkg ) => ! isLicenseIgnored ( pkg . id ) )
115
127
. filter ( ( pkg ) => ! isLicenseValid ( pkg . licenses ) ) ;
116
128
117
129
if ( badLicensePackages . length > 0 ) {
0 commit comments