Skip to content

Conversation

@coliff
Copy link
Member

@coliff coliff commented Jun 24, 2025

Summary of Code Changes

1. Removed Deprecated ProposedFeatures.all

Before:

let connection: Connection = createConnection(ProposedFeatures.all);

After:

let connection: Connection = createConnection();

2. Removed Deprecated ErrorMessageTracker

Before:

import { ErrorMessageTracker } from "vscode-languageserver/node";
// ...
let tracker = new ErrorMessageTracker();
documents.forEach((document) => {
  try {
    validateTextDocument(connection, document);
  } catch (err) {
    tracker.add(getErrorMessage(err, document));
  }
});
tracker.sendErrors(connection);

After:

const errors: string[] = [];
documents.forEach((document) => {
  try {
    validateTextDocument(connection, document);
  } catch (err) {
    errors.push(getErrorMessage(err, document));
  }
});
if (errors.length > 0) {
  connection.window.showErrorMessage(errors.join('\n'));
}

3. Converted CommonJS require() to ES6 Imports

Before:

import fs = require("fs");
let stripJsonComments: any = require("strip-json-comments");

After:

import * as fs from "fs";
import stripJsonComments from "strip-json-comments";

4. Improved Typing for linter and Configs

Before:

let linter: any = null;
let htmlhintrcOptions: any = {};
function getConfiguration(filePath: string): any { ... }
function findConfigForHtmlFile(base: string) { ... }
function loadConfigurationFile(configFile: string): any { ... }

After:

let linter: { verify: (text: string, config?: HtmlHintConfig) => htmlhint.Error[] } | null = null;
let htmlhintrcOptions: Record<string, HtmlHintConfig | null | undefined> = {};
function getConfiguration(filePath: string): HtmlHintConfig { ... }
function findConfigForHtmlFile(base: string): HtmlHintConfig | undefined { ... }
function loadConfigurationFile(configFile: string): HtmlHintConfig | null { ... }

5. Safer Assignment for linter

Before:

linter = htmlhint.default || htmlhint.HTMLHint || htmlhint;

After:

linter = (htmlhint.default || htmlhint.HTMLHint || htmlhint) as typeof linter;

6. Other Minor Type Improvements

  • Used more specific types for settings and configuration objects.
  • Updated function signatures to reflect improved types.

These changes modernize the code, remove deprecated APIs, and improve type safety.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request focuses on modernizing the codebase by removing deprecated APIs, improving type safety, and enhancing error handling. The changes are well-structured and contribute to the overall maintainability and reliability of the HTMLHint server.

@coliff coliff merged commit c738417 into main Jun 24, 2025
9 checks passed
@coliff coliff deleted the dev/coliff/replace-dprecated-apis branch June 24, 2025 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants