Skip to content

Commit

Permalink
chore(dependencies): update eslint 8->9
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli authored and djwhitt committed Jan 30, 2025
1 parent 8b82345 commit 06b382c
Show file tree
Hide file tree
Showing 14 changed files with 414 additions and 295 deletions.
45 changes: 0 additions & 45 deletions .eslintrc

This file was deleted.

84 changes: 84 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import header from 'eslint-plugin-header';
import jestFormatting from 'eslint-plugin-jest-formatting';
import prettier from 'eslint-plugin-prettier';
import unicorn from 'eslint-plugin-unicorn';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// workaround: https://github.com/Stuk/eslint-plugin-header/issues/57#issuecomment-2378485611
header.rules.header.meta.schema = false;
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends(
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
),
{
plugins: {
'@typescript-eslint': typescriptEslint,
header,
'jest-formatting': jestFormatting,
prettier,
unicorn,
},

languageOptions: {
parser: tsParser,
ecmaVersion: 5,
sourceType: 'script',

parserOptions: {
project: 'tsconfig.json',
},
},

rules: {
'@typescript-eslint/no-explicit-any': ['off'],
'@typescript-eslint/no-unused-vars': ['off'],

'@typescript-eslint/strict-boolean-expressions': [
2,
{
allowNullableObject: true,
allowNullableBoolean: true,
allowAny: true,
},
],

eqeqeq: ['error', 'smart'],
'jest-formatting/padding-around-describe-blocks': 2,
'jest-formatting/padding-around-test-blocks': 2,
'header/header': [2, './resources/license.header.js'],
'mocha/max-top-level-suites': 'off',
'mocha/no-exports': 'off',
'mocha/no-mocha-arrows': 'off',
'no-console': 0,
'no-return-await': 2,
'no-unneeded-ternary': 2,
'no-unused-vars': 'off',

'prettier/prettier': [
'error',
{
endOfLine: 'auto',
},
],

'unicorn/prefer-node-protocol': 2,
},
},
];
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
},
"devDependencies": {
"@aws-lite/s3-types": "^0.2.6",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.19.0",
"@smithy/types": "^3.7.2",
"@swc/core": "^1.10.12",
"@testcontainers/localstack": "^10.17.2",
Expand All @@ -72,16 +74,16 @@
"@types/stream-json": "^1.7.8",
"@types/supertest": "^2.0.16",
"@types/swagger-ui-express": "^4.1.7",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^8.22.0",
"@typescript-eslint/parser": "^8.22.0",
"c8": "^8.0.1",
"copyfiles": "^2.4.1",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-jest-formatting": "^3.1.0",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-unicorn": "^49.0.0",
"eslint-plugin-unicorn": "^56.0.1",
"msgpack-lite": "^0.1.26",
"nodemon": "^2.0.22",
"npm-check-updates": "^16.14.20",
Expand Down
4 changes: 3 additions & 1 deletion src/data/ar-io-data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export class ArIODataSource implements ContiguousDataSource {
}

stopUpdatingPeers() {
this.intervalId && clearInterval(this.intervalId);
if (this.intervalId) {
clearInterval(this.intervalId);
}
}

async updatePeerList() {
Expand Down
4 changes: 2 additions & 2 deletions src/data/gateways-data-source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { Readable } from 'node:stream';

const axiosMockCommonParams = (config: any) => ({
interceptors: {
request: { use: () => {} }, // eslint-disable-line @typescript-eslint/no-empty-function
response: { use: () => {} }, // eslint-disable-line @typescript-eslint/no-empty-function
request: { use: () => {} },
response: { use: () => {} },
},
defaults: config,
});
Expand Down
11 changes: 5 additions & 6 deletions src/data/read-through-data-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('ReadThroughDataCache', function () {
123,
);

assert.deepEqual(calledWithArgument!, 'test-hash'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.deepEqual(calledWithArgument!, 'test-hash');
assert.deepEqual(result?.stream, mockStream);
assert.deepEqual(result?.size, 123);
});
Expand All @@ -192,7 +192,7 @@ describe('ReadThroughDataCache', function () {
123,
);

assert.deepEqual(calledWithArgument!, 'test-hash'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.deepEqual(calledWithArgument!, 'test-hash');

assert.deepEqual(result, undefined);
});
Expand Down Expand Up @@ -227,9 +227,9 @@ describe('ReadThroughDataCache', function () {
20,
);

assert.deepEqual(calledWithArgument!, 'test-hash'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.deepEqual(calledWithArgument!, 'test-hash');

assert.deepEqual(calledWithParentArgument!, 'test-parent-hash'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.deepEqual(calledWithParentArgument!, 'test-parent-hash');

assert.deepEqual(result?.stream, mockStream);
assert.deepEqual(result?.size, 20);
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('ReadThroughDataCache', function () {
origin: 'node-url',
},
});
assert.equal(calledWithArgument!, 'test-hash'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(calledWithArgument!, 'test-hash');

let receivedData = '';

Expand Down Expand Up @@ -381,7 +381,6 @@ describe('ReadThroughDataCache', function () {
requestAttributes,
});

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
assert.deepEqual(calledWithArgument!, {
id: 'test-id',
dataAttributes: undefined,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function sanityCheckBlock(block: PartialJsonBlock) {
throw new Error("Invalid block: invalid 'indep_hash' format");
}

if (!block.height === undefined) {
if (!block.height === false) {
throw new Error("Invalid block: missing 'height'");
}

Expand Down
12 changes: 6 additions & 6 deletions src/store/kv-debounce-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('KvDebounceCache', () => {
await kvDebounceCache.set(key, Buffer.from('test2', 'base64url'));
const result = await kvDebounceCache.get(key);
assert.notEqual(result, undefined);
assert.equal(toB64Url(result!), 'test'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(toB64Url(result!), 'test');
});

describe('debounceFn', () => {
Expand All @@ -78,7 +78,7 @@ describe('KvDebounceCache', () => {
});
await kvDebounceStore.get(key);
const result = await kvBufferStore.get(key);
assert.equal(result!.toString('utf-8'), 'test'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(result!.toString('utf-8'), 'test');
assert.equal(callCount, 1);
});

Expand All @@ -101,7 +101,7 @@ describe('KvDebounceCache', () => {
},
});
const result = await kvBufferStore.get(key);
assert.equal(result, undefined); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(result, undefined);
assert.equal(callCount, 0);
assert.equal(lastCallTimestamp, 0);
});
Expand Down Expand Up @@ -138,7 +138,7 @@ describe('KvDebounceCache', () => {
const result = await kvDebounceStore.get(key);
assert.equal(callCount, 2);
assert.ok(lastCallTimestamp >= Date.now() - 10);
assert.equal(result!.toString('utf-8'), '1'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(result!.toString('utf-8'), '1');
});

it('should call debounceFn on cache hit after the cache hit debounce ttl expires', async () => {
Expand All @@ -163,7 +163,7 @@ describe('KvDebounceCache', () => {

// should hydrate immediately
const result = await kvDebounceStore.get(key);
assert.equal(result!.toString('utf-8'), 'test0'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(result!.toString('utf-8'), 'test0');
assert.ok(lastCallTimestamp <= Date.now());
assert.equal(callCount, 1);

Expand All @@ -172,7 +172,7 @@ describe('KvDebounceCache', () => {
assert.equal(callCount, 2);
assert.ok(lastCallTimestamp >= Date.now() - 100);
const result2 = await kvDebounceStore.get(key);
assert.equal(result2!.toString('utf-8'), 'test1'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(result2!.toString('utf-8'), 'test1');
});

// intentional design choice to bubble up errors from debounceFn and let the caller handle them appropriately
Expand Down
8 changes: 4 additions & 4 deletions src/store/lmdb-kv-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('LmdbKvStore', () => {
await lmdbKvStore.set(key, value);
const result = await lmdbKvStore.get(key);
assert.notEqual(result, undefined);
assert.equal(toB64Url(result!), 'test'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(toB64Url(result!), 'test');
});

it('should properly delete buffer', async () => {
Expand All @@ -59,9 +59,9 @@ describe('LmdbKvStore', () => {
await lmdbKvStore.set(key, value);
await lmdbKvStore.set(key, Buffer.from('test2', 'base64url'));
const result = await lmdbKvStore.get(key);
assert.notEqual(result, undefined); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.notEqual(result, undefined);

assert.equal(toB64Url(result!), 'test'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(toB64Url(result!), 'test');
});

it('should return a buffer when a Uint8Array is stored in the cache', async () => {
Expand All @@ -74,6 +74,6 @@ describe('LmdbKvStore', () => {
const result = await lmdbKvStore.get(key);
assert.notEqual(result, undefined);
assert.equal(Buffer.isBuffer(result), true);
assert.equal(toB64Url(result!), 'test'); // eslint-disable-line @typescript-eslint/no-non-null-assertion
assert.equal(toB64Url(result!), 'test');
});
});
4 changes: 3 additions & 1 deletion src/workers/sqlite-wal-cleanup-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export class SQLiteWalCleanupWorker {
}

stop(): void {
this.intervalId && clearInterval(this.intervalId);
if (this.intervalId) {
clearInterval(this.intervalId);
}
this.log.info(
`Stopped SQLite WAL cleanup worker for ${this.dbName} database`,
);
Expand Down
4 changes: 3 additions & 1 deletion src/workers/transaction-offset-repair-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ export class TransactionOffsetRepairWorker {
async stop(): Promise<void> {
const log = this.log.child({ method: 'stop' });

this.intervalId && clearInterval(this.intervalId);
if (this.intervalId) {
clearInterval(this.intervalId);
}

log.debug('Stopped successfully.');
}
Expand Down
4 changes: 3 additions & 1 deletion src/workers/transaction-repair-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export class TransactionRepairWorker {
async stop(): Promise<void> {
const log = this.log.child({ method: 'stop' });

this.intervalId && clearInterval(this.intervalId);
if (this.intervalId) {
clearInterval(this.intervalId);
}

log.debug('Stopped successfully.');
}
Expand Down
1 change: 0 additions & 1 deletion test/sqlite-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export let dataDb: Sqlite.Database;
export let moderationDb: Sqlite.Database;
export let bundlesDb: Sqlite.Database;

/* eslint-disable */
before(async () => {
log.transports.forEach((t) => (t.silent = true));
fs.readdirSync('test/tmp').forEach((file) => {
Expand Down
Loading

0 comments on commit 06b382c

Please sign in to comment.