From 7b684a03f6fc2cfae36fd1d4d85f8983161c5e43 Mon Sep 17 00:00:00 2001 From: Yavor Ivanov Date: Mon, 25 Mar 2024 15:08:50 +0200 Subject: [PATCH] fix: Eslint issues --- src/detectors/transpilers/html/parser.ts | 4 ++-- src/linter/html/linter.ts | 12 +++++------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/detectors/transpilers/html/parser.ts b/src/detectors/transpilers/html/parser.ts index c826b6e32..67f134774 100644 --- a/src/detectors/transpilers/html/parser.ts +++ b/src/detectors/transpilers/html/parser.ts @@ -16,7 +16,7 @@ async function initSaxWasm() { } async function parseHtml(contentStream: ReadStream, parseHandler: (type: SaxEventType, tag: Detail) => void) { - const options = { highWaterMark: 32 * 1024 }; // 32k chunks + const options = {highWaterMark: 32 * 1024}; // 32k chunks const saxWasmBuffer = await initSaxWasm(); const saxParser = new SAXParser(SaxEventType.OpenTag | SaxEventType.CloseTag, options); @@ -56,4 +56,4 @@ export async function extractScriptTags(contentStream: ReadStream) { }); return scriptTags; -} \ No newline at end of file +} diff --git a/src/linter/html/linter.ts b/src/linter/html/linter.ts index ce1e97c0e..773a3a54f 100644 --- a/src/linter/html/linter.ts +++ b/src/linter/html/linter.ts @@ -3,9 +3,8 @@ import {extractScriptTags} from "../../detectors/transpilers/html/parser.js"; import {LintMessageSeverity} from "../../detectors/AbstractDetector.js"; import Reporter from "../../detectors/Reporter.js"; -import type { TranspileResult } from "../../detectors/transpilers/AbstractTranspiler.js"; -import type { ReadStream } from "node:fs"; - +import type {TranspileResult} from "../../detectors/transpilers/AbstractTranspiler.js"; +import type {ReadStream} from "node:fs"; export async function lintHtml(resourceName: string, contentStream: ReadStream): Promise { const taskLintEnd = taskStart("Static lint", resourceName); @@ -14,16 +13,15 @@ export async function lintHtml(resourceName: string, contentStream: ReadStream): const scriptTags = await extractScriptTags(contentStream); const jsScriptTags = scriptTags.filter((tag) => tag.attributes.every((attr) => { // The "type" attribute of the script tag should be - // 1. not set (default), - // 2. an empty string, + // 1. not set (default), + // 2. an empty string, // 3. or a JavaScript MIME type (text/javascript) // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type#attribute_is_not_set_default_an_empty_string_or_a_javascript_mime_type return attr.name.value !== "type" || (attr.name.value === "type" && - (attr.value.value === "" || attr.value.value === "text/javascript")); + (attr.value.value === "" || attr.value.value === "text/javascript")); })); - jsScriptTags.forEach((tag) => { const scriptContent = tag.textNodes?.map((tNode) => tNode.value).join("").trim();