This is an automated email from the ASF dual-hosted git repository.
HTHou pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/iotdb-client-nodejs.git
The following commit(s) were added to refs/heads/develop by this push:
new 02aedeb chore: fix all ESLint errors (#30)
02aedeb is described below
commit 02aedeb7426271c0ef84922de731cf6a2548164d
Author: CritasWang <[email protected]>
AuthorDate: Fri Sep 11 12:21:01 2026 +0800
chore: fix all ESLint errors (#30)
npm run lint failed with 56 errors on develop. Fixes:
- remove unused imports and local variables
- use the optional catch binding (catch {}) where the caught error was
unused
- wrap the variable-length case body in Session.getRowCount in a block to
satisfy no-case-declarations
- drop the unused promise reject parameter in SessionDataSet.close
- declare the NodeJS type namespace in the ESLint config, which no-undef
cannot resolve from @types/node
- examples: close the pool/session instances that were constructed purely to
document the alternative APIs, and export the demo helpers that main()
intentionally does not call because they need a live IoTDB
npm run lint now exits 0 (0 errors, 166 warnings), npm run build passes and
npm run test:unit passes (12 suites / 173 tests).
---
benchmark/benchmark-table-cluster.js | 13 ++++---------
benchmark/benchmark-table.js | 5 ++---
benchmark/benchmark-tree.js | 5 ++---
benchmark/data-generator.js | 2 +-
benchmark/schema-manager.js | 8 ++++----
eslint.config.mjs | 2 ++
examples/basic-session.ts | 1 +
examples/concurrent-operations.ts | 4 ++--
examples/multi-node.ts | 3 +++
examples/session-pool.ts | 1 +
examples/ssl-connection.ts | 2 +-
examples/table-session-pool.ts | 3 +++
src/client/ColumnDecoder.ts | 1 -
src/client/Session.ts | 18 ++++++++++--------
src/client/SessionDataSet.ts | 2 +-
src/client/TableSessionPool.ts | 2 +-
tests/e2e/AllDataTypes.test.ts | 2 +-
tests/e2e/LargeQuery.test.ts | 4 ++--
tests/e2e/MultiNode.test.ts | 2 +-
tests/e2e/Session.test.ts | 4 ++--
tests/e2e/SessionDataSet.test.ts | 6 +++---
tests/e2e/SessionPool.test.ts | 6 +++---
tests/e2e/TableModelDataTypes.test.ts | 6 +++---
tests/e2e/TableSessionPool.test.ts | 10 +++++-----
24 files changed, 58 insertions(+), 54 deletions(-)
diff --git a/benchmark/benchmark-table-cluster.js
b/benchmark/benchmark-table-cluster.js
index 47a7352..890aa9a 100644
--- a/benchmark/benchmark-table-cluster.js
+++ b/benchmark/benchmark-table-cluster.js
@@ -79,10 +79,6 @@ const INSERT_DATATYPE_PROPORTION = {
[TSDataType.BOOLEAN]: 0.1,
};
-// Generate sensor types ONCE with fixed seed for consistency across all
processes
-// This ensures schema and data match
-const SENSOR_TYPES = distributeSensorTypes(SENSOR_NUMBER,
INSERT_DATATYPE_PROPORTION);
-
if (cluster.isPrimary) {
// ============== PRIMARY PROCESS ==============
runPrimary();
@@ -181,7 +177,7 @@ async function runPrimary() {
}
async function createSchema() {
- const { TableSessionPool, ColumnCategory } = require('../dist');
+ const { TableSessionPool } = require('../dist');
const pool = new TableSessionPool(IOTDB_HOST, IOTDB_PORT, {
username: IOTDB_USER,
@@ -197,7 +193,7 @@ async function createSchema() {
// Drop existing database
try {
await pool.executeNonQueryStatement(`DROP DATABASE ${DATABASE_NAME}`);
- } catch (e) {
+ } catch {
// Ignore if not exists
}
@@ -291,7 +287,7 @@ async function runWorker() {
if (i >= warmupTablets.length) break;
try {
await session.insertTablet(warmupTablets[i]);
- } catch (e) { /* ignore */ }
+ } catch { /* ignore */ }
}
}));
} finally {
@@ -318,7 +314,6 @@ async function runWorker() {
const tablets = buildTabletsForLoop(devices, sharedBatch, loopIdx,
ColumnCategory);
let tabletIndex = 0;
- const loopStartTime = performance.now();
await Promise.all(sessions.map(async (session) => {
while (tabletIndex < tablets.length) {
@@ -334,7 +329,7 @@ async function runWorker() {
totalLatency += latency;
totalOperations++;
totalDataPoints += tablet.timestamps.length *
(tablet.columnNames.length - 1); // -1 for device_id
- } catch (error) {
+ } catch {
// Count as failed but continue
}
}
diff --git a/benchmark/benchmark-table.js b/benchmark/benchmark-table.js
index b197a50..f8907be 100755
--- a/benchmark/benchmark-table.js
+++ b/benchmark/benchmark-table.js
@@ -41,8 +41,7 @@
const { TableSessionPool } = require('../dist');
const { createConfig, printConfig } = require('./config');
const { prepareTestData } = require('./data-generator');
-const { createTableModelSchema, cleanupSchema } = require('./schema-manager');
-const { runBatchBenchmark } = require('./benchmark-core');
+const { createTableModelSchema } = require('./schema-manager');
// Import ColumnCategory from dist
const { ColumnCategory } = require('../dist');
@@ -233,7 +232,7 @@ async function runStreamingBenchmark(pool, testData,
config) {
if (i >= warmupTablets.length) break;
try {
await session.insertTablet(warmupTablets[i]);
- } catch (e) { /* ignore warmup errors */ }
+ } catch { /* ignore warmup errors */ }
}
});
await Promise.all(workers);
diff --git a/benchmark/benchmark-tree.js b/benchmark/benchmark-tree.js
index d28f623..3f8b4d4 100755
--- a/benchmark/benchmark-tree.js
+++ b/benchmark/benchmark-tree.js
@@ -41,8 +41,7 @@
const { SessionPool } = require('../dist');
const { createConfig, printConfig } = require('./config');
const { prepareTestData } = require('./data-generator');
-const { createTreeModelSchema, cleanupSchema } = require('./schema-manager');
-const { runBatchBenchmark } = require('./benchmark-core');
+const { createTreeModelSchema } = require('./schema-manager');
/**
* Create session pool for tree model
@@ -213,7 +212,7 @@ async function runStreamingBenchmark(pool, testData,
config) {
if (i >= warmupTablets.length) break;
try {
await session.insertTablet(warmupTablets[i]);
- } catch (e) { /* ignore warmup errors */ }
+ } catch { /* ignore warmup errors */ }
}
});
await Promise.all(workers);
diff --git a/benchmark/data-generator.js b/benchmark/data-generator.js
index 417d73d..3d96687 100644
--- a/benchmark/data-generator.js
+++ b/benchmark/data-generator.js
@@ -411,7 +411,7 @@ async function isDataFileValid(filePath, config) {
}
return true;
- } catch (error) {
+ } catch {
return false;
}
}
diff --git a/benchmark/schema-manager.js b/benchmark/schema-manager.js
index 0b50553..c89a597 100644
--- a/benchmark/schema-manager.js
+++ b/benchmark/schema-manager.js
@@ -91,7 +91,7 @@ async function createTreeModelSchema(session, testData,
config) {
`DROP DEVICE TEMPLATE ${templateName}`
);
console.log(' ✓ Existing template dropped');
- } catch (error) {
+ } catch {
console.log(' ℹ Template does not exist, will create new one');
}
@@ -182,7 +182,7 @@ async function createTableModelSchema(session, testData,
config) {
try {
await session.executeNonQueryStatement(`DROP TABLE
${config.TABLE_NAME}`);
console.log(' ✓ Dropped existing table');
- } catch (error) {
+ } catch {
// Ignore if table doesn't exist
}
@@ -234,7 +234,7 @@ async function cleanupSchema(session, model, config) {
`DELETE DATABASE ${config.STORAGE_GROUP_PREFIX}.*`
);
console.log(' ✓ Storage group deleted');
- } catch (error) {
+ } catch {
console.log(' ℹ Storage group does not exist or already deleted');
}
} else if (model === 'table') {
@@ -244,7 +244,7 @@ async function cleanupSchema(session, model, config) {
`DROP DATABASE ${config.DATABASE_NAME}`
);
console.log(' ✓ Database dropped');
- } catch (error) {
+ } catch {
console.log(' ℹ Database does not exist or already deleted');
}
}
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 4f4a530..296370d 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -17,6 +17,8 @@ export default [
globals: {
...globals.node,
...globals.es2020,
+ // Type namespace provided by @types/node; no-undef cannot see it.
+ NodeJS: 'readonly',
},
},
plugins: {
diff --git a/examples/basic-session.ts b/examples/basic-session.ts
index 81f2d1b..6a4c7f5 100644
--- a/examples/basic-session.ts
+++ b/examples/basic-session.ts
@@ -116,6 +116,7 @@ async function main() {
// Close the session
console.log("\nClosing session...");
await session.close();
+ await session2.close();
console.log("Session closed");
}
}
diff --git a/examples/concurrent-operations.ts
b/examples/concurrent-operations.ts
index cb6d218..14691ac 100644
--- a/examples/concurrent-operations.ts
+++ b/examples/concurrent-operations.ts
@@ -20,7 +20,7 @@ import {
createSemaphore
} from "../src";
-async function demonstrateSessionApis() {
+export async function demonstrateSessionApis() {
console.log("=== Session Concurrent APIs ===\n");
const session = new Session({
@@ -90,7 +90,7 @@ async function demonstrateSessionApis() {
}
}
-async function demonstratePoolApis() {
+export async function demonstratePoolApis() {
console.log("\n=== SessionPool Concurrent APIs ===\n");
const pool = new SessionPool("localhost", 6667, {
diff --git a/examples/multi-node.ts b/examples/multi-node.ts
index a5597c7..b9a270a 100644
--- a/examples/multi-node.ts
+++ b/examples/multi-node.ts
@@ -102,6 +102,9 @@ async function main() {
console.error('Error:', error);
} finally {
await pool.close();
+ await pool2.close();
+ await pool3.close();
+ await pool4.close();
console.log('Pool closed');
}
}
diff --git a/examples/session-pool.ts b/examples/session-pool.ts
index 8ed3cb3..f5a949d 100644
--- a/examples/session-pool.ts
+++ b/examples/session-pool.ts
@@ -179,6 +179,7 @@ async function main() {
// Close the pool
console.log("\nClosing session pool...");
await pool.close();
+ await pool2.close();
console.log("Pool closed");
}
}
diff --git a/examples/ssl-connection.ts b/examples/ssl-connection.ts
index 5fcf3de..f53d992 100644
--- a/examples/ssl-connection.ts
+++ b/examples/ssl-connection.ts
@@ -55,7 +55,7 @@ async function main() {
}
// For self-signed certificates or testing, you can use:
-async function selfSignedExample() {
+export async function selfSignedExample() {
const session = new Session({
host: 'localhost',
port: 6667,
diff --git a/examples/table-session-pool.ts b/examples/table-session-pool.ts
index 65ab0be..02cb821 100644
--- a/examples/table-session-pool.ts
+++ b/examples/table-session-pool.ts
@@ -213,6 +213,9 @@ async function main() {
} finally {
console.log("\nClosing table session pool...");
await pool.close();
+ await pool2.close();
+ await pool3.close();
+ await pool4.close();
console.log("Table pool closed");
}
}
diff --git a/src/client/ColumnDecoder.ts b/src/client/ColumnDecoder.ts
index 25d5c13..436d1a3 100644
--- a/src/client/ColumnDecoder.ts
+++ b/src/client/ColumnDecoder.ts
@@ -17,7 +17,6 @@
* under the License.
*/
-import { logger } from "../utils/Logger";
import { parseIntToDate } from "../utils/DataTypes";
/**
diff --git a/src/client/Session.ts b/src/client/Session.ts
index ef6424a..31d1103 100644
--- a/src/client/Session.ts
+++ b/src/client/Session.ts
@@ -29,7 +29,7 @@ import { registerClosable, unregisterClosable } from
"../utils/ProcessCleanup";
import { SessionDataSet } from "./SessionDataSet";
import { RowRecord } from "./RowRecord";
import { BaseColumnDecoder, ColumnEncoding, Column } from "./ColumnDecoder";
-import { RedirectException, isWildcardAddress } from "../utils/Errors";
+import { isWildcardAddress } from "../utils/Errors";
import {
serializeTabletValuesFast,
serializeTimestamps
@@ -1179,14 +1179,16 @@ export class Session {
case 10: // BLOB - variable length
case 11: // STRING - variable length
// For variable-length types, count entries by parsing length prefixes
- let count = 0;
- let offset = 0;
- while (offset + 4 <= length) {
- const strLength = buffer.readInt32BE(offset);
- offset += 4 + strLength;
- count++;
+ {
+ let count = 0;
+ let offset = 0;
+ while (offset + 4 <= length) {
+ const strLength = buffer.readInt32BE(offset);
+ offset += 4 + strLength;
+ count++;
+ }
+ return count;
}
- return count;
default:
logger.warn(
`Unknown data type ${dataType}, cannot determine row count`,
diff --git a/src/client/SessionDataSet.ts b/src/client/SessionDataSet.ts
index ecaeb8a..c0b8f99 100644
--- a/src/client/SessionDataSet.ts
+++ b/src/client/SessionDataSet.ts
@@ -412,7 +412,7 @@ export class SessionDataSet {
statementId: this.statementId,
});
- await new Promise<void>((resolve, reject) => {
+ await new Promise<void>((resolve) => {
client.closeOperation(req, (err: Error, response: any) => {
if (err) {
logger.warn(`Error closing query operation: ${err.message}`);
diff --git a/src/client/TableSessionPool.ts b/src/client/TableSessionPool.ts
index 3eacb0c..bfeb4c1 100644
--- a/src/client/TableSessionPool.ts
+++ b/src/client/TableSessionPool.ts
@@ -18,7 +18,7 @@
*/
import { TableSession } from "./TableSession";
-import { Session, TableTablet, TreeTablet } from "./Session";
+import { Session } from "./Session";
import { PoolConfig, SQL_DIALECT_TABLE, InternalConfig } from
"../utils/Config";
import { BaseSessionPool } from "./BaseSessionPool";
import { logger } from "../utils/Logger";
diff --git a/tests/e2e/AllDataTypes.test.ts b/tests/e2e/AllDataTypes.test.ts
index 184badb..de63ec9 100644
--- a/tests/e2e/AllDataTypes.test.ts
+++ b/tests/e2e/AllDataTypes.test.ts
@@ -39,7 +39,7 @@ describe("All Data Types E2E Tests", () => {
try {
await session.open();
console.log("Connected to IoTDB for all data types test");
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. E2E tests will be skipped.");
console.warn(
"Set IOTDB_HOST, IOTDB_PORT to run E2E tests against a real instance.",
diff --git a/tests/e2e/LargeQuery.test.ts b/tests/e2e/LargeQuery.test.ts
index b5c81c2..c44e56f 100644
--- a/tests/e2e/LargeQuery.test.ts
+++ b/tests/e2e/LargeQuery.test.ts
@@ -40,7 +40,7 @@ describe("Large Query E2E Tests", () => {
try {
await session.open();
console.log("Connected to IoTDB for large query tests");
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. E2E tests will be skipped.");
console.warn(
"Set IOTDB_HOST, IOTDB_PORT to run E2E tests against a real instance.",
@@ -58,7 +58,7 @@ describe("Large Query E2E Tests", () => {
// Cleanup test data
try {
await session.executeNonQueryStatement("DROP DATABASE root.test");
- } catch (error) {
+ } catch {
// Ignore cleanup errors
}
await session.close();
diff --git a/tests/e2e/MultiNode.test.ts b/tests/e2e/MultiNode.test.ts
index d01ce24..7c2c6fb 100644
--- a/tests/e2e/MultiNode.test.ts
+++ b/tests/e2e/MultiNode.test.ts
@@ -103,7 +103,7 @@ describe("Multi-Node E2E Tests", () => {
if (isConnected) {
try {
await pool1.executeNonQueryStatement("DROP DATABASE root.test");
- } catch (error) {
+ } catch {
// Ignore cleanup errors
}
diff --git a/tests/e2e/Session.test.ts b/tests/e2e/Session.test.ts
index 1be2e28..e21b0b2 100644
--- a/tests/e2e/Session.test.ts
+++ b/tests/e2e/Session.test.ts
@@ -38,7 +38,7 @@ describe("Session E2E Tests", () => {
try {
await session.open();
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. E2E tests will be skipped.");
console.warn(
"Set IOTDB_HOST, IOTDB_PORT to run E2E tests against a real instance.",
@@ -56,7 +56,7 @@ describe("Session E2E Tests", () => {
// Cleanup test data
try {
await session.executeNonQueryStatement("DROP DATABASE root.test");
- } catch (e) {
+ } catch {
// Ignore cleanup errors
}
await session.close();
diff --git a/tests/e2e/SessionDataSet.test.ts b/tests/e2e/SessionDataSet.test.ts
index cbd3a5c..2bde591 100644
--- a/tests/e2e/SessionDataSet.test.ts
+++ b/tests/e2e/SessionDataSet.test.ts
@@ -36,7 +36,7 @@ describe("SessionDataSet E2E Tests", () => {
try {
await session.open();
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. Tests will be skipped.");
try {
await session.close();
@@ -61,7 +61,7 @@ describe("SessionDataSet E2E Tests", () => {
// Setup test data
try {
await session.executeNonQueryStatement("DELETE DATABASE root.test");
- } catch (e) {
+ } catch {
// Ignore if doesn't exist
}
@@ -247,7 +247,7 @@ describe("SessionDataSet E2E Tests", () => {
// Setup test data
try {
await session.executeNonQueryStatement("DELETE DATABASE root.test");
- } catch (e) {
+ } catch {
// Ignore
}
diff --git a/tests/e2e/SessionPool.test.ts b/tests/e2e/SessionPool.test.ts
index e5464fb..bda032e 100644
--- a/tests/e2e/SessionPool.test.ts
+++ b/tests/e2e/SessionPool.test.ts
@@ -40,7 +40,7 @@ describe("SessionPool E2E Tests", () => {
try {
await pool.init();
isConnected = true;
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. E2E tests will be skipped.");
console.warn(
"Set IOTDB_HOST, IOTDB_PORT to run E2E tests against a real instance.",
@@ -58,7 +58,7 @@ describe("SessionPool E2E Tests", () => {
// Cleanup test data
try {
await pool.executeNonQueryStatement("DROP DATABASE root.test");
- } catch (error) {
+ } catch {
// Ignore cleanup errors
}
await pool.close();
@@ -182,7 +182,7 @@ describe("SessionPool E2E Tests", () => {
await multiNodePool.init();
expect(multiNodePool.getPoolSize()).toBeGreaterThanOrEqual(1);
await multiNodePool.close();
- } catch (error) {
+ } catch {
console.warn(
"Multi-node test failed, this is expected if IoTDB is not available",
);
diff --git a/tests/e2e/TableModelDataTypes.test.ts
b/tests/e2e/TableModelDataTypes.test.ts
index d00580d..632b85e 100644
--- a/tests/e2e/TableModelDataTypes.test.ts
+++ b/tests/e2e/TableModelDataTypes.test.ts
@@ -47,10 +47,10 @@ describe("Table Model All Data Types E2E Tests", () => {
// Cleanup from previous runs
try {
await pool.executeNonQueryStatement("DROP DATABASE test");
- } catch (e) {
+ } catch {
// Ignore if doesn't exist
}
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. E2E tests will be skipped.");
console.warn(
"Set IOTDB_HOST, IOTDB_PORT to run E2E tests against a real instance.",
@@ -68,7 +68,7 @@ describe("Table Model All Data Types E2E Tests", () => {
// Cleanup test data
try {
await pool.executeNonQueryStatement("DROP DATABASE test");
- } catch (error) {
+ } catch {
// Ignore cleanup errors
}
await pool.close();
diff --git a/tests/e2e/TableSessionPool.test.ts
b/tests/e2e/TableSessionPool.test.ts
index f7fbb78..5ff13a1 100644
--- a/tests/e2e/TableSessionPool.test.ts
+++ b/tests/e2e/TableSessionPool.test.ts
@@ -45,10 +45,10 @@ describe("TableSessionPool E2E Tests", () => {
// Cleanup from previous runs
try {
await pool.executeNonQueryStatement("DROP DATABASE test");
- } catch (e) {
+ } catch {
// Ignore errors if database doesn't exist
}
- } catch (error) {
+ } catch {
console.warn("Could not connect to IoTDB. E2E tests will be skipped.");
console.warn(
"Set IOTDB_HOST, IOTDB_PORT to run E2E tests against a real instance.",
@@ -66,7 +66,7 @@ describe("TableSessionPool E2E Tests", () => {
// Cleanup
try {
await pool.executeNonQueryStatement("DROP DATABASE test");
- } catch (e) {
+ } catch {
// Ignore cleanup errors
}
await pool.close();
@@ -401,7 +401,7 @@ describe("TableSessionPool E2E Tests", () => {
await pool.executeNonQueryStatement(
`CREATE TABLE IF NOT EXISTS ${tableName}(device_id STRING TAG, value
FLOAT FIELD)`
);
- } catch (e: any) {
+ } catch {
// Ignore if already exists
}
@@ -456,7 +456,7 @@ describe("TableSessionPool E2E Tests", () => {
await session.executeNonQueryStatement(
`CREATE TABLE IF NOT EXISTS ${tableName}(device_id STRING TAG,
value FLOAT FIELD)`
);
- } catch (e: any) {
+ } catch {
// Ignore if already exists
}
return tableName;