Skip to content

Commit 3ea591f

Browse files
committed
Adjust ESLint, TypeScript configs and tests
Update ESLint rules and ignores, add test-specific overrides, and tighten TypeScript compiler options across packages. ESLint: reorder and extend rules (add no-useless-assignment), change ignored paths (add test/out/**), add overrides to expose Mocha globals for test/**/*.ts and disable no-console for test/runTest.ts. TypeScript: align and enable options such as allowSyntheticDefaultImports, esModuleInterop, noEmitOnError, strict flags, sourceMap, outDir and target (ES2022) in htmlhint-server, htmlhint and test tsconfig files. Tests: simplify .htmlhintrc existence checks in htmlhint.test.ts by failing directly in catch blocks instead of tracking a boolean and redundant assertions.
1 parent 5e4e966 commit 3ea591f

5 files changed

Lines changed: 83 additions & 72 deletions

File tree

eslint.config.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ const strictRules = {
1414
module.exports = [
1515
{
1616
ignores: [
17-
"test/**",
1817
"**/*.d.ts",
1918
"out/**",
2019
"htmlhint/out/**",
2120
"htmlhint-server/out/**",
21+
"test/out/**",
2222
".vscode-test/**",
2323
"node_modules/**",
2424
"htmlhint/node_modules/**",
@@ -45,14 +45,15 @@ module.exports = [
4545
"@typescript-eslint": tseslint,
4646
},
4747
rules: {
48-
...tseslint.configs.recommended.rules,
4948
...strictRules,
50-
"no-console": "error",
51-
"no-empty": "off",
49+
...tseslint.configs.recommended.rules,
5250
"@typescript-eslint/explicit-module-boundary-types": "off",
5351
"@typescript-eslint/no-empty-interface": "off",
5452
"@typescript-eslint/no-explicit-any": "off",
5553
"@typescript-eslint/no-non-null-assertion": "off",
54+
"no-console": "error",
55+
"no-empty": "off",
56+
"no-useless-assignment": "error",
5657
// Disable base no-unused-vars rule for TypeScript files to prevent conflicts
5758
"no-unused-vars": "off",
5859
"@typescript-eslint/no-unused-vars": [
@@ -66,6 +67,20 @@ module.exports = [
6667
"@typescript-eslint/no-var-requires": "off",
6768
},
6869
},
70+
{
71+
files: ["test/**/*.ts"],
72+
languageOptions: {
73+
globals: {
74+
...globals.mocha,
75+
},
76+
},
77+
},
78+
{
79+
files: ["test/runTest.ts"],
80+
rules: {
81+
"no-console": "off",
82+
},
83+
},
6984
{
7085
files: ["**/*.js"],
7186
languageOptions: {
@@ -80,6 +95,7 @@ module.exports = [
8095
...strictRules,
8196
"no-console": "error",
8297
"no-empty": "off",
98+
"no-useless-assignment": "error",
8399
"no-unused-vars": [
84100
"error",
85101
{

htmlhint-server/src/tsconfig.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
{
22
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"alwaysStrict": true,
5+
"declaration": true,
6+
"declarationMap": true,
7+
"esModuleInterop": true,
8+
"exactOptionalPropertyTypes": false,
9+
"forceConsistentCasingInFileNames": true,
310
"module": "commonjs",
4-
"target": "ES2022",
511
"lib": ["ES2022"],
612
"moduleResolution": "node",
7-
"outDir": "../../htmlhint/server",
8-
"sourceMap": true,
9-
"declaration": true,
10-
"declarationMap": true,
11-
"strict": true,
13+
"noEmitOnError": true,
14+
"noFallthroughCasesInSwitch": true,
1215
"noImplicitAny": false,
13-
"noImplicitReturns": true,
1416
"noImplicitThis": true,
1517
"noImplicitOverride": true,
16-
"strictNullChecks": false,
17-
"strictFunctionTypes": true,
18-
"strictBindCallApply": true,
19-
"strictPropertyInitialization": false,
20-
"alwaysStrict": true,
18+
"noImplicitReturns": true,
19+
"noPropertyAccessFromIndexSignature": false,
20+
"noUncheckedIndexedAccess": false,
2121
"noUnusedLocals": false,
2222
"noUnusedParameters": false,
23-
"exactOptionalPropertyTypes": false,
24-
"noFallthroughCasesInSwitch": true,
25-
"noUncheckedIndexedAccess": false,
26-
"noPropertyAccessFromIndexSignature": false,
27-
"esModuleInterop": true,
28-
"allowSyntheticDefaultImports": true,
23+
"outDir": "../../htmlhint/server",
2924
"resolveJsonModule": true,
30-
"forceConsistentCasingInFileNames": true,
3125
"skipLibCheck": true,
3226
"incremental": true,
27+
"sourceMap": true,
28+
"strict": true,
29+
"strictBindCallApply": true,
30+
"strictFunctionTypes": true,
31+
"strictNullChecks": false,
32+
"strictPropertyInitialization": false,
33+
"target": "ES2022",
3334
"tsBuildInfoFile": ".tsbuildinfo"
3435
},
3536
"include": ["**/*.ts"],

htmlhint/tsconfig.json

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
11
{
22
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"alwaysStrict": true,
5+
"declaration": true,
6+
"declarationMap": true,
7+
"esModuleInterop": true,
8+
"exactOptionalPropertyTypes": true,
9+
"forceConsistentCasingInFileNames": true,
310
"module": "commonjs",
4-
"target": "ES2022",
511
"lib": ["ES2022", "DOM"],
612
"moduleResolution": "node",
7-
"outDir": "out",
8-
"sourceMap": true,
9-
"declaration": true,
10-
"declarationMap": true,
11-
"strict": true,
13+
"noEmitOnError": true,
14+
"noFallthroughCasesInSwitch": true,
1215
"noImplicitAny": true,
13-
"noImplicitReturns": true,
1416
"noImplicitThis": true,
1517
"noImplicitOverride": true,
16-
"strictNullChecks": true,
17-
"strictFunctionTypes": true,
18-
"strictBindCallApply": true,
19-
"strictPropertyInitialization": true,
20-
"alwaysStrict": true,
18+
"noImplicitReturns": true,
19+
"noPropertyAccessFromIndexSignature": true,
20+
"noUncheckedIndexedAccess": true,
2121
"noUnusedLocals": true,
2222
"noUnusedParameters": true,
23-
"exactOptionalPropertyTypes": true,
24-
"noFallthroughCasesInSwitch": true,
25-
"noUncheckedIndexedAccess": true,
26-
"noPropertyAccessFromIndexSignature": false,
27-
"esModuleInterop": true,
28-
"allowSyntheticDefaultImports": true,
23+
"outDir": "out",
2924
"resolveJsonModule": true,
30-
"forceConsistentCasingInFileNames": true,
3125
"skipLibCheck": true,
3226
"incremental": true,
27+
"sourceMap": true,
28+
"strict": true,
29+
"strictBindCallApply": true,
30+
"strictFunctionTypes": true,
31+
"strictNullChecks": true,
32+
"strictPropertyInitialization": true,
33+
"target": "ES2022",
3334
"tsBuildInfoFile": ".tsbuildinfo"
3435
},
3536
"include": ["extension.ts", "**/*.ts"],

test/suite/htmlhint.test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,19 @@ suite("HTMLHint Test Suite", () => {
3131
__dirname,
3232
"../../../test/testConfigFile/.htmlhintrc",
3333
);
34-
let configExists = false;
3534
try {
3635
await vscode.workspace.fs.stat(vscode.Uri.file(testConfigPath));
37-
configExists = true;
3836
} catch {
39-
configExists = false;
37+
assert.fail(".htmlhintrc should exist in test config directory");
4038
}
41-
assert.strictEqual(
42-
configExists,
43-
true,
44-
".htmlhintrc should exist in test config directory",
45-
);
4639
return;
4740
}
4841

4942
const configPath = path.join(workspaceFolder.uri.fsPath, ".htmlhintrc");
50-
let configExists = false;
5143
try {
5244
await vscode.workspace.fs.stat(vscode.Uri.file(configPath));
53-
configExists = true;
5445
} catch {
55-
configExists = false;
46+
assert.fail(".htmlhintrc should exist");
5647
}
57-
58-
assert.strictEqual(configExists, true, ".htmlhintrc should exist");
5948
});
6049
});

test/tsconfig.json

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
11
{
22
"compilerOptions": {
3+
"allowSyntheticDefaultImports": true,
4+
"alwaysStrict": true,
5+
"esModuleInterop": true,
6+
"exactOptionalPropertyTypes": true,
7+
"forceConsistentCasingInFileNames": true,
38
"module": "commonjs",
4-
"target": "ES2022",
59
"lib": ["ES2022", "DOM"],
610
"moduleResolution": "node",
7-
"outDir": "out",
8-
"sourceMap": true,
9-
"strict": true,
11+
"noEmitOnError": true,
12+
"noFallthroughCasesInSwitch": true,
1013
"noImplicitAny": true,
11-
"noImplicitReturns": true,
1214
"noImplicitThis": true,
13-
"strictNullChecks": true,
14-
"strictFunctionTypes": true,
15-
"strictBindCallApply": true,
16-
"alwaysStrict": true,
17-
"noUnusedLocals": false,
18-
"noUnusedParameters": false,
19-
"noFallthroughCasesInSwitch": true,
20-
"noUncheckedIndexedAccess": false,
21-
"esModuleInterop": true,
22-
"allowSyntheticDefaultImports": true,
15+
"noImplicitOverride": true,
16+
"noImplicitReturns": true,
17+
"noPropertyAccessFromIndexSignature": true,
18+
"noUncheckedIndexedAccess": true,
19+
"noUnusedLocals": true,
20+
"noUnusedParameters": true,
21+
"outDir": "out",
2322
"resolveJsonModule": true,
24-
"forceConsistentCasingInFileNames": true,
23+
"sourceMap": true,
2524
"types": ["node", "mocha"],
26-
"skipLibCheck": true
25+
"skipLibCheck": true,
26+
"strict": true,
27+
"strictBindCallApply": true,
28+
"strictFunctionTypes": true,
29+
"strictNullChecks": true,
30+
"target": "ES2022"
2731
},
2832
"include": ["suite/**/*.ts", "runTest.ts"],
2933
"exclude": ["node_modules"]

0 commit comments

Comments
 (0)