Skip to content

Commit 88e17cb

Browse files
authored
Merge pull request #338 from htmlhint/dev/coliff/update-eslint
Migrate ESLint config to flat config and update deps
2 parents a245dea + 7d59d94 commit 88e17cb

File tree

8 files changed

+667
-697
lines changed

8 files changed

+667
-697
lines changed

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"ruleset",
1616
"sarif",
1717
"tagname",
18+
"tsparser",
1819
"vite",
1920
"VSIX",
2021
"ZIZMOR"

.eslintrc.js

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

eslint.config.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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+
const globals = require("globals");
6+
7+
module.exports = [
8+
{
9+
ignores: [
10+
"test/**",
11+
"**/*.d.ts",
12+
"out/**",
13+
"htmlhint/out/**",
14+
"htmlhint-server/out/**",
15+
".vscode-test/**",
16+
"node_modules/**",
17+
"htmlhint/node_modules/**",
18+
"htmlhint-server/node_modules/**",
19+
"htmlhint/vscode-htmlhint-*.vsix",
20+
"**/*.vsix",
21+
],
22+
},
23+
js.configs.recommended,
24+
{
25+
files: ["**/*.ts"],
26+
languageOptions: {
27+
parser: tsparser,
28+
parserOptions: {
29+
ecmaVersion: "latest",
30+
sourceType: "module",
31+
},
32+
globals: {
33+
...globals.node,
34+
NodeJS: "readonly",
35+
},
36+
},
37+
plugins: {
38+
"@typescript-eslint": tseslint,
39+
},
40+
rules: {
41+
...tseslint.configs.recommended.rules,
42+
"no-console": "error",
43+
"no-empty": "off",
44+
"no-var": "off",
45+
"prefer-const": "off",
46+
"@typescript-eslint/explicit-module-boundary-types": "off",
47+
"@typescript-eslint/no-empty-interface": "off",
48+
"@typescript-eslint/no-explicit-any": "off",
49+
"@typescript-eslint/no-non-null-assertion": "off",
50+
// Disable base no-unused-vars rule for TypeScript files to prevent conflicts
51+
"no-unused-vars": "off",
52+
"@typescript-eslint/no-unused-vars": [
53+
"error",
54+
{
55+
argsIgnorePattern: "^_",
56+
varsIgnorePattern: "^_",
57+
args: "after-used",
58+
},
59+
],
60+
"@typescript-eslint/no-var-requires": "off",
61+
},
62+
},
63+
{
64+
files: ["**/*.js"],
65+
languageOptions: {
66+
ecmaVersion: "latest",
67+
sourceType: "commonjs",
68+
globals: {
69+
...globals.node,
70+
NodeJS: "readonly",
71+
},
72+
},
73+
rules: {
74+
"no-console": "error",
75+
"no-empty": "off",
76+
"no-var": "off",
77+
"prefer-const": "off",
78+
"no-unused-vars": [
79+
"error",
80+
{
81+
argsIgnorePattern: "^_",
82+
varsIgnorePattern: "^_",
83+
args: "after-used",
84+
},
85+
],
86+
},
87+
},
88+
prettier,
89+
];

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)