Skip to content

Commit 48ec2ee

Browse files
committed
Migrate ESLint config to flat config and update deps
Replaces .eslintrc.js with eslint.config.js using the new flat config format. Updates ESLint and TypeScript ESLint dependencies to latest major versions, adjusts ignore patterns, and refactors htmlhint-server code to use unused parameter conventions. Also bumps VS Code engine and type dependencies for compatibility.
1 parent a245dea commit 48ec2ee

File tree

7 files changed

+672
-697
lines changed

7 files changed

+672
-697
lines changed

.eslintrc.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

eslint.config.js

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
const js = require("@eslint/js");
2+
const tseslint = require("@typescript-eslint/eslint-plugin");
3+
const tsparser = require("@typescript-eslint/parser");
4+
const prettier = require("eslint-config-prettier");
5+
6+
module.exports = [
7+
{
8+
ignores: [
9+
"test/**",
10+
"**/*.d.ts",
11+
"out/**",
12+
"htmlhint/out/**",
13+
"htmlhint-server/out/**",
14+
".vscode-test/**",
15+
"node_modules/**",
16+
"htmlhint/node_modules/**",
17+
"htmlhint-server/node_modules/**",
18+
"htmlhint/vscode-htmlhint-*.vsix",
19+
"**/*.vsix",
20+
],
21+
},
22+
js.configs.recommended,
23+
{
24+
files: ["**/*.ts"],
25+
languageOptions: {
26+
parser: tsparser,
27+
parserOptions: {
28+
ecmaVersion: "latest",
29+
sourceType: "module",
30+
},
31+
globals: {
32+
console: "readonly",
33+
process: "readonly",
34+
Buffer: "readonly",
35+
__dirname: "readonly",
36+
__filename: "readonly",
37+
global: "readonly",
38+
module: "readonly",
39+
require: "readonly",
40+
exports: "readonly",
41+
NodeJS: "readonly",
42+
},
43+
},
44+
plugins: {
45+
"@typescript-eslint": tseslint,
46+
},
47+
rules: {
48+
...tseslint.configs.recommended.rules,
49+
"no-console": "error",
50+
"no-empty": "off",
51+
"no-var": "off",
52+
"prefer-const": "off",
53+
"@typescript-eslint/explicit-module-boundary-types": "off",
54+
"@typescript-eslint/no-empty-interface": "off",
55+
"@typescript-eslint/no-explicit-any": "off",
56+
"@typescript-eslint/no-non-null-assertion": "off",
57+
"@typescript-eslint/no-unused-vars": [
58+
"error",
59+
{
60+
argsIgnorePattern: "^_",
61+
varsIgnorePattern: "^_",
62+
args: "after-used",
63+
},
64+
],
65+
"no-unused-vars": [
66+
"error",
67+
{
68+
argsIgnorePattern: "^_",
69+
varsIgnorePattern: "^_",
70+
args: "after-used",
71+
},
72+
],
73+
"@typescript-eslint/no-var-requires": "off",
74+
},
75+
},
76+
{
77+
files: ["**/*.js"],
78+
languageOptions: {
79+
ecmaVersion: "latest",
80+
sourceType: "commonjs",
81+
globals: {
82+
console: "readonly",
83+
process: "readonly",
84+
Buffer: "readonly",
85+
__dirname: "readonly",
86+
__filename: "readonly",
87+
global: "readonly",
88+
module: "readonly",
89+
require: "readonly",
90+
exports: "readonly",
91+
NodeJS: "readonly",
92+
},
93+
},
94+
rules: {
95+
"no-console": "error",
96+
"no-empty": "off",
97+
"no-var": "off",
98+
"prefer-const": "off",
99+
"no-unused-vars": [
100+
"error",
101+
{
102+
argsIgnorePattern: "^_",
103+
varsIgnorePattern: "^_",
104+
args: "after-used",
105+
},
106+
],
107+
},
108+
},
109+
prettier,
110+
];

htmlhint-server/src/server.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface HtmlHintConfig {
6767

6868
let settings: Settings | null = null;
6969
let linter: {
70-
verify: (text: string, config?: HtmlHintConfig) => htmlhint.Error[];
70+
verify: (_text: string, _config?: HtmlHintConfig) => htmlhint.Error[];
7171
} | null = null;
7272

7373
/**
@@ -82,9 +82,8 @@ let htmlhintrcOptions: Record<string, HtmlHintConfig | null | undefined> = {};
8282
*/
8383
function makeDiagnostic(
8484
problem: htmlhint.Error,
85-
document: TextDocument,
85+
_document: TextDocument,
8686
): Diagnostic {
87-
const lines = document.getText().split("\n");
8887
const col = problem.col - 1;
8988
const endCol = problem.col + (problem.raw?.length || 0) - 1;
9089

@@ -2190,16 +2189,7 @@ async function createAutoFixes(
21902189
}
21912190

21922191
connection.onInitialize(
2193-
(params: InitializeParams, token: CancellationToken) => {
2194-
let initOptions: {
2195-
nodePath: string;
2196-
} = params.initializationOptions;
2197-
let nodePath = initOptions
2198-
? initOptions.nodePath
2199-
? initOptions.nodePath
2200-
: undefined
2201-
: undefined;
2202-
2192+
(_params: InitializeParams, _token: CancellationToken) => {
22032193
// Since Files API is no longer available, we'll use embedded htmlhint directly
22042194
linter = (htmlhint.default ||
22052195
htmlhint.HTMLHint ||
@@ -2281,7 +2271,6 @@ function doValidate(connection: Connection, document: TextDocument): void {
22812271
}
22822272

22832273
let contents = document.getText();
2284-
let lines = contents.split("\n");
22852274

22862275
let config = getConfiguration(fsPath);
22872276
trace(`[DEBUG] Loaded config: ${JSON.stringify(config)}`);

htmlhint/package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

htmlhint/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"Linters"
2727
],
2828
"engines": {
29-
"vscode": "^1.89.0"
29+
"vscode": "^1.101.0"
3030
},
3131
"activationEvents": [
3232
"onLanguage:html",
@@ -91,8 +91,8 @@
9191
"package": "vsce package"
9292
},
9393
"devDependencies": {
94-
"@types/node": "^22.15.31",
95-
"@types/vscode": "^1.89.0",
94+
"@types/node": "^22.19.1",
95+
"@types/vscode": "^1.101.0",
9696
"@vscode/test-electron": "^2.5.2",
9797
"typescript": "5.5.4"
9898
},

0 commit comments

Comments
 (0)