Skip to content

Commit 746e0b2

Browse files
committed
wip
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent c56dac9 commit 746e0b2

19 files changed

+38
-37
lines changed

src/_helpers/packageJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2525
* Having multiple slashes(`/`) is basically no issue.
2626
*/
2727
export function splitNameGroup (data: string): [string, string?] {
28-
const delimGroup = data[0] === '@'
28+
const delimGroup = data.startsWith('@')
2929
? data.indexOf('/', 2)
3030
: 0
3131
return delimGroup > 0

src/_optPlug.node/jsonValidator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export type Validator = (data: string) => null | ValidationError
2424
export type Functionality = (schemaPath: string, schemaMap: Record<string, string>) => Promise<Validator>
2525

2626
export default opWrapper<Functionality>('JsonValidator', [
27-
/* eslint-disable @typescript-eslint/no-var-requires */
27+
2828
['( ajv && ajv-formats && ajv-formats-draft2019 )', () => require('./__jsonValidators/ajv').default]
2929
// ... add others here, pull-requests welcome!
30-
/* eslint-enable @typescript-eslint/no-var-requires */
30+
3131
]) satisfies Functionality | WillThrow

src/_optPlug.node/xmlStringify.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import opWrapper, { type WillThrow } from './_wrapper'
2424
export type Functionality = (element: SimpleXml.Element, options?: SerializerOptions) => string
2525

2626
export default opWrapper<Functionality>('XmlStringifier', [
27-
/* eslint-disable @typescript-eslint/no-var-requires */
27+
2828
['xmlbuilder2', () => require('./__xmlStringifiers/xmlbuilder2').default]
2929
// ... add others here, pull-requests welcome!
30-
/* eslint-enable @typescript-eslint/no-var-requires */
30+
3131
]) satisfies Functionality | WillThrow

src/_optPlug.node/xmlValidator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ export type Validator = (data: string) => null | ValidationError
2424
export type Functionality = (schemaPath: string) => Promise<Validator>
2525

2626
export default opWrapper<Functionality>('XmlValidator', [
27-
/* eslint-disable @typescript-eslint/no-var-requires */
27+
2828
['libxmljs2', () => require('./__xmlValidators/libxmljs2').default]
2929
// ... add others here, pull-requests welcome!
30-
/* eslint-enable @typescript-eslint/no-var-requires */
30+
3131
]) satisfies Functionality | WillThrow

src/builders/fromNodePackageJson.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class ComponentBuilder {
127127
if (Array.isArray(data.licenses)) {
128128
/* see https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json */
129129
for (const licenseData of data.licenses) {
130-
if (typeof licenseData?.type === 'string') {
130+
if (typeof licenseData.type === 'string') {
131131
const license = this.#licenseFactory.makeDisjunctive(licenseData.type)
132132
license.url = typeof licenseData.url === 'string'
133133
? licenseData.url

src/factories/fromNodePackageJson.node.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class ExternalReferenceFactory {
5353

5454
makeVcs (data: PackageJson): ExternalReference | undefined {
5555
/* see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#repositoryc */
56-
const repository = data.repository
56+
const {repository} = data
5757
let url
5858
let comment: string | undefined
5959
if (typeof repository === 'object') {
@@ -86,7 +86,7 @@ export class ExternalReferenceFactory {
8686

8787
makeIssueTracker (data: PackageJson): ExternalReference | undefined {
8888
/* see https://docs.npmjs.com/cli/v9/configuring-npm/package-json#bugs */
89-
const bugs = data.bugs
89+
const {bugs} = data
9090
let url
9191
let comment: string | undefined
9292
if (typeof bugs === 'object') {
@@ -113,7 +113,7 @@ const npmDefaultRepositoryMatcher = /^https?:\/\/registry\.npmjs\.org(:?\/|$)/
113113
* @see {@link https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#npm}
114114
*/
115115
export class PackageUrlFactory extends PlainPackageUrlFactory<'npm'> {
116-
override makeFromComponent (component: Component, sort: boolean = false): PackageURL | undefined {
116+
override makeFromComponent (component: Component, sort = false): PackageURL | undefined {
117117
const purl = super.makeFromComponent(component, sort)
118118
return purl === undefined
119119
? undefined

src/serialize/json/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import type { HashContent } from '../../models'
2222
import type { SpdxId } from '../../spdx'
2323
import type { CPE, CWE, Integer } from '../../types'
2424

25-
// eslint-disable-next-line @typescript-eslint/no-namespace
25+
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
2626
export namespace JsonSchema {
2727

2828
/**
@@ -62,7 +62,7 @@ export namespace JsonSchema {
6262

6363
}
6464

65-
// eslint-disable-next-line @typescript-eslint/no-namespace
65+
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
6666
export namespace Normalized {
6767

6868
export type RefType = string
@@ -261,7 +261,7 @@ export namespace Normalized {
261261
properties?: Property[]
262262
}
263263

264-
// eslint-disable-next-line @typescript-eslint/no-namespace
264+
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
265265
export namespace Vulnerability {
266266
export interface Source {
267267
name?: string

src/serialize/xml/normalize.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ export class BomNormalizer extends BaseXmlNormalizer<Models.Bom> {
221221
: undefined
222222
},
223223
children: [
224-
data.metadata
225-
? this._factory.makeForMetadata().normalize(data.metadata, options, 'metadata')
226-
: undefined,
224+
this._factory.makeForMetadata().normalize(data.metadata, options, 'metadata'),
227225
components,
228226
services,
229227
this._factory.spec.supportsDependencyGraph

src/serialize/xml/types.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,13 @@ export namespace XmlSchema {
4747
}
4848

4949
const fragmentPos = value.indexOf('#')
50-
let beforeFragment: string
50+
let beforeFragment = value
5151
if (fragmentPos >= 0) {
5252
if (value.includes('#', fragmentPos + 1)) {
5353
// has a second fragment marker
5454
return false
5555
}
5656
beforeFragment = value.slice(undefined, fragmentPos)
57-
} else {
58-
beforeFragment = value
5957
}
6058

6159
const schemePos = beforeFragment.indexOf(':')
@@ -71,7 +69,7 @@ export namespace XmlSchema {
7169

7270
}
7371

74-
// eslint-disable-next-line @typescript-eslint/no-namespace
72+
/* eslint-disable-next-line @typescript-eslint/no-namespace -- needed */
7573
export namespace SimpleXml {
7674

7775
/**

src/spdx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const spdxLowerToActual: Readonly<Record<string, SpdxId>> = Object.freeze(Object
3838
))
3939

4040
export function isSupportedSpdxId (value: SpdxId | any): value is SpdxId {
41-
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
41+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- fix */
4242
return spdxIds.has(value)
4343
}
4444

0 commit comments

Comments
 (0)