Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javascript/biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.8/schema.json",
"linter": {
"enabled": true,
"rules": {
Expand Down
192 changes: 96 additions & 96 deletions javascript/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@vitest/browser-playwright": "^4.0.18",
"esbuild": "^0.27.0",
"playwright": "^1.58.0",
"typescript": "^5.1.6",
"typescript": "^6.0.2",
"vitest": "^4.0.18"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion javascript/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const cli = (argv: string[]) => {
});

let stdin = '';
rl.on('line', line => {
rl.on('line', (line: string) => {
stdin += line + '\n';
});
process.stdin.on('end', () => {
Expand Down
4 changes: 2 additions & 2 deletions javascript/src/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import {DOMParser} from 'linkedom';
* @param html An HTML string.
* @return A Document.
*/
export const parseFromString = (html: string) => {
export const parseFromString = (html: string): Document => {
return new DOMParser().parseFromString(
`<!doctype html><html><body>${html}</body></html>`,
'text/html'
);
) as unknown as Document;
};
9 changes: 6 additions & 3 deletions javascript/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ export class Parser {
*/
constructor(model: {[key: string]: {[key: string]: number}}) {
this.model = new Map(
Object.entries(model).map(([k, v]) => [k, new Map(Object.entries(v))])
Object.entries(model).map(([k, v]: [string, {[key: string]: number}]) => [
k,
new Map(Object.entries(v)),
])
);
this.baseScore =
-0.5 *
[...this.model.values()]
.flatMap(group => [...group.values()])
.reduce((prev, curr) => prev + curr, 0);
.flatMap((group: Map<string, number>) => [...group.values()])
.reduce((prev: number, curr: number) => prev + curr, 0);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions javascript/src/tests/test_cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* limitations under the License.
*/

import {type ExecFileException, execFile} from 'child_process';
import {execFile} from 'child_process';
import * as path from 'path';
import stream from 'stream';
import {describe, expect, it} from 'vitest';
import {cli} from '../cli.js';
import {loadDefaultParsers} from '../index.js';

type execFileCallBack = {
error: ExecFileException | null;
error: Error | null;
stdout: string;
stderr: string;
};
Expand All @@ -33,7 +33,7 @@ const runCli = (args: string[], stdin?: string): Promise<execFileCallBack> => {
const child = execFile(
'node',
[binPath, ...args],
(error, stdout, stderr) => {
(error: Error | null, stdout: string, stderr: string) => {
resolve({
error,
stdout,
Expand Down
6 changes: 4 additions & 2 deletions javascript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"compilerOptions": {
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"lib": ["es6", "dom", "dom.iterable"],
"lib": ["es2020", "dom", "dom.iterable"],
"target": "es2017",
"module": "commonjs",
"moduleResolution": "node",
"moduleResolution": "bundler",
"rootDir": "./src",
"types": ["node"],
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
Expand Down
Loading