Skip to content

Commit 966f3cf

Browse files
authored
refactor: prefix native module imports with node: (#1210)
fixes #1198 --------- Signed-off-by: Jan Kowalleck <[email protected]>
1 parent da54363 commit 966f3cf

File tree

69 files changed

+234
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+234
-158
lines changed

src/_optPlug.node/__jsonValidators/ajv.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20+
import { readFile } from 'node:fs/promises'
21+
2022
import Ajv, { type Options as AjvOptions } from 'ajv'
2123
import addFormats from 'ajv-formats'
2224
/* @ts-expect-error TS7016 */
2325
import addFormats2019 from 'ajv-formats-draft2019'
24-
import { readFile } from 'fs/promises'
2526

2627
import type { ValidationError } from '../../validation/types'
2728
import type { Functionality, Validator } from '../jsonValidator'

src/_optPlug.node/__xmlValidators/libxmljs2.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
import { readFile } from 'fs/promises'
20+
import { readFile } from 'node:fs/promises'
21+
import { pathToFileURL } from 'node:url'
22+
2123
import { type ParserOptions, parseXml } from 'libxmljs2'
22-
import { pathToFileURL } from 'url'
2324

2425
import type { ValidationError } from '../../validation/types'
2526
import type { Functionality, Validator } from '../xmlValidator'

src/models/externalReference.ts

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type { ExternalReferenceType } from '../enums/externalReferenceType'
2323
import type { BomLink } from './bomLink'
2424
import { HashDictionary } from './hash'
2525

26+
2627
export interface OptionalExternalReferenceProperties {
2728
hashes?: ExternalReference['hashes']
2829
comment?: ExternalReference['comment']

src/resources.node.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
import { resolve } from 'path'
20+
import { resolve } from 'node:path'
2121

2222
import { Version } from './spec/enums'
2323

tests/_data/models.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const { Enums, Models, Types } = require('../../')
2424
/**
2525
* @returns {Models.Bom}
2626
*/
27-
module.exports.createComplexStructure = function () {
27+
function createComplexStructure () {
2828
const bomSerialNumberRaw = 'ac35b126-ef3a-11ed-a05b-0242ac120003'
2929
const bom = new Models.Bom({
3030
version: 7,
@@ -613,7 +613,7 @@ module.exports.createComplexStructure = function () {
613613
/**
614614
* @returns {Models.Bom}
615615
*/
616-
module.exports.createAllTools = function () {
616+
function createAllTools () {
617617
const bomSerialNumberRaw = '8fd9e244-73b6-4cd3-ab3a-a0fefdee5c9e'
618618
const bom = new Models.Bom({
619619
version: 7,
@@ -670,3 +670,9 @@ module.exports.createAllTools = function () {
670670
)
671671
return bom
672672
}
673+
674+
675+
module.exports = {
676+
createAllTools,
677+
createComplexStructure
678+
}

tests/_data/normalize.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const fs = require('fs')
21-
const path = require('path')
20+
const fs = require('node:fs')
21+
const path = require('node:path')
2222

2323
/* eslint-disable jsdoc/valid-types */
2424

tests/_data/serialize.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const fs = require('fs')
21-
const path = require('path')
20+
const fs = require('node:fs')
21+
const path = require('node:path')
2222

2323
/* eslint-disable jsdoc/valid-types */
2424

tests/_data/spdx.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const fs = require('fs')
21-
const assert = require('assert')
20+
const assert = require('node:assert')
21+
const fs = require('node:fs')
2222

2323
const { _Resources: { FILES: { SPDX: { JSON_SCHEMA: SPDX_JSON_SCHEMA } } } } = require('../../')
2424

tests/_data/specLoader.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const fs = require('fs')
21-
const path = require('path')
20+
const fs = require('node:fs')
21+
const path = require('node:path')
2222

2323
const resPath = path.resolve(__dirname, '..', '..', 'res', 'schema')
2424

@@ -72,7 +72,7 @@ function getSpecEnum (resourceFile, ...path) {
7272
}
7373

7474
module.exports = {
75-
loadSpec,
7675
getSpecElement,
77-
getSpecEnum
76+
getSpecEnum,
77+
loadSpec
7878
}

tests/_data/specLoader.spec.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
20+
const assert = require('node:assert')
21+
2122
const { suite, test } = require('mocha')
2223

23-
const { loadSpec, getSpecElement, getSpecEnum } = require('./specLoader')
24+
const { getSpecElement, getSpecEnum, loadSpec } = require('./specLoader')
2425

2526
suite('test helpers: specLoader', () => {
2627

tests/_helpers/stringFunctions.spec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
20+
const assert = require('node:assert')
21+
2122
const { suite, test } = require('mocha')
2223

2324
const stringFunctions = require('./stringFunctions')

tests/functional/Enums.ComponentScope.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { ComponentScope },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: ComponentScope enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.ComponentType.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { ComponentType },
2826
Spec: { Version, SpecVersionDict },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: ComponentType enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.ExternalReferenceType.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { ExternalReferenceType },
2826
Spec: { Version, SpecVersionDict },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: ExternalReferenceType enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.HashAlogorithms.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { capitaliseFirstLetter } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { HashAlgorithm },
2826
Spec: { Version, SpecVersionDict },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { capitaliseFirstLetter } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: HashAlgorithm enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.LicenseAcknowledgement.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { LicenseAcknowledgement },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: LicenseAcknowledgement enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.LifecyclePhase.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { LifecyclePhase },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: LifecyclePhase enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.Vulnerability.AffectStatus.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { Vulnerability: { AffectStatus } },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: Vulnerability.AffectStatus enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.Vulnerability.AnalysisJustification.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { Vulnerability: { AnalysisJustification } },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: Vulnerability.AnalysisJustification enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.Vulnerability.AnalysisResponse.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { Vulnerability: { AnalysisResponse } },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: Vulnerability.AnalysisResponse enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.Vulnerability.AnalysisState.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { Vulnerability: { AnalysisState } },
2826
Spec: { Version },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: Vulnerability.AnalysisState enum', () => {
3333
const specVersions = new Set([

tests/functional/Enums.Vulnerability.RatingMethod.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ SPDX-License-Identifier: Apache-2.0
1717
Copyright (c) OWASP Foundation. All Rights Reserved.
1818
*/
1919

20-
const assert = require('assert')
21-
const { suite, test } = require('mocha')
20+
const assert = require('node:assert')
2221

23-
const { getSpecEnum } = require('../_data/specLoader')
24-
const { upperCamelCase } = require('../_helpers/stringFunctions')
22+
const { suite, test } = require('mocha')
2523

2624
const {
2725
Enums: { Vulnerability: { RatingMethod } },
2826
Spec: { Version, SpecVersionDict },
2927
_Resources: { FILES: { CDX: { JSON_SCHEMA: CDX_JSON_SCHEMA } } }
3028
} = require('../../')
29+
const { getSpecEnum } = require('../_data/specLoader')
30+
const { upperCamelCase } = require('../_helpers/stringFunctions')
3131

3232
suite('functional: Vulnerability.RatingMethod enum', () => {
3333
const specVersions = new Set([

0 commit comments

Comments
 (0)