Skip to content

Commit 1a40b51

Browse files
committed
chore: updated validate-license script and cspell package
1 parent f4635be commit 1a40b51

File tree

3 files changed

+542
-449
lines changed

3 files changed

+542
-449
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"@angular/router": "18.2.6",
6161
"@commitlint/cli": "^19.5.0",
6262
"@commitlint/config-conventional": "^19.5.0",
63-
"@cspell/dict-markdown": "^2.0.2",
64-
"@cspell/dict-ru_ru": "^2.2.1",
63+
"@cspell/dict-markdown": "^2.0.10",
64+
"@cspell/dict-ru_ru": "^2.3.0",
6565
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
6666
"@koobiq/design-tokens": "^3.13.2",
6767
"@koobiq/luxon-date-adapter": "^3.2.3",
@@ -104,7 +104,7 @@
104104
"conventional-changelog": "^3.1.10",
105105
"conventional-changelog-angular": "5.0.13",
106106
"conventional-changelog-writer": "5.0.1",
107-
"cspell": "^8.14.4",
107+
"cspell": "^8.19.4",
108108
"dotenv": "^16.4.5",
109109
"eslint": "^8.57.1",
110110
"eslint-config-prettier": "^9.1.0",

tools/validate-licenses/validate-licenses.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import spdxSatisfies from 'spdx-satisfies';
44

55
type License = string;
66

7-
type PackageID = string;
7+
type PackageID = string | RegExp;
88

99
// List of licenses considered valid and acceptable for use.
1010
const licensesWhitelist: License[] = [
@@ -57,7 +57,7 @@ const ignoredPackages: PackageID[] = [
5757
'gitconfiglocal@1.0.0',
5858

5959
// https://github.com/streetsidesoftware/cspell-dicts/blob/main/dictionaries/en-common-misspellings/LICENSE
60-
'@cspell/dict-en-common-misspellings@2.0.4'
60+
/^@cspell\/dict-en-common-misspellings@.*$/
6161
];
6262

6363
// Normalizes the license string to a standard SPDX identifier, handling possible asterisks from guessed licenses.
@@ -90,6 +90,18 @@ const enum ReturnCode {
9090
InvalidLicense = 2
9191
}
9292

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+
93105
// Main function that initializes the license checker and processes the results.
94106
async function validateLicense(): Promise<ReturnCode> {
95107
try {
@@ -111,7 +123,7 @@ async function validateLicense(): Promise<ReturnCode> {
111123
? json[key].licenses.map(normalizeLicense)
112124
: [normalizeLicense(json[key].licenses)]
113125
}))
114-
.filter((pkg) => !ignoredPackages.includes(pkg.id))
126+
.filter((pkg) => !isLicenseIgnored(pkg.id))
115127
.filter((pkg) => !isLicenseValid(pkg.licenses));
116128

117129
if (badLicensePackages.length > 0) {

0 commit comments

Comments
 (0)