Skip to content

Commit 18d02b9

Browse files
authored
style: apply neostandard to JS files (#1224)
Signed-off-by: Jan Kowalleck <[email protected]>
1 parent b504ef5 commit 18d02b9

18 files changed

+125
-119
lines changed

eslint.config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Copyright (c) OWASP Foundation. All Rights Reserved.
2020
import path from 'node:path'
2121
import { fileURLToPath } from 'node:url'
2222

23-
import { default as baseCfg, globals } from './tools/code-style/eslint.config.mjs'
23+
import baseCfg, { globals } from './tools/code-style/eslint.config.mjs'
2424

2525
const __filename = fileURLToPath(import.meta.url)
2626
const __dirname = path.dirname(__filename)
@@ -36,7 +36,7 @@ export default [
3636
{
3737
name: 'project-specific',
3838
rules: {
39-
"complexity": ["error", { "max": 15 }]
39+
complexity: ['error', { max: 15 }]
4040
}
4141
},
4242
{
@@ -55,7 +55,7 @@ export default [
5555
{
5656
files: [
5757
'**/*.{test,spec}.{js,mjs,cjs,ts}',
58-
'tests/**.{js,mjs,cjs,ts}'
58+
'tests/**/*.{js,mjs,cjs,ts}'
5959
],
6060
languageOptions: {
6161
globals: globals.mocha

tests/_data/models.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ function createComplexStructure () {
301301
['encode anyUri: mailto', 'mailto:[email protected]'],
302302
['encode anyUri: relative path', '../foo/bar'],
303303
['encode anyUri: space', 'https://example.org/foo bar bazz%20again+again'],
304-
['encode anyUri: quotation', `https://example.org/this"test"isa'test'`],
304+
['encode anyUri: quotation', 'https://example.org/this"test"isa\'test\''],
305305
['encode anyUri: []', 'https://example.org/?bar[test]=baz[again]'],
306306
['encode anyUri: <>', 'https://example.org/#<test><again>'],
307307
['encode anyUri: {}', 'https://example.org/#{test}{again}'],
@@ -609,7 +609,6 @@ function createComplexStructure () {
609609
return bom
610610
}
611611

612-
613612
/**
614613
* @returns {Models.Bom}
615614
*/
@@ -671,7 +670,6 @@ function createAllTools () {
671670
return bom
672671
}
673672

674-
675673
module.exports = {
676674
createAllTools,
677675
createComplexStructure

tests/_data/specLoader.spec.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ const { suite, test } = require('mocha')
2424
const { getSpecElement, getSpecEnum, loadSpec } = require('./specLoader')
2525

2626
suite('test helpers: specLoader', () => {
27-
28-
const expected_definitions_affectedStatus_enum = [
27+
const expectedDefinitionsAffectedStatusEnum = [
2928
'affected',
3029
'unaffected',
3130
'unknown'
@@ -42,7 +41,7 @@ suite('test helpers: specLoader', () => {
4241
test('happy path', () => {
4342
const loaded = loadSpec('bom-1.4.SNAPSHOT.schema.json')
4443
// dummy test to see if loading worked somehow ...
45-
assert.deepStrictEqual(loaded.definitions.affectedStatus.enum, expected_definitions_affectedStatus_enum)
44+
assert.deepStrictEqual(loaded.definitions.affectedStatus.enum, expectedDefinitionsAffectedStatusEnum)
4645
})
4746
})
4847

@@ -59,7 +58,7 @@ suite('test helpers: specLoader', () => {
5958
'bom-1.4.SNAPSHOT.schema.json',
6059
'definitions', 'affectedStatus', 'enum')
6160
// dummy test to see if loading worked somehow ...
62-
assert.deepStrictEqual(loaded, expected_definitions_affectedStatus_enum)
61+
assert.deepStrictEqual(loaded, expectedDefinitionsAffectedStatusEnum)
6362
})
6463
})
6564

@@ -69,7 +68,7 @@ suite('test helpers: specLoader', () => {
6968
'bom-1.4.SNAPSHOT.schema.json',
7069
'affectedStatus')
7170
// dummy test to see if loading worked somehow ...
72-
assert.deepStrictEqual(loaded, expected_definitions_affectedStatus_enum)
71+
assert.deepStrictEqual(loaded, expectedDefinitionsAffectedStatusEnum)
7372
})
7473
})
7574
})

tests/integration/Builders.FromNodePackageJson.ComponentBuilder.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ suite('integration: Builders.FromNodePackageJson.ComponentBuilder', () => {
6060
}
6161
],
6262
repository: {
63-
type: "git",
64-
url: "https://github.com/foo/bar.git"
63+
type: 'git',
64+
url: 'https://github.com/foo/bar.git'
6565
}
6666
// to be continued
6767
},

tests/integration/Factories.FromNodePackageJson.ExternalReferenceFactory.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ suite('integration: Factories.FromNodePackageJson.ExternalReferenceFactory', ()
104104
ExternalReferenceType.VCS,
105105
{ comment: 'as detected from PackageJson property "repository"' }
106106
)]
107-
const data = { repository: '../foo/bar' }
107+
const data = { repository: '../foo/bar' }
108108
const actual = sut.makeExternalReferences(data)
109109
assert.deepEqual(actual, expected)
110110
})
@@ -114,7 +114,7 @@ suite('integration: Factories.FromNodePackageJson.ExternalReferenceFactory', ()
114114
ExternalReferenceType.VCS,
115115
{ comment: 'as detected from PackageJson property "repository"' }
116116
)]
117-
const data = { repository: '[email protected]:foo/bar'}
117+
const data = { repository: '[email protected]:foo/bar' }
118118
const actual = sut.makeExternalReferences(data)
119119
assert.deepEqual(actual, expected)
120120
})
@@ -134,19 +134,19 @@ suite('integration: Factories.FromNodePackageJson.ExternalReferenceFactory', ()
134134
ExternalReferenceType.VCS,
135135
{ comment: 'as detected from PackageJson property "repository"' }
136136
)]
137-
const data = { repository: 'svn://example.com/foo/trunk' }
137+
const data = { repository: 'svn://example.com/foo/trunk' }
138138
const actual = sut.makeExternalReferences(data)
139139
assert.deepEqual(actual, expected)
140140
})
141141
test('empty string', () => {
142142
const expected = []
143-
const data = { repository: '' }
143+
const data = { repository: '' }
144144
const actual = sut.makeExternalReferences(data)
145145
assert.deepEqual(actual, expected)
146146
})
147147
test('undefined', () => {
148148
const expected = []
149-
const data = { }
149+
const data = { }
150150
const actual = sut.makeExternalReferences(data)
151151
assert.deepEqual(actual, expected)
152152
})
@@ -168,7 +168,7 @@ suite('integration: Factories.FromNodePackageJson.ExternalReferenceFactory', ()
168168
ExternalReferenceType.VCS,
169169
{ comment: 'as detected from PackageJson property "repository.url"' }
170170
)]
171-
const data = { repository: { url: '[email protected]:foo/bar'} }
171+
const data = { repository: { url: '[email protected]:foo/bar' } }
172172
const actual = sut.makeExternalReferences(data)
173173
assert.deepEqual(actual, expected)
174174
})
@@ -200,7 +200,7 @@ suite('integration: Factories.FromNodePackageJson.ExternalReferenceFactory', ()
200200
})
201201
test('undefined', () => {
202202
const expected = []
203-
const data = { repository: { } }
203+
const data = { repository: { } }
204204
const actual = sut.makeExternalReferences(data)
205205
assert.deepEqual(actual, expected)
206206
})
@@ -222,7 +222,7 @@ suite('integration: Factories.FromNodePackageJson.ExternalReferenceFactory', ()
222222
ExternalReferenceType.VCS,
223223
{ comment: 'as detected from PackageJson property "repository.url" and "repository.directory"' }
224224
)]
225-
const data = { repository: { url: '[email protected]:foo/bar', directory: 'some/other#23/dir#42'} }
225+
const data = { repository: { url: '[email protected]:foo/bar', directory: 'some/other#23/dir#42' } }
226226
const actual = sut.makeExternalReferences(data)
227227
assert.deepEqual(actual, expected)
228228
})

tests/integration/Serialize.JsonSerialize.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const { createAllTools, createComplexStructure } = require('../_data/models')
3737
const { loadSerializeResult, writeSerializeResult } = require('../_data/serialize')
3838

3939
describe('integration.Serialize.JsonSerialize', function () {
40-
this.timeout(60000);
40+
this.timeout(60000)
4141

4242
Object.entries({
4343
complex: createComplexStructure,

tests/integration/Serialize.XmlSerialize.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const { loadSerializeResult, writeSerializeResult } = require('../_data/serializ
3737
describe('integration.Serialize.XmlSerialize', function () {
3838
const expectMissingDepError = xmlStringify.fails ?? false
3939

40-
this.timeout(60000);
40+
this.timeout(60000)
4141

4242
Object.entries({
4343
complex: createComplexStructure,
@@ -100,7 +100,6 @@ describe('integration.Serialize.XmlSerialize', function () {
100100

101101
// TODO add more tests
102102
}))
103-
104103
}))
105104

106105
describe('make bom-refs unique', () => {

tests/unit/Models.bomLink.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const {
2525
Models: { BomLinkDocument, BomLinkElement }
2626
} = require('../../')
2727

28-
2928
suite('unit: Models.BomLinkDocument', () => {
3029
suite('isValid()', () => {
3130
test('pass', () => {

tests/unit/Serialize.BomRefDiscriminator.spec.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ suite('unit: Serialize.BomRefDiscriminator', () => {
3333
const bomRef2 = new BomRef('foo')
3434
const prefix = randomString(10)
3535

36-
3736
const actual = new BomRefDiscriminator([bomRef1, bomRef2], prefix)
3837

3938
assert.strictEqual(actual.prefix, prefix)
@@ -65,7 +64,6 @@ suite('unit: Serialize.BomRefDiscriminator', () => {
6564
assert.strictEqual(bomRef1.value, 'foo')
6665
assert.strictEqual(bomRef2.value, 'foo')
6766

68-
6967
const discriminator = new BomRefDiscriminator([bomRef1, bomRef2])
7068
discriminator.discriminate()
7169

tests/unit/Serialize.JsonSerializer.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ suite('unit: Serialize.JsonSerializer', () => {
4040
const normalizerFactoryDummy = { spec: { supportsFormat: f => f !== Format.JSON } }
4141
assert.throws(
4242
() => {
43-
43+
/* eslint-disable-next-line no-new -- needed to test constructor */
4444
new JsonSerializer(normalizerFactoryDummy)
4545
},
4646
UnsupportedFormatError,

0 commit comments

Comments
 (0)