Skip to content

Commit 866a7df

Browse files
authored
Replace ESLint with Biome (#44)
1 parent 6f983ce commit 866a7df

16 files changed

+92
-95
lines changed

.eslintignore

-1
This file was deleted.

.eslintrc

-23
This file was deleted.

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Build
3636
run: npm run rollup
3737

38-
- name: Run Tests
38+
- name: Run Tests and Linting
3939
run: npm run test:ci
4040

4141
automerge:

.prettierrc.json

-8
This file was deleted.

benchmark.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Lru } from './dist/toad-cache.mjs'
21
import { precise } from 'precise'
2+
import { Lru } from './dist/toad-cache.mjs'
33

4-
const nth = 2e3,
5-
cache = new Lru(nth),
6-
data = new Array(nth)
4+
const nth = 2e3
5+
const cache = new Lru(nth)
6+
const data = new Array(nth)
77

88
function seed() {
99
let i = -1
@@ -40,7 +40,9 @@ function bench(n = 0, x = 1, type = 'set') {
4040
populate(cache, n)
4141
timer.stop()
4242
console.log(
43-
`Run ${x} ${x === 1 ? 'Set' : 'Evict'} (${n === 0 ? 'Low Keys' : 'High Keys'}): ${timer.diff() / 1e6} ms`,
43+
`Run ${x} ${x === 1 ? 'Set' : 'Evict'} (${n === 0 ? 'Low Keys' : 'High Keys'}): ${
44+
timer.diff() / 1e6
45+
} ms`,
4446
)
4547
} else if (type === 'get') {
4648
const timer = precise().start()

biome.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
3+
"javascript": {
4+
"formatter": {
5+
"arrowParentheses": "always",
6+
"indentStyle": "space",
7+
"semicolons": "asNeeded",
8+
"trailingComma": "all",
9+
"lineWidth": 100,
10+
"quoteStyle": "single"
11+
}
12+
},
13+
"linter": {
14+
"rules": {
15+
"style": {
16+
"useConst": "off",
17+
"noVar": "off"
18+
},
19+
"correctness": {
20+
"noInnerDeclarations": "off"
21+
},
22+
"suspicious": {
23+
"noGlobalIsNan": "off"
24+
},
25+
"complexity": {
26+
"useLiteralKeys": "off"
27+
}
28+
}
29+
}
30+
}

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { FifoMap } from './src/FifoMap.js'
2+
import { FifoObject } from './src/FifoObject.js'
3+
import { HitStatisticsRecord } from './src/HitStatisticsRecord.js'
24
import { LruMap } from './src/LruMap.js'
35
import { LruObject } from './src/LruObject.js'
46
import { LruObjectHitStatistics } from './src/LruObjectHitStatistics.js'
5-
import { FifoObject } from './src/FifoObject.js'
6-
import { HitStatisticsRecord } from './src/HitStatisticsRecord.js'
77

88
export { FifoObject }
99
export { FifoMap }

package.json

+7-10
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
"build": "del-cli dist && del-cli coverage && npm run rollup",
4343
"benchmark": "npm run build && node benchmark.js",
4444
"changelog": "auto-changelog -p",
45-
"lint": "eslint *.js src/*.js test/*.js",
46-
"lint:fix": "eslint --fix *.js src/*.js test/*.js && prettier --write \"{src,test}/**/*.js\" benchmark.js",
45+
"lint": "biome lint index.js benchmark.js src test biome.json",
46+
"lint:fix": "biome check --apply index.js benchmark.js src test biome.json",
4747
"rollup": "rollup --config",
4848
"test": "vitest",
4949
"test:coverage": "npm run rollup && npm run test -- --coverage",
@@ -53,19 +53,16 @@
5353
"prepublishOnly": "npm run build"
5454
},
5555
"devDependencies": {
56-
"@vitest/coverage-v8": "^1.0.0",
56+
"@biomejs/biome": "^1.5.3",
57+
"@vitest/coverage-v8": "^1.2.2",
5758
"@rollup/plugin-terser": "^0.4.4",
5859
"auto-changelog": "^2.4.0",
5960
"del-cli": "^5.1.0",
60-
"eslint": "^8.50.0",
61-
"eslint-config-prettier": "^9.0.0",
62-
"eslint-plugin-import": "^2.28.1",
63-
"eslint-plugin-prettier": "^5.0.0",
6461
"precise": "^4.0.0",
6562
"rollup": "^4.6.0",
66-
"vitest": "^1.1.3",
67-
"tsd": "^0.30.0",
68-
"typescript": "^5.3.2"
63+
"vitest": "^1.2.2",
64+
"tsd": "^0.30.4",
65+
"typescript": "^5.3.3"
6966
},
7067
"keywords": [
7168
"LRU",

src/LruObjectHitStatistics.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { LruObject } from './LruObject.js'
21
import { HitStatistics } from './HitStatistics.js'
2+
import { LruObject } from './LruObject.js'
33

44
export class LruObjectHitStatistics extends LruObject {
55
constructor(max, ttlInMsecs, cacheId, globalStatisticsRecord, statisticTtlInHours) {

test/FifoMap.spec.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import assert from 'node:assert'
2-
import { it, describe, beforeEach, expect } from 'vitest'
2+
import { setTimeout } from 'timers/promises'
3+
import { beforeEach, describe, expect, it } from 'vitest'
34
import { FifoMap } from '../src/FifoMap.js'
45
import { items, populateCache } from './utils/cachePopulator.js'
5-
import { setTimeout } from 'timers/promises'
66

7-
describe('FifoMap', function () {
7+
describe('FifoMap', () => {
88
let cache
99

10-
beforeEach(function () {
10+
beforeEach(() => {
1111
cache = new FifoMap(4)
1212
populateCache(cache)
1313
})
@@ -33,7 +33,7 @@ describe('FifoMap', function () {
3333
})
3434

3535
describe('evict', () => {
36-
it('It should evict', function () {
36+
it('It should evict', () => {
3737
expect(cache.first.key).toBe('b')
3838
expect(cache.last.key).toBe('e')
3939
expect(cache.size).toBe(4)
@@ -115,7 +115,7 @@ describe('FifoMap', function () {
115115
})
116116

117117
describe('delete', () => {
118-
it('It should delete', function () {
118+
it('It should delete', () => {
119119
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
120120
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
121121
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -165,7 +165,7 @@ describe('FifoMap', function () {
165165
})
166166

167167
describe('deleteMany', () => {
168-
it('It should delete', function () {
168+
it('It should delete', () => {
169169
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
170170
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
171171
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -211,7 +211,7 @@ describe('FifoMap', function () {
211211
})
212212

213213
describe('core', () => {
214-
it('It should handle a small evict', function () {
214+
it('It should handle a small evict', () => {
215215
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
216216
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
217217
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -247,7 +247,7 @@ describe('FifoMap', function () {
247247
assert.strictEqual(cache.size, 2, "Should be '2'")
248248
})
249249

250-
it('It should handle an empty evict', function () {
250+
it('It should handle an empty evict', () => {
251251
cache = new FifoMap(1)
252252
assert.strictEqual(cache.first, null, "Should be 'null'")
253253
assert.strictEqual(cache.last, null, "Should be 'null'")
@@ -258,7 +258,7 @@ describe('FifoMap', function () {
258258
assert.strictEqual(cache.size, 0, "Should be 'null'")
259259
})
260260

261-
it('It should expose expiration time', function () {
261+
it('It should expose expiration time', () => {
262262
cache = new FifoMap(1, 6e4)
263263
cache.set(items[0], false)
264264
assert.strictEqual(typeof cache.expiresAt(items[0]), 'number', 'Should be a number')

test/FifoObject.spec.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import assert from 'node:assert'
2-
import { it, describe, beforeEach, expect } from 'vitest'
2+
import { setTimeout } from 'timers/promises'
3+
import { beforeEach, describe, expect, it } from 'vitest'
34
import { FifoObject } from '../src/FifoObject.js'
45
import { items, populateCache } from './utils/cachePopulator.js'
5-
import { setTimeout } from 'timers/promises'
66

7-
describe('FifoObject', function () {
7+
describe('FifoObject', () => {
88
let cache
99

10-
beforeEach(function () {
10+
beforeEach(() => {
1111
cache = new FifoObject(4)
1212
populateCache(cache)
1313
})
@@ -33,7 +33,7 @@ describe('FifoObject', function () {
3333
})
3434

3535
describe('evict', () => {
36-
it('It should evict', function () {
36+
it('It should evict', () => {
3737
expect(cache.first.key).toBe('b')
3838
expect(cache.last.key).toBe('e')
3939
expect(cache.size).toBe(4)
@@ -115,7 +115,7 @@ describe('FifoObject', function () {
115115
})
116116

117117
describe('delete', () => {
118-
it('It should delete', function () {
118+
it('It should delete', () => {
119119
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
120120
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
121121
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -165,7 +165,7 @@ describe('FifoObject', function () {
165165
})
166166

167167
describe('deleteMany', () => {
168-
it('It should delete', function () {
168+
it('It should delete', () => {
169169
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
170170
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
171171
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -211,7 +211,7 @@ describe('FifoObject', function () {
211211
})
212212

213213
describe('core', () => {
214-
it('It should handle a small evict', function () {
214+
it('It should handle a small evict', () => {
215215
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
216216
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
217217
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -247,7 +247,7 @@ describe('FifoObject', function () {
247247
assert.strictEqual(cache.size, 2, "Should be '2'")
248248
})
249249

250-
it('It should handle an empty evict', function () {
250+
it('It should handle an empty evict', () => {
251251
cache = new FifoObject(1)
252252
assert.strictEqual(cache.first, null, "Should be 'null'")
253253
assert.strictEqual(cache.last, null, "Should be 'null'")
@@ -258,7 +258,7 @@ describe('FifoObject', function () {
258258
assert.strictEqual(cache.size, 0, "Should be 'null'")
259259
})
260260

261-
it('It should expose expiration time', function () {
261+
it('It should expose expiration time', () => {
262262
cache = new FifoObject(1, 6e4)
263263
cache.set(items[0], false)
264264
assert.strictEqual(typeof cache.expiresAt(items[0]), 'number', 'Should be a number')

test/HitStatistics.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { afterEach, beforeEach, describe, expect, it, vitest } from 'vitest'
12
import { HitStatistics } from '../src/HitStatistics.js'
2-
import { it, describe, expect, beforeEach, afterEach, vitest } from 'vitest'
33
import { HitStatisticsRecord } from '../src/HitStatisticsRecord.js'
44

55
describe('HitStatistics', () => {

test/HitStatisticsRecord.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { describe, expect, it } from 'vitest'
12
import { HitStatisticsRecord } from '../src/HitStatisticsRecord.js'
23
import { getTimestamp } from '../src/utils/dateUtils.js'
3-
import { it, describe, expect } from 'vitest'
44

55
describe('HitStatisticsRecord', () => {
66
describe('resetForCache', () => {

test/LruMap.spec.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import assert from 'node:assert'
2-
import { it, describe, beforeEach, expect } from 'vitest'
2+
import { setTimeout } from 'timers/promises'
3+
import { beforeEach, describe, expect, it } from 'vitest'
34
import { LruMap } from '../src/LruMap.js'
45
import { items, populateCache } from './utils/cachePopulator.js'
5-
import { setTimeout } from 'timers/promises'
66

7-
describe('LruMap', function () {
7+
describe('LruMap', () => {
88
let cache
99

10-
beforeEach(function () {
10+
beforeEach(() => {
1111
cache = new LruMap(4)
1212
populateCache(cache)
1313
})
@@ -33,7 +33,7 @@ describe('LruMap', function () {
3333
})
3434

3535
describe('evict', () => {
36-
it('It should evict', function () {
36+
it('It should evict', () => {
3737
expect(cache.first.key).toBe('b')
3838
expect(cache.last.key).toBe('e')
3939
expect(cache.size).toBe(4)
@@ -143,7 +143,7 @@ describe('LruMap', function () {
143143
})
144144

145145
describe('delete', () => {
146-
it('It should delete', function () {
146+
it('It should delete', () => {
147147
expect(cache.first.key).toBe('b')
148148
expect(cache.last.key).toBe('e')
149149
expect(cache.size).toBe(4)
@@ -193,7 +193,7 @@ describe('LruMap', function () {
193193
})
194194

195195
describe('deleteMany', () => {
196-
it('It should delete', function () {
196+
it('It should delete', () => {
197197
expect(cache.first.key).toBe('b')
198198
expect(cache.last.key).toBe('e')
199199
expect(cache.size).toBe(4)
@@ -240,7 +240,7 @@ describe('LruMap', function () {
240240
})
241241

242242
describe('core', () => {
243-
it('It should handle a small evict', function () {
243+
it('It should handle a small evict', () => {
244244
assert.strictEqual(cache.first.key, 'b', "Should be 'b'")
245245
assert.strictEqual(cache.last.key, 'e', "Should be 'e'")
246246
assert.strictEqual(cache.size, 4, "Should be '4'")
@@ -276,7 +276,7 @@ describe('LruMap', function () {
276276
assert.strictEqual(cache.size, 2, "Should be '2'")
277277
})
278278

279-
it('It should handle an empty evict', function () {
279+
it('It should handle an empty evict', () => {
280280
cache = new LruMap(1)
281281
assert.strictEqual(cache.first, null, "Should be 'null'")
282282
assert.strictEqual(cache.last, null, "Should be 'null'")

0 commit comments

Comments
 (0)