Skip to content

Commit

Permalink
chore(deps-dev): bump the eslint group with 2 updates (#1149)
Browse files Browse the repository at this point in the history
* chore(deps-dev): bump the eslint group with 2 updates

Bumps the eslint group with 2 updates: [eslint-config-standard-with-typescript](https://github.com/mightyiam/eslint-config-standard-with-typescript) and [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint/tree/HEAD/packages/eslint-plugin).


Updates `eslint-config-standard-with-typescript` from 43.0.0 to 43.0.1
- [Release notes](https://github.com/mightyiam/eslint-config-standard-with-typescript/releases)
- [Changelog](https://github.com/mightyiam/eslint-config-standard-with-typescript/blob/master/CHANGELOG.md)
- [Commits](mightyiam/eslint-config-love@v43.0.0...v43.0.1)

Updates `@typescript-eslint/eslint-plugin` from 6.18.1 to 6.20.0
- [Release notes](https://github.com/typescript-eslint/typescript-eslint/releases)
- [Changelog](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/CHANGELOG.md)
- [Commits](https://github.com/typescript-eslint/typescript-eslint/commits/v6.20.0/packages/eslint-plugin)

---
updated-dependencies:
- dependency-name: eslint-config-standard-with-typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
  dependency-group: eslint
- dependency-name: "@typescript-eslint/eslint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-minor
  dependency-group: eslint
...

Signed-off-by: dependabot[bot] <support@github.com>

* style: apply code style

Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jan Kowalleck <jan.kowalleck@gmail.com>
  • Loading branch information
dependabot[bot] and jkowalleck committed Feb 5, 2024
1 parent eb57e4c commit b53d48f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 25 deletions.
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.

## unreleased

* Style
* Applied latest code standards (via [#1149])

[#1149]: https://github.com/CycloneDX/cyclonedx-node-npm/pull/1149

## 1.16.1 - 2024-01-11

* Fixed
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"@types/normalize-package-data": "^2.4.1",
"eslint": "8.56.0",
"eslint-config-standard": "17.1.0",
"eslint-config-standard-with-typescript": "43.0.0",
"@typescript-eslint/eslint-plugin": "6.18.1",
"eslint-config-standard-with-typescript": "43.0.1",
"@typescript-eslint/eslint-plugin": "6.20.0",
"eslint-plugin-header": "3.1.1",
"eslint-plugin-simple-import-sort": "10.0.0",
"fast-glob": "^3.2.11",
Expand Down
4 changes: 4 additions & 0 deletions src/_helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@ export async function writeAllSync (fd: number, data: string): Promise<number> {
}
return w
}

export function isString (v: any): v is string {
return typeof v === 'string'
}
48 changes: 25 additions & 23 deletions src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import * as normalizePackageData from 'normalize-package-data'
import { type PackageURL } from 'packageurl-js'
import * as path from 'path'

import { loadJsonFile } from './_helpers'
import { isString, loadJsonFile } from './_helpers'
import { makeNpmRunner, type runFunc } from './npmRunner'
import { PropertyNames, PropertyValueBool } from './properties'
import { versionCompare } from './versionCompare'
Expand Down Expand Up @@ -246,10 +246,6 @@ export class BomBuilder {

// region components

/* eslint "@typescript-eslint/no-unsafe-argument": "off"
--------
this rule would cause eslint to run into issues with max recursion depth
see https://github.com/typescript-eslint/typescript-eslint/issues/7298 */
bom.components = this.nestComponents(
// remove rootComponent - so the elements that are nested below it are just returned.
new Map(Array.from(allComponents.entries()).filter(([, c]) => c !== rootComponent)),
Expand Down Expand Up @@ -309,36 +305,38 @@ export class BomBuilder {
* but only the most top-level has a complete set with all `dependencies` *and* `resolved`.
* This detail might cause implementation changes: run over the top level first, then go into nested dependencies.
*/
/* eslint-disable-next-line @typescript-eslint/no-unsafe-argument */
for (const [depName, depData] of Object.entries(data.dependencies ?? {}) as any) {
if (depData === null || typeof depData !== 'object') {
// cannot build
this.console.debug('DEBUG | skip malformed component %j in %j', depName, depData)
continue // for-loop
}
if (typeof depData.path !== 'string') {
const depPath = depData.path
if (!isString(depPath)) {
// might be an optional dependency that was not installed
// skip, as it was not installed anyway
this.console.debug('DEBUG | skip missing component %j in %j', depName, depData.path)
this.console.debug('DEBUG | skip missing component %j in %j', depName, depPath)
continue // for-loop
}

let dep = allComponents.get(depData.path)
let dep = allComponents.get(depPath)
if (dep === undefined) {
const _dep = this.makeComponent(depData)
if (_dep === false) {
// shall be skipped
this.console.debug('DEBUG | skip impossible component %j in %j', depName, depData.path)
this.console.debug('DEBUG | skip impossible component %j in %j', depName, depPath)
continue // for-loop
}
dep = _dep ??
new DummyComponent(Enums.ComponentType.Library, `InterferedDependency.${depName as string}`)
new DummyComponent(Enums.ComponentType.Library, `InterferedDependency.${depName}`)
if (dep instanceof DummyComponent) {
this.console.warn('WARN | InterferedDependency %j in %j', depName, depData.path)
this.console.warn('WARN | InterferedDependency %j in %j', depName, depPath)
} else {
this.console.debug('DEBUG | built component %j in %j: %j', depName, depData.path, dep)
this.console.debug('DEBUG | built component %j in %j: %j', depName, depPath, dep)
}
this.console.info('INFO | add component for %j in %j', depName, depData.path)
allComponents.set(depData.path, dep)
this.console.info('INFO | add component for %j in %j', depName, depPath)
allComponents.set(depPath, dep)
}
directDepRefs.add(dep.bomRef)

Expand Down Expand Up @@ -445,15 +443,19 @@ export class BomBuilder {
if (!this.packageLockOnly) {
_dataC = this.enhancedPackageData(_dataC)
}
normalizePackageData(_dataC /* add debug for warnings? */)
normalizePackageData(_dataC as normalizePackageData.Input
/* add debug for warnings? */)
// region fix normalizations
if (typeof data.version === 'string') {
if (isString(data.version)) {
// allow non-SemVer strings
_dataC.version = data.version.trim()
}
// endregion fix normalizations

const component = this.componentBuilder.makeComponent(_dataC, type)
const component = this.componentBuilder.makeComponent(
_dataC as normalizePackageData.Package,
type
)
if (component === undefined) {
this.console.debug('DEBUG | skip broken component: %j %j', data.name, data._id)
return undefined
Expand All @@ -465,9 +467,9 @@ export class BomBuilder {

// region properties

if (typeof data.path === 'string') {
if (isString(data.path)) {
component.properties.add(
new Models.Property(PropertyNames.PackageInstallPath, data.path)
new Models.Property(PropertyNames.PackageInstallPath, data.path as string)
)
}
if (isDev || isDevOptional) {
Expand Down Expand Up @@ -496,11 +498,11 @@ export class BomBuilder {

// older npm-ls versions (v6) hide properties behind a `_`
const resolved = data.resolved ?? data._resolved
if (typeof resolved === 'string' && !this.resolvedRE_ignore.test(resolved)) {
if (isString(resolved) && !this.resolvedRE_ignore.test(resolved)) {
const hashes = new Models.HashDictionary()
// older npm-ls versions (v6) hide properties behind a `_`
const integrity = data.integrity ?? data._integrity
if (typeof integrity === 'string') {
if (isString(integrity)) {
for (const [hashAlgorithm, hashRE] of this.integrityRE) {
const hashMatchBase64 = hashRE.exec(integrity) ?? []
if (hashMatchBase64?.length === 2) {
Expand Down Expand Up @@ -530,7 +532,7 @@ export class BomBuilder {

/* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing
-- since empty-string handling is needed */
component.bomRef.value = (typeof data._id === 'string' ? data._id : undefined) ||
component.bomRef.value = (isString(data._id) ? data._id : undefined) ||
`${component.group || '-'}/${component.name}@${component.version || '-'}`
/* eslint-enable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/prefer-nullish-coalescing */

Expand All @@ -552,7 +554,7 @@ export class BomBuilder {
}

private finalizePathProperties (rootPath: any, components: IterableIterator<Models.Component>): void {
if (typeof rootPath !== 'string' || rootPath === '') {
if (!isString(rootPath) || rootPath === '') {
return
}
/* eslint-disable @typescript-eslint/unbound-method */
Expand Down

0 comments on commit b53d48f

Please sign in to comment.