Skip to content

Commit f183fee

Browse files
committed
style: 💄 fix linter errors
1 parent 4b791da commit f183fee

File tree

15 files changed

+101
-55
lines changed

15 files changed

+101
-55
lines changed

‎biome.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
3+
"organizeImports": {
4+
"enabled": true
5+
},
6+
"formatter": {
7+
"indentStyle": "space",
8+
"lineWidth": 120
9+
},
10+
"javascript": {
11+
"formatter": {
12+
"quoteStyle": "single",
13+
"trailingCommas": "all",
14+
"bracketSpacing": false
15+
}
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true,
21+
"style": {
22+
"noNonNullAssertion": "off",
23+
"useNodejsImportProtocol": "off",
24+
"useTemplate": "off",
25+
"noInferrableTypes": "off",
26+
"noUselessElse": "off",
27+
"noParameterAssign": "off",
28+
"noCommaOperator": "off",
29+
"useSingleVarDeclarator": "off",
30+
"noUnusedTemplateLiteral": "off"
31+
},
32+
"suspicious": {
33+
"noExplicitAny": "off",
34+
"useIsArray": "off",
35+
"noAssignInExpressions": "off"
36+
},
37+
"complexity": {
38+
"noStaticOnlyClass": "off",
39+
"useOptionalChain": "off"
40+
},
41+
"security": {
42+
"noGlobalEval": "off"
43+
}
44+
}
45+
}
46+
}

‎src/__bench__/find.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,33 @@ const doc = {
2323
};
2424

2525
suite
26-
.add(`find`, function () {
26+
.add(`find`, () => {
2727
const pointer = parseJsonPointer('/foo/bar/0/baz');
2828
find(doc, pointer);
2929
})
30-
.add(`find ES5`, function () {
30+
.add(`find ES5`, () => {
3131
const pointer = parseJsonPointerEs5('/foo/bar/0/baz');
3232
findEs5(doc, pointer);
3333
})
34-
.add(`findByPointer (v1)`, function () {
34+
.add(`findByPointer (v1)`, () => {
3535
findByPointerV1('/foo/bar/0/baz', doc);
3636
})
37-
.add(`findByPointer (v2)`, function () {
37+
.add(`findByPointer (v2)`, () => {
3838
findByPointerV2('/foo/bar/0/baz', doc);
3939
})
40-
.add(`findByPointer (v3)`, function () {
40+
.add(`findByPointer (v3)`, () => {
4141
findByPointerV3('/foo/bar/0/baz', doc);
4242
})
43-
.add(`findByPointer (v4)`, function () {
43+
.add(`findByPointer (v4)`, () => {
4444
findByPointerV4('/foo/bar/0/baz', doc);
4545
})
46-
.add(`findByPointer (v5)`, function () {
46+
.add(`findByPointer (v5)`, () => {
4747
findByPointerV5('/foo/bar/0/baz', doc);
4848
})
49-
.add(`findByPointer (v6)`, function () {
49+
.add(`findByPointer (v6)`, () => {
5050
findByPointerV6('/foo/bar/0/baz', doc);
5151
})
52-
.on('cycle', function (event) {
52+
.on('cycle', (event) => {
5353
console.log(String(event.target));
5454
})
5555
.on('complete', function () {

‎src/__tests__/testFindRef.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {test, expect} from 'vitest';
2-
import {Path, Reference} from '..';
2+
import type {Path, Reference} from '..';
33
import {isArrayReference, isArrayEnd} from '../find';
44
import {parseJsonPointer} from '../util';
55

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {$findRef} from '../findRef';
2-
import {Path} from '../..';
2+
import type {Path} from '../..';
33
import {testFindRef} from '../../__tests__/testFindRef';
44

55
testFindRef((val: unknown, path: Path) => $findRef(path)(val));

‎src/codegen/find.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {JavaScript} from '@jsonjoy.com/util/lib/codegen';
2-
import {Path} from '../types';
1+
import type {JavaScript} from '@jsonjoy.com/util/lib/codegen';
2+
import type {Path} from '../types';
33

44
export const $$find = (path: Path): JavaScript<(doc: unknown) => unknown> => {
55
if (path.length === 0) return '(function(x){return x})' as JavaScript<(doc: unknown) => unknown>;

‎src/codegen/findRef.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type {Reference} from '../find';
22
import type {Path} from '../types';
3-
import {JavaScriptLinked, compileClosure} from '@jsonjoy.com/util/lib/codegen';
4-
import {hasOwnProperty} from '@jsonjoy.com/util/lib/hasOwnProperty';
3+
import {type JavaScriptLinked, compileClosure} from '@jsonjoy.com/util/lib/codegen';
4+
import {hasOwnProperty as has} from '@jsonjoy.com/util/lib/hasOwnProperty';
55

66
type Fn = (val: unknown) => Reference;
77

@@ -30,7 +30,7 @@ export const $$findRef = (path: Path): JavaScriptLinked<Fn> => {
3030
}
3131
val = obj[key];
3232
} else if (typeof obj === 'object' && !!obj) {
33-
val = hasOwnProperty(obj, key) ? obj[key] : undefined;
33+
val = has(obj, key) ? obj[key] : undefined;
3434
} else throw new Error('NOT_FOUND');
3535
`;
3636
}
@@ -44,7 +44,7 @@ export const $$findRef = (path: Path): JavaScriptLinked<Fn> => {
4444
})`;
4545

4646
return {
47-
deps: [hasOwnProperty, path] as unknown[],
47+
deps: [has, path] as unknown[],
4848
js,
4949
} as JavaScriptLinked<Fn>;
5050
};

‎src/find.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* tslint:disable no-string-throw */
22

3-
import {hasOwnProperty} from '@jsonjoy.com/util/lib/hasOwnProperty';
3+
import {hasOwnProperty as has} from '@jsonjoy.com/util/lib/hasOwnProperty';
44
import type {Path} from './types';
55

66
export interface Reference {
@@ -59,7 +59,7 @@ export const find = (val: unknown, path: Path): Reference => {
5959
}
6060
val = obj[key];
6161
} else if (typeof obj === 'object' && !!obj) {
62-
val = hasOwnProperty(obj, key as string) ? (obj as any)[key] : undefined;
62+
val = has(obj, key as string) ? (obj as any)[key] : undefined;
6363
} else throw new Error('NOT_FOUND');
6464
}
6565
const ref: Reference = {val, obj, key};

‎src/findByPointer/v1.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {hasOwnProperty} from '@jsonjoy.com/util/lib/hasOwnProperty';
2-
import {Reference} from '../find';
1+
import {hasOwnProperty as has} from '@jsonjoy.com/util/lib/hasOwnProperty';
2+
import type {Reference} from '../find';
33
import {isValidIndex, unescapeComponent} from '../util';
44

55
const {isArray} = Array;
@@ -8,8 +8,8 @@ export const findByPointer = (pointer: string, val: unknown): Reference => {
88
if (!pointer) return {val};
99
let obj: Reference['obj'];
1010
let key: Reference['key'];
11-
let indexOfSlash: number = 0;
12-
let indexAfterSlash: number = 1;
11+
let indexOfSlash = 0;
12+
let indexAfterSlash = 1;
1313
while (indexOfSlash > -1) {
1414
indexOfSlash = pointer.indexOf('/', indexAfterSlash);
1515
const component: string =
@@ -24,9 +24,9 @@ export const findByPointer = (pointer: string, val: unknown): Reference => {
2424
key = Number(key);
2525
if (key < 0) throw new Error('INVALID_INDEX');
2626
}
27-
val = hasOwnProperty(obj, String(key)) ? obj[key] : undefined;
27+
val = has(obj, String(key)) ? obj[key] : undefined;
2828
} else if (typeof obj === 'object' && !!obj) {
29-
val = hasOwnProperty(obj, String(key)) ? (obj as any)[key] : undefined;
29+
val = has(obj, String(key)) ? (obj as any)[key] : undefined;
3030
} else throw new Error('NOT_FOUND');
3131
}
3232
return {val, obj, key};

‎src/findByPointer/v2.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {hasOwnProperty} from '@jsonjoy.com/util/lib/hasOwnProperty';
2-
import {Reference} from '../find';
1+
import {hasOwnProperty as has} from '@jsonjoy.com/util/lib/hasOwnProperty';
2+
import type {Reference} from '../find';
33
import {isValidIndex, unescapeComponent} from '../util';
44

55
const {isArray} = Array;
@@ -8,7 +8,7 @@ export const findByPointer = (pointer: string, val: unknown): Reference => {
88
if (!pointer) return {val};
99
let obj: Reference['obj'];
1010
let key: Reference['key'];
11-
let indexOfSlash: number = 0;
11+
let indexOfSlash = 0;
1212
pointer = pointer.substr(1);
1313
while (pointer) {
1414
indexOfSlash = pointer.indexOf('/');
@@ -29,9 +29,9 @@ export const findByPointer = (pointer: string, val: unknown): Reference => {
2929
key = Number(key);
3030
if (key < 0) throw new Error('INVALID_INDEX');
3131
}
32-
val = hasOwnProperty(obj, String(key)) ? obj[key] : undefined;
32+
val = has(obj, String(key)) ? obj[key] : undefined;
3333
} else if (typeof obj === 'object' && !!obj) {
34-
val = hasOwnProperty(obj, String(key)) ? (obj as any)[key] : undefined;
34+
val = has(obj, String(key)) ? (obj as any)[key] : undefined;
3535
} else throw new Error('NOT_FOUND');
3636
}
3737
return {val, obj, key};

‎src/findByPointer/v3.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {hasOwnProperty} from '@jsonjoy.com/util/lib/hasOwnProperty';
2-
import {Reference} from '../find';
1+
import {hasOwnProperty as has} from '@jsonjoy.com/util/lib/hasOwnProperty';
2+
import type {Reference} from '../find';
33
import {isInteger, unescapeComponent} from '../util';
44

55
const {isArray} = Array;
@@ -8,7 +8,7 @@ export const findByPointer = (pointer: string, val: unknown): Reference => {
88
if (!pointer) return {val};
99
let obj: Reference['obj'];
1010
let key: Reference['key'];
11-
let indexOfSlash: number = 0;
11+
let indexOfSlash = 0;
1212
pointer = pointer.substr(1);
1313
while (pointer) {
1414
indexOfSlash = pointer.indexOf('/');
@@ -29,9 +29,9 @@ export const findByPointer = (pointer: string, val: unknown): Reference => {
2929
key = Number(key);
3030
if (key < 0) throw new Error('INVALID_INDEX');
3131
}
32-
val = hasOwnProperty(obj, String(key)) ? obj[key] : undefined;
32+
val = has(obj, String(key)) ? obj[key] : undefined;
3333
} else if (typeof obj === 'object' && !!obj) {
34-
val = hasOwnProperty(obj, String(key)) ? (obj as any)[key] : undefined;
34+
val = has(obj, String(key)) ? (obj as any)[key] : undefined;
3535
} else throw new Error('NOT_FOUND');
3636
}
3737
return {val, obj, key};

0 commit comments

Comments
 (0)