diff --git a/biome.json b/biome.json index acdac79b..565ee297 100644 --- a/biome.json +++ b/biome.json @@ -14,7 +14,8 @@ "noForEach": "off" }, "a11y": { - "all": false + "all": false, + "useButtonType": { "level": "off" } }, "style": { "noParameterAssign": "off" diff --git a/jest.config.cjs b/jest.config.cjs index 5363db9c..df228a34 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -1,4 +1,4 @@ -const path = require('path'); +const path = require('node:path'); module.exports = { verbose: true, diff --git a/package.json b/package.json index 3306ca25..ef5af3d5 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,7 @@ "pg:clean": "docker rm -f graffypg", "pg:psql": "docker run --name pgrepl -e POSTGRES_PASSWORD=graffy -d postgres:alpine && until docker exec -it pgrepl psql -U postgres; do sleep 0.5; done ; docker rm -f pgrepl" }, - "workspaces": [ - "src/*" - ], + "workspaces": ["src/*"], "author": "aravindet", "license": "Apache-2.0", "bugs": { diff --git a/scripts/build.js b/scripts/build.js index 145166dc..51281610 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,5 +1,5 @@ -import { builtinModules } from 'module'; -import { mkdir, readFile, writeFile } from 'fs/promises'; +import { mkdir, readFile, writeFile } from 'node:fs/promises'; +import { builtinModules } from 'node:module'; import { build as viteBuild } from 'vite'; import { depVersions, peerDepVersions, use } from './deps.js'; import { dst, ownPattern, read, src } from './utils.js'; diff --git a/scripts/jest.setup.js b/scripts/jest.setup.js index aff8e2c3..696629ec 100644 --- a/scripts/jest.setup.js +++ b/scripts/jest.setup.js @@ -1,4 +1,4 @@ -import util from 'util'; +import util from 'node:util'; process.on('unhandledRejection', (reason) => { console.error('Unhandled Promise Rejection:', reason); diff --git a/scripts/package.js b/scripts/package.js index 5c674108..b0479910 100755 --- a/scripts/package.js +++ b/scripts/package.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -import os from 'os'; -import { mkdir, readdir } from 'fs/promises'; +import { mkdir, readdir } from 'node:fs/promises'; +import os from 'node:os'; import pMap from 'p-map'; import mRimraf from 'rimraf'; import yargs from 'yargs'; diff --git a/scripts/tscworker.js b/scripts/tscworker.js index d9055110..86635eb3 100644 --- a/scripts/tscworker.js +++ b/scripts/tscworker.js @@ -1,6 +1,6 @@ -import { dirname } from 'path'; +import { dirname } from 'node:path'; +import { parentPort } from 'node:worker_threads'; import ts from 'typescript'; -import { parentPort } from 'worker_threads'; import { dst, src } from './utils.js'; parentPort.on('message', (message) => { diff --git a/scripts/types.js b/scripts/types.js index a8352f92..e4188cb7 100644 --- a/scripts/types.js +++ b/scripts/types.js @@ -1,4 +1,4 @@ -import { Worker } from 'worker_threads'; +import { Worker } from 'node:worker_threads'; import { root } from './utils.js'; const workerPool = []; diff --git a/scripts/utils.js b/scripts/utils.js index 9b33acf9..7a691e11 100644 --- a/scripts/utils.js +++ b/scripts/utils.js @@ -1,8 +1,8 @@ -import { execFile as cExecFile } from 'child_process'; -import { readFileSync } from 'fs'; -import { join } from 'path'; -import { fileURLToPath } from 'url'; -import { promisify } from 'util'; +import { execFile as cExecFile } from 'node:child_process'; +import { readFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { promisify } from 'node:util'; const execFile = promisify(cExecFile); diff --git a/scripts/version.js b/scripts/version.js index 5095838c..fd3c9974 100644 --- a/scripts/version.js +++ b/scripts/version.js @@ -20,7 +20,7 @@ export default async function version(str) { .reduce((latest, vstring) => { const version = vstring .split(/[.-]/) - .map((seg, i) => (i === 3 ? seg : parseInt(seg))); + .map((seg, i) => (i === 3 ? seg : Number.parseInt(seg))); for (let i = 0; i < 5; i++) { const atPre = i === 3; diff --git a/src/common/coding/decodeTree.js b/src/common/coding/decodeTree.js index 1d543598..d393ee35 100644 --- a/src/common/coding/decodeTree.js +++ b/src/common/coding/decodeTree.js @@ -75,7 +75,7 @@ function decode(nodes = [], { isGraph } = {}) { (allNums && putRanges.length === 1 && cmp(putRanges[0].key, 0) === 0 && - cmp(putRanges[0].end, +Infinity) === 0) + cmp(putRanges[0].end, Number.POSITIVE_INFINITY) === 0) ) { result = result.reduce( (collection, item) => { diff --git a/src/common/coding/decorate.js b/src/common/coding/decorate.js index 01446977..654d6c53 100644 --- a/src/common/coding/decorate.js +++ b/src/common/coding/decorate.js @@ -152,7 +152,7 @@ export default function decorate(rootGraph, rootQuery) { children = descend(children, MIN_KEY); } - const { key, end, limit = Infinity } = encodeArgs(range); + const { key, end, limit = Number.POSITIVE_INFINITY } = encodeArgs(range); const ix = findFirst(children, key); let i = ix; let result; diff --git a/src/common/coding/encodeTree.js b/src/common/coding/encodeTree.js index fc62a76a..5ff00f97 100644 --- a/src/common/coding/encodeTree.js +++ b/src/common/coding/encodeTree.js @@ -142,7 +142,7 @@ function encode(value, { version, isGraph } = {}) { !isDef($val) && !object.some((it) => isDef(it?.$key)) ) { - putRange = [encodeArgs({ $since: 0, $until: +Infinity })]; + putRange = [encodeArgs({ $since: 0, $until: Number.POSITIVE_INFINITY })]; } function classifyPut(put) { diff --git a/src/common/coding/test/number.test.js b/src/common/coding/test/number.test.js index cb0077ed..d8fcda87 100644 --- a/src/common/coding/test/number.test.js +++ b/src/common/coding/test/number.test.js @@ -18,12 +18,12 @@ describe('dencorder', () => { }); test('infinity', () => { - const v = -Infinity; + const v = Number.NEGATIVE_INFINITY; expect(v).toEqual(decode(encode(v))); }); test('nan', () => { - const v = NaN; + const v = Number.NaN; expect(Number.isNaN(decode(encode(v)))).toBe(true); }); }); diff --git a/src/common/ops/slice.js b/src/common/ops/slice.js index 80ec3dd9..fa84f7af 100644 --- a/src/common/ops/slice.js +++ b/src/common/ops/slice.js @@ -109,7 +109,7 @@ function sliceNode(graph, query, result) { } export function sliceRange(graph, query, result) { - let { key, end, limit = Infinity, version } = query; + let { key, end, limit = Number.POSITIVE_INFINITY, version } = query; const step = cmp(key, end) < 0 ? 1 : -1; // Prefixes are used to combine filtering and pagination. In schemas where diff --git a/src/core/shift.js b/src/core/shift.js index ffcacd47..39ca9221 100644 --- a/src/core/shift.js +++ b/src/core/shift.js @@ -1,12 +1,12 @@ import { - decodeGraph as origDecodeGraph, - decodeQuery as origDecodeQuery, encodeGraph, encodePath, encodeQuery, finalize, merge, mergeStreams, + decodeGraph as origDecodeGraph, + decodeQuery as origDecodeQuery, remove, unwrap, unwrapObject, diff --git a/src/example/example.test.js b/src/example/example.test.js index c7728e3c..f2b8a015 100644 --- a/src/example/example.test.js +++ b/src/example/example.test.js @@ -1,6 +1,6 @@ -import { fork } from 'child_process'; -import { dirname } from 'path'; -import { fileURLToPath } from 'url'; +import { fork } from 'node:child_process'; +import { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { jest } from '@jest/globals'; import puppeteer from 'puppeteer'; diff --git a/src/link/package.json b/src/link/package.json index 3e101051..37a35054 100644 --- a/src/link/package.json +++ b/src/link/package.json @@ -3,4 +3,4 @@ "version": "1.0.0", "type": "module", "main": "index.js" -} \ No newline at end of file +} diff --git a/src/link/prepQueryLinks.test.js b/src/link/prepQueryLinks.test.js index d1f4ada3..0b279921 100644 --- a/src/link/prepQueryLinks.test.js +++ b/src/link/prepQueryLinks.test.js @@ -100,8 +100,8 @@ test('cube_args', () => { const quantities = { $ctd: [ - [-Infinity, -Infinity], - [Infinity, Infinity], + [Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY], + [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY], ], }; diff --git a/src/pg/Db.js b/src/pg/Db.js index 2f2bd140..07201339 100644 --- a/src/pg/Db.js +++ b/src/pg/Db.js @@ -38,12 +38,12 @@ export default class Db { async query(sql, tableOptions) { log(`Making SQL query: ${sql.text}`, sql.values); const cubeOid = - parseInt(tableOptions?.schema?.typeOids?.cube || '0') || null; + Number.parseInt(tableOptions?.schema?.typeOids?.cube || '0') || null; try { sql.types = { getTypeParser: (oid, format) => { if (oid === types.builtins.INT8) { - return (value) => parseInt(value, 10); + return (value) => Number.parseInt(value, 10); } if (oid === cubeOid) { return (value) => { @@ -51,7 +51,9 @@ export default class Db { .slice(1, -1) .split(/\)\s*,\s*\(/) .map((corner) => - corner.split(',').map((coord) => parseFloat(coord.trim())), + corner + .split(',') + .map((coord) => Number.parseFloat(coord.trim())), ); return array.length > 1 ? array : array[0]; }; diff --git a/src/pg/sql/clauses.js b/src/pg/sql/clauses.js index 733469b5..74fa8201 100644 --- a/src/pg/sql/clauses.js +++ b/src/pg/sql/clauses.js @@ -29,7 +29,7 @@ export const lookup = (prop, options) => { return sql`"${raw(prefix)}" #> ${suffix}`; } if (types[prefix] === 'cube' && suffix.length === 1) { - return sql`"${raw(prefix)}" ~> ${parseInt(suffix[0])}`; + return sql`"${raw(prefix)}" ~> ${Number.parseInt(suffix[0])}`; } throw Error(`pg.cannot_lookup ${prop}`); }; diff --git a/src/pg/test/e2e.test.js b/src/pg/test/e2e.test.js index 71c0fd05..34d40a35 100644 --- a/src/pg/test/e2e.test.js +++ b/src/pg/test/e2e.test.js @@ -797,10 +797,10 @@ describe('pg_e2e', () => { // Implicit array $put Object.defineProperty(exp1[pid1].commenters, '$put', { - value: [{ $since: 0, $until: Infinity }], + value: [{ $since: 0, $until: Number.POSITIVE_INFINITY }], }); Object.defineProperty(exp1[pid2].commenters, '$put', { - value: [{ $since: 0, $until: Infinity }], + value: [{ $since: 0, $until: Number.POSITIVE_INFINITY }], }); expect(res1).toEqual(exp1); diff --git a/src/pg/test/setup.js b/src/pg/test/setup.js index e58d2dad..c0d09d70 100644 --- a/src/pg/test/setup.js +++ b/src/pg/test/setup.js @@ -1,5 +1,5 @@ -import { execFile as execFileCb } from 'child_process'; -import { promisify } from 'util'; +import { execFile as execFileCb } from 'node:child_process'; +import { promisify } from 'node:util'; import pg from 'pg'; import sql from 'sql-template-tag'; diff --git a/src/server/httpServer.js b/src/server/httpServer.js index a27c28af..a0ddd578 100644 --- a/src/server/httpServer.js +++ b/src/server/httpServer.js @@ -1,4 +1,4 @@ -import url from 'url'; +import url from 'node:url'; import { decodeGraph, decodeQuery, pack, unpack } from '@graffy/common'; import debug from 'debug'; diff --git a/src/server/package.json b/src/server/package.json index 41f0f69d..64c88704 100644 --- a/src/server/package.json +++ b/src/server/package.json @@ -3,7 +3,5 @@ "version": "1.0.0", "type": "module", "main": "index.js", - "browserslist": [ - "maintained node versions" - ] + "browserslist": ["maintained node versions"] } diff --git a/src/stream/makeStream.js b/src/stream/makeStream.js index 1943405c..a29cfd1d 100644 --- a/src/stream/makeStream.js +++ b/src/stream/makeStream.js @@ -11,7 +11,11 @@ export default function makeStream(init, options = {}) { let complete; let drain; - const { highWatermark = Infinity, lowWatermark = 0, debugId } = options; + const { + highWatermark = Number.POSITIVE_INFINITY, + lowWatermark = 0, + debugId, + } = options; const push = (value) => { if (complete) return; diff --git a/tsconfig.json b/tsconfig.json index 0a24138e..a313bb32 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,10 +9,10 @@ "dom", "dom.iterable", "esnext" - ], /* Specify library files to be included in the compilation. */ + ] /* Specify library files to be included in the compilation. */, "allowJs": true /* Allow javascript files to be compiled. */, - "checkJs": true, /* Report errors in .js files. */ - "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ + "checkJs": true /* Report errors in .js files. */, + "jsx": "preserve" /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */, // "declaration": false, /* Generates corresponding '.d.ts' file. */, // "emitDeclarationOnly": true /* This compiler run should only output '.d.ts' files. */, // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ @@ -23,9 +23,9 @@ // "composite": true, /* Enable project compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ - "noEmit": true, /* Do not emit outputs. */ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ + "noEmit": true /* Do not emit outputs. */, // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */ + "isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ /* Strict Type-Checking Options */, // "strict": true /* Enable all strict type-checking options. */, // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ // "strictNullChecks": true, /* Enable strict null checks. */ @@ -42,7 +42,7 @@ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ /* Module Resolution Options */ - "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ + "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ @@ -66,8 +66,5 @@ "resolveJsonModule": true, "strict": false }, - "include": [ - "src/**/*.js", - "src/**/*.jsx" - ], -} \ No newline at end of file + "include": ["src/**/*.js", "src/**/*.jsx"] +}