Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aravindet committed Apr 11, 2024
1 parent 553dc05 commit 084ec05
Show file tree
Hide file tree
Showing 27 changed files with 57 additions and 57 deletions.
3 changes: 2 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"noForEach": "off"
},
"a11y": {
"all": false
"all": false,
"useButtonType": { "level": "off" }
},
"style": {
"noParameterAssign": "off"
Expand Down
2 changes: 1 addition & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path');
const path = require('node:path');

module.exports = {
verbose: true,
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion scripts/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import util from 'util';
import util from 'node:util';

process.on('unhandledRejection', (reason) => {
console.error('Unhandled Promise Rejection:', reason);
Expand Down
4 changes: 2 additions & 2 deletions scripts/package.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions scripts/tscworker.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/types.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Worker } from 'worker_threads';
import { Worker } from 'node:worker_threads';
import { root } from './utils.js';

const workerPool = [];
Expand Down
10 changes: 5 additions & 5 deletions scripts/utils.js
Original file line number Diff line number Diff line change
@@ -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);

Expand Down
2 changes: 1 addition & 1 deletion scripts/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/common/coding/decodeTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/common/coding/decorate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/common/coding/encodeTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/common/coding/test/number.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
2 changes: 1 addition & 1 deletion src/common/ops/slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/core/shift.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/example/example.test.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"version": "1.0.0",
"type": "module",
"main": "index.js"
}
}
4 changes: 2 additions & 2 deletions src/link/prepQueryLinks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
],
};

Expand Down
8 changes: 5 additions & 3 deletions src/pg/Db.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ 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) => {
const array = value
.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];
};
Expand Down
2 changes: 1 addition & 1 deletion src/pg/sql/clauses.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
};
Expand Down
4 changes: 2 additions & 2 deletions src/pg/test/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/pg/test/setup.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/server/httpServer.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
4 changes: 1 addition & 3 deletions src/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@
"version": "1.0.0",
"type": "module",
"main": "index.js",
"browserslist": [
"maintained node versions"
]
"browserslist": ["maintained node versions"]
}
6 changes: 5 additions & 1 deletion src/stream/makeStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
19 changes: 8 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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. */
Expand All @@ -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. */
Expand All @@ -66,8 +66,5 @@
"resolveJsonModule": true,
"strict": false
},
"include": [
"src/**/*.js",
"src/**/*.jsx"
],
}
"include": ["src/**/*.js", "src/**/*.jsx"]
}

0 comments on commit 084ec05

Please sign in to comment.