Skip to content

Commit 0b896fb

Browse files
committed
fix: Update code for dev dependency upgrades
- Rename eslint.config.js to eslint.config.mjs for ESM format (eslint 9.x) - Add no-unused-vars exception for underscore-prefixed vars - Replace chai-spies with sinon in dispatcherTests (chai-spies incompatible with chai v6) - Add .default accessor for chai-as-promised in test files (ESM compatibility) - Fix mockttp v4 flaky tests by adding delay between server stop/start
1 parent 7e96da3 commit 0b896fb

File tree

14 files changed

+45
-40
lines changed

14 files changed

+45
-40
lines changed

eslint.config.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import eslintConfigPrettier from 'eslint-config-prettier'
4+
5+
export default [
6+
js.configs.recommended,
7+
{
8+
languageOptions: {
9+
globals: {
10+
...globals.node,
11+
...globals.mocha
12+
},
13+
parserOptions: {
14+
sourceType: 'module'
15+
}
16+
},
17+
rules: {
18+
'no-console': 'off',
19+
'no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }]
20+
}
21+
},
22+
eslintConfigPrettier
23+
]

ghcrawler/lib/crawler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class Crawler {
254254
try {
255255
request = await self._releaseLock(request)
256256
request = await self._deleteFromQueue(request)
257-
} catch (error) {
257+
} catch (_error) {
258258
request = await self._abandonInQueue(request)
259259
}
260260
}

providers/fetch/condaFetch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class CondaFetch extends AbstractFetch {
189189
async _fetchCachedJSONFile(cacheKey, url, cacheDuration, fileLocation) {
190190
try {
191191
await this._cachedDownload(cacheKey, url, cacheDuration, fileLocation)
192-
} catch (error) {
192+
} catch (_error) {
193193
return null
194194
}
195195
return JSON.parse(fs.readFileSync(fileLocation))

providers/fetch/dispatcher.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class FetchDispatcher extends AbstractFetch {
3333
request.document = document
3434
request.contentOrigin = 'storage'
3535
return this._dispatchFetch(request)
36-
} catch (error) {
36+
} catch (_error) {
3737
// TODO eating the error here. at least log
3838
return this._fetchMissing(request)
3939
}

test/unit/lib/fetchTests.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ function checkDefaultHeaders(headers) {
1111
}
1212
describe('CallFetch', () => {
1313
describe('with mock server', () => {
14-
const mockServer = mockttp.getLocal()
15-
beforeEach(async () => await mockServer.start())
16-
afterEach(async () => await mockServer.stop())
14+
let mockServer
15+
beforeEach(async () => {
16+
mockServer = mockttp.getLocal()
17+
await mockServer.start()
18+
})
19+
afterEach(async () => {
20+
await mockServer.stop()
21+
// Small delay to ensure port is released before next test
22+
await new Promise(resolve => setTimeout(resolve, 50))
23+
})
1724

1825
it('should return a stream when called with a URL string', async () => {
1926
const path = '/registry.npmjs.com/redis/0.1.0'

test/unit/lib/utilsTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: MIT
33

44
const chai = require('chai')
5-
const chaiAsPromised = require('chai-as-promised')
5+
const chaiAsPromised = require('chai-as-promised').default
66
const {
77
normalizePath,
88
normalizePaths,

test/unit/providers/fetch/debianFetchTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('Debian fetching', () => {
145145
try {
146146
await handler.handle(request)
147147
expect(false).to.be.true
148-
} catch (error) {
148+
} catch (_error) {
149149
expect(request.getTrackedCleanups().length).to.be.equal(2)
150150
}
151151
})

test/unit/providers/fetch/dispatcherTests.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// SPDX-License-Identifier: MIT
33

44
const chai = require('chai')
5-
const spies = require('chai-spies')
65
const sinon = require('sinon')
76
const fs = require('fs')
87
const PassThrough = require('stream').PassThrough
@@ -11,7 +10,6 @@ const proxyquire = require('proxyquire')
1110
const Request = require('../../../../ghcrawler').request
1211
const { promisify } = require('util')
1312

14-
chai.use(spies)
1513
const expect = chai.expect
1614

1715
const FetchDispatcher = require('../../../../providers/fetch/dispatcher')
@@ -30,10 +28,9 @@ describe('fetchDispatcher', () => {
3028
it('should call markNoSave if processor should not fetch', async () => {
3129
const processorsStub = [{ canHandle: () => true, shouldFetch: () => false }]
3230
const fetchDispatcher = FetchDispatcher({}, {}, {}, processorsStub)
33-
const request = {}
34-
chai.spy.on(request, 'markNoSave', () => {})
31+
const request = { markNoSave: sinon.spy() }
3532
await fetchDispatcher.handle(request)
36-
expect(request.markNoSave).to.have.been.called.once
33+
expect(request.markNoSave.calledOnce).to.be.true
3734
})
3835

3936
it('should markSkip request if missing from store and should not fetch missing', async () => {

test/unit/providers/fetch/gitClonerTests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('fetch result', () => {
5151
const request = new Request('licensee', 'cd:git/github/palantir/refreshable/2.0.0')
5252
try {
5353
await gitClient.handle(request)
54-
} catch (error) {
54+
} catch (_error) {
5555
expect(request.fetchResult).to.be.undefined
5656
expect(request.getTrackedCleanups().length).to.be.equal(1)
5757
}

0 commit comments

Comments
 (0)