Skip to content

Commit 8e6cd18

Browse files
committed
style
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent 421f7fa commit 8e6cd18

File tree

4 files changed

+74
-64
lines changed

4 files changed

+74
-64
lines changed

eslint.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ export default [
4949
},
5050
{
5151
files: ['**/*.js'],
52-
languageOptions: { sourceType: 'commonjs' }
52+
languageOptions: { sourceType: 'commonjs' },
53+
rules: {
54+
'jsdoc/reject-any-type': 'off'
55+
}
5356
},
5457
{
5558
files: [

src/_helpers.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export function versionTuple (value: string): Version {
7878
}
7979

8080
export function versionCompare (a: Version, b: Version): CompareResult {
81+
/* eslint-disable-next-line no-plusplus -- save */
8182
for (let i = 0, l = Math.max(a.length, b.length); i < l; ++i) {
8283
// make values NaN-save, null-safe, undefined-safe
8384
const ai = a[i] || 0 /* eslint-disable-line @typescript-eslint/strict-boolean-expressions -- needed */
@@ -129,7 +130,7 @@ export function normalizePackageManifest (data: any): asserts data is normalizeP
129130

130131
if (isString(oVersion)) {
131132
// normalizer might have stripped version or sanitized it to SemVer -- we want the original
132-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access -- ack */
133+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, no-param-reassign -- ack */
133134
data.version = oVersion.trim()
134135
}
135136
}

src/builders.ts

Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,13 @@ export class BomBuilder {
243243
: [path.win32.relative, '\\', /\\/g]
244244
/* eslint-enable @typescript-eslint/unbound-method */
245245
allComponents.forEach((c, p) => {
246+
/* eslint-disable no-param-reassign -- intended */
246247
c.purl = this.makePurl(c)
247248
c.properties.add(new Models.Property(
248249
PropertyNames.PackageInstallPath,
249250
relativePath(rootPath, p).replace(dirSepRE, '/')
250251
))
252+
/* eslint-enable no-param-reassign */
251253
})
252254

253255
const pTree = this.treeBuilder.fromPaths(rootPath,allComponents.keys(), dirSep)
@@ -315,7 +317,7 @@ export class BomBuilder {
315317
parts.push('@', component.version)
316318
}
317319
const bRefD = parts.join('')
318-
const bRefC = bRefCs[bRefD] = (bRefCs[bRefD] ?? 0) +1
320+
const bRefC = bRefCs[bRefD] = (bRefCs[bRefD] ?? 0) +1 /* eslint-disable-line no-multi-assign -- ack */
319321
component.bomRef.value = `${pref}${bRefD}${bRefC > 1 ? '#' + bRefC : ''}`
320322
this.setNestedBomRefs(allComponents, cTree, `${component.bomRef.value}|`)
321323
}
@@ -404,30 +406,32 @@ export class BomBuilder {
404406
}
405407

406408
component.licenses.forEach(l => {
409+
/* eslint-disable no-param-reassign -- intended */
407410
l.acknowledgement = Enums.LicenseAcknowledgement.Declared
408-
})
411+
/* eslint-enable no-param-reassign */
412+
})
409413

410-
if ( this.gatherLicenseTexts ) {
411-
component.evidence = new Models.ComponentEvidence()
412-
for (const le of this.fetchLicenseEvidence(ppath) ) {
413-
component.evidence.licenses.add(le)
414-
}
415-
}
414+
if ( this.gatherLicenseTexts ) {
415+
component.evidence = new Models.ComponentEvidence()
416+
for (const le of this.fetchLicenseEvidence(ppath) ) {
417+
component.evidence.licenses.add(le)
418+
}
419+
}
416420

417-
// region properties
421+
// region properties
418422

419-
if (manifest.private === true) {
420-
component.properties.add(
421-
new Models.Property(PropertyNames.PackagePrivate, PropertyValueBool.True)
422-
)
423-
}
423+
if (manifest.private === true) {
424+
component.properties.add(
425+
new Models.Property(PropertyNames.PackagePrivate, PropertyValueBool.True)
426+
)
427+
}
424428

425-
// endregion properties
429+
// endregion properties
426430

427-
return component
428-
}
431+
return component
432+
}
429433

430-
/* eslint-disable-next-line complexity -- ack */
434+
/* eslint-disable-next-line complexity -- ack */
431435
private makeComponentWithPackageData(data: PackageData, ppath: PackagePath, type: Enums.ComponentType = Enums.ComponentType.Library): Models.Component {
432436
const isOptional = data.optional === true || data.devOptional === false
433437
let isExcluded= false
@@ -462,49 +466,51 @@ export class BomBuilder {
462466
component = new DummyComponent(type, ppath)
463467
} else {
464468
component.licenses.forEach(l => {
469+
/* eslint-disable no-param-reassign -- intended */
465470
l.acknowledgement = Enums.LicenseAcknowledgement.Declared
466-
})
467-
}
468-
469-
if (isExcluded) {
470-
component.scope = Enums.ComponentScope.Excluded
471-
} else if (isOptional) {
472-
component.scope = Enums.ComponentScope.Optional
473-
}
474-
475-
// region properties
476-
if (data.dev === true || data.devOptional === true) {
477-
component.properties.add(
478-
new Models.Property(PropertyNames.PackageDevelopment, PropertyValueBool.True)
479-
)
480-
}
481-
if (data.extraneous === true) {
482-
component.properties.add(
483-
new Models.Property(PropertyNames.PackageExtraneous, PropertyValueBool.True)
484-
)
485-
}
486-
if (data.inBundle === true) {
487-
component.properties.add(
488-
new Models.Property(PropertyNames.PackageBundled, PropertyValueBool.True)
489-
)
490-
}
491-
// endregion properties
492-
493-
// region resolved
494-
const rref = this.makeExtRefDistFromPackageData(data)
495-
if ( rref !== undefined ) {
496-
component.externalReferences.add(rref)
497-
}
498-
// endregion resolved
499-
500-
return component
501-
}
502-
503-
/**
504-
* Ignore pattern for `resolved`.
505-
* - ignore: well, just ignore it ... i guess.
506-
* - file: local dist cannot be shipped and therefore should be ignored.
507-
*/
471+
/* eslint-enable no-param-reassign */
472+
})
473+
}
474+
475+
if (isExcluded) {
476+
component.scope = Enums.ComponentScope.Excluded
477+
} else if (isOptional) {
478+
component.scope = Enums.ComponentScope.Optional
479+
}
480+
481+
// region properties
482+
if (data.dev === true || data.devOptional === true) {
483+
component.properties.add(
484+
new Models.Property(PropertyNames.PackageDevelopment, PropertyValueBool.True)
485+
)
486+
}
487+
if (data.extraneous === true) {
488+
component.properties.add(
489+
new Models.Property(PropertyNames.PackageExtraneous, PropertyValueBool.True)
490+
)
491+
}
492+
if (data.inBundle === true) {
493+
component.properties.add(
494+
new Models.Property(PropertyNames.PackageBundled, PropertyValueBool.True)
495+
)
496+
}
497+
// endregion properties
498+
499+
// region resolved
500+
const rref = this.makeExtRefDistFromPackageData(data)
501+
if ( rref !== undefined ) {
502+
component.externalReferences.add(rref)
503+
}
504+
// endregion resolved
505+
506+
return component
507+
}
508+
509+
/**
510+
* Ignore pattern for `resolved`.
511+
* - ignore: well, just ignore it ... i guess.
512+
* - file: local dist cannot be shipped and therefore should be ignored.
513+
*/
508514
private readonly resolvedRE_ignore = /^(?:ignore|file):/i
509515

510516
private makeExtRefDistFromPackageData (data: PackageData): Models.ExternalReference | undefined {
@@ -603,7 +609,7 @@ type PTreeI = Iterable<[PackagePath, PTree]>
603609

604610
export class TreeBuilder {
605611
fromPaths (root: PackagePath, paths: Iterable<PackagePath>, dirSeparator: string): PTree {
606-
root += dirSeparator
612+
root += dirSeparator /* eslint-disable-line no-param-reassign -- ack */
607613
const upaths = new Set<PackagePath>(iterableMap(paths, p => `${p}${dirSeparator}`))
608614
const outs = new Set<PackagePath>(iterableFilter(upaths, p => !p.startsWith(root)))
609615
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- ack */

src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ const npmMinVersion: Version = Object.freeze([9, 0, 0])
248248

249249
/* eslint-disable-next-line complexity -- ack */
250250
export async function run (process_: NodeJS.Process): Promise<number> {
251-
process_.title = 'cyclonedx-node-npm'
251+
process_.title = 'cyclonedx-node-npm' /* eslint-disable-line no-param-reassign -- ack */
252252

253253
const program = makeCommand(process_)
254254
program.parse(process_.argv)

0 commit comments

Comments
 (0)