@@ -216,42 +216,60 @@ export type ThirdPartyOutput = string | ((dependencies: Dependency[]) => void) |
216
216
template ?: ( ( dependencies : Dependency [ ] ) => string ) | string ,
217
217
} ;
218
218
219
+ /**
220
+ * SPDX Licence Identifier.
221
+ */
222
+ type SpdxId = string ;
223
+
224
+ /**
225
+ * Function checking dependency license validity.
226
+ */
227
+ type ThirdPartyDependencyValidatorFn = ( Dependency : Dependency ) => boolean ;
228
+
229
+ type ThirdPartyValidator = SpdxId | ThirdPartyDependencyValidatorFn ;
230
+
231
+ interface ThirdPartyAllowOptions {
232
+ /**
233
+ * Testing if the license if valid
234
+ */
235
+ test : ThirdPartyValidator ;
236
+
237
+ /**
238
+ * Fail if a dependency does not specify any licenses
239
+ * @default false
240
+ */
241
+ failOnUnlicensed ?: boolean ;
242
+
243
+ /**
244
+ * Fail if a dependency specify a license that does not match given requirement
245
+ * @default false
246
+ */
247
+ failOnViolation ?: boolean ;
248
+ }
249
+
219
250
export type ThirdParty = ( ( dependencies : Dependency [ ] ) => void ) | {
220
251
/**
221
- * If private dependencies should be allowed (`private: true` in package.json)
252
+ * If private dependencies should be checked (`private: true` in package.json)
222
253
* @default false
223
254
*/
224
255
includePrivate ?: boolean ,
225
256
226
257
/**
227
258
* Ensures that dependencies does not violate any license restriction.
259
+ *
228
260
* For example, suppose you want to limit dependencies with MIT or Apache-2.0
229
- * licenses, simply define the restriction such as:
261
+ * licenses, simply define the restriction:
262
+ *
230
263
* @example
231
- * {allow: '(MIT OR Apache-2.0)'}
264
+ * {
265
+ * allow: '(MIT OR Apache-2.0)'
266
+ * }
232
267
*
233
- * allow(dependency) {
234
- * return dependency.license === 'MIT';
235
- * }
236
- */
237
- allow ?: string | ( ( dependency : Dependency ) => boolean ) | {
238
- /**
239
- * Testing if the license if valid
240
- */
241
- test : string | ( ( dependency : Dependency ) => boolean ) ,
242
-
243
- /**
244
- * Fail if a dependency does not specify any licenses
245
- * @default false
246
- */
247
- failOnUnlicensed ?: boolean ,
248
-
249
- /**
250
- * Fail if a dependency specify a license that does not match given requirement
251
- * @default false
252
- */
253
- failOnViolation ?: boolean ,
254
- } ,
268
+ * allow(dependency) {
269
+ * return dependency.license === 'MIT';
270
+ * }
271
+ */
272
+ allow ?: ThirdPartyValidator | ThirdPartyAllowOptions ,
255
273
256
274
/**
257
275
* Output file for
0 commit comments