diff --git a/HISTORY.md b/HISTORY.md index d9886bbe8..d32328538 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,11 +12,14 @@ All notable changes to this project will be documented in this file. * Changed * Replace usage of internals `Stringable` & `SortableStringables` with public aliases API ([#1192] via [#1202]) This is considered a non-breaking change, as the types are not changed, but made publicly available. +* Style + * Apply latest code style guide (via [#1201]) * Misc * Support `npm11` ([#1191] via [#1203]) [#1191]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1191 [#1192]: https://github.com/CycloneDX/cyclonedx-javascript-library/issues/1192 +[#1201]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1201 [#1202]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1202 [#1203]: https://github.com/CycloneDX/cyclonedx-javascript-library/pull/1203 diff --git a/eslint.config.mjs b/eslint.config.mjs index 012378ffb..734b9ff2a 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -33,6 +33,12 @@ const __dirname = path.dirname(__filename) */ export default [ ...baseCfg, + { + name: 'project-specific', + rules: { + "complexity": ["error", { "max": 15 }] + } + }, { files: ['**/*.js'], languageOptions: { sourceType: 'commonjs' } diff --git a/src/models/bomLink.ts b/src/models/bomLink.ts index 239353c37..73f8ed945 100644 --- a/src/models/bomLink.ts +++ b/src/models/bomLink.ts @@ -34,6 +34,10 @@ abstract class BomLinkBase implements Stringable, Comparable { this.value = value } + get value (): string { + return this.#value + } + /** * @throws {@link RangeError} if value is invalid */ @@ -44,10 +48,6 @@ abstract class BomLinkBase implements Stringable, Comparable { this.#value = value } - get value (): string { - return this.#value - } - compare (other: Stringable): number { return this.toString().localeCompare(other.toString()) } diff --git a/src/models/vulnerability/rating.ts b/src/models/vulnerability/rating.ts index 70547d930..d82c1edb6 100644 --- a/src/models/vulnerability/rating.ts +++ b/src/models/vulnerability/rating.ts @@ -48,6 +48,7 @@ export class Rating implements Comparable { this.justification = op.justification } + /* eslint complexity: ["error", 50] -- acknowledged */ compare (other: Rating): number { /* eslint-disable @typescript-eslint/strict-boolean-expressions -- run compares in weighted order */ return ((this.score ?? 0) - (other.score ?? 0)) || diff --git a/src/models/vulnerability/vulnerability.ts b/src/models/vulnerability/vulnerability.ts index a117d02f0..acf8f46e8 100644 --- a/src/models/vulnerability/vulnerability.ts +++ b/src/models/vulnerability/vulnerability.ts @@ -98,6 +98,7 @@ export class Vulnerability implements Comparable { return this.#bomRef } + /* eslint complexity: ["error", 50] -- acknowledged */ compare (other: Vulnerability): number { const bomRefCompare = this.bomRef.compare(other.bomRef) if (bomRefCompare !== 0) { diff --git a/src/serialize/json/normalize.ts b/src/serialize/json/normalize.ts index 63c21fa95..20415067b 100644 --- a/src/serialize/json/normalize.ts +++ b/src/serialize/json/normalize.ts @@ -17,6 +17,9 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ +/* eslint complexity: ["error", 50 ] -- acknowledged */ +/* eslint max-lines: 'off' -- intended */ + import { chainI } from "../../_helpers/iterable"; import { isNotUndefined } from '../../_helpers/notUndefined' import type { SortableIterable } from '../../_helpers/sortable' @@ -35,6 +38,8 @@ import type { NormalizerOptions } from '../types' import type { Normalized } from './types' import { JsonSchema } from './types' + + export class Factory { readonly #spec: Spec diff --git a/src/serialize/xml/normalize.ts b/src/serialize/xml/normalize.ts index ad9222502..bac70b5ca 100644 --- a/src/serialize/xml/normalize.ts +++ b/src/serialize/xml/normalize.ts @@ -17,6 +17,9 @@ SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ +/* eslint complexity: ["error", 50 ] -- acknowledged */ +/* eslint max-lines: 'off' -- intended */ + import { chainI } from "../../_helpers/iterable"; import { isNotUndefined } from '../../_helpers/notUndefined' import type { SortableIterable } from '../../_helpers/sortable' @@ -36,6 +39,8 @@ import { normalizedString, token} from './_xsd' import type { SimpleXml } from './types' import { XmlSchema } from './types' + + export class Factory { readonly #spec: Spec diff --git a/tools/code-style/package.json b/tools/code-style/package.json index 194821c40..81876ef46 100644 --- a/tools/code-style/package.json +++ b/tools/code-style/package.json @@ -7,19 +7,19 @@ }, "dependencies": { "@eslint/eslintrc": "3.2.0", - "@eslint/js": "9.15.0", + "@eslint/js": "9.17.0", "@types/eslint": "^9.6.1", "eslint": "9.14.0", - "eslint-config-love": "107.0.0", + "eslint-config-love": "114.0.0", "eslint-plugin-editorconfig": "4.0.3", "eslint-plugin-import": "2.31.0", - "eslint-plugin-jsdoc": "50.5.0", + "eslint-plugin-jsdoc": "50.6.1", "eslint-plugin-license-header": "0.6.1", - "eslint-plugin-n": "17.14.0", - "eslint-plugin-promise": "7.1.0", + "eslint-plugin-n": "17.15.1", + "eslint-plugin-promise": "7.2.1", "eslint-plugin-simple-import-sort": "12.1.1", "eslint-plugin-tsdoc": "0.4.0", "globals": "^15.7.0", - "typescript-eslint": "8.15.0" + "typescript-eslint": "8.19.1" } }