Skip to content

Commit a2677f7

Browse files
bzm3rfendor
andauthored
Tooling update (#1043)
* remove TSLint from recommendations, instead suggest ESLint * add prettier to workspace recommendations, since project assumes prettier usage * auto-formatter (hopefully prettier) is making changes to src/*.ts; they seem reasonable... * trying to silence eslint warnings for unused vars; but its not working... * fix eslint warnings related to null in utils.ts * silenced no-explicit-any related warnings; also, unused vars related warning are also being correctly suppressed --------- Co-authored-by: fendor <fendor@users.noreply.github.com>
1 parent 5769ee2 commit a2677f7

File tree

7 files changed

+154
-133
lines changed

7 files changed

+154
-133
lines changed

.eslintrc.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
"browser": true,
44
"es2021": true
55
},
6-
"extends": [
7-
"eslint:recommended",
8-
"plugin:@typescript-eslint/recommended"
9-
],
10-
"overrides": [],
6+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
117
"parser": "@typescript-eslint/parser",
128
"parserOptions": {
139
"ecmaVersion": "latest",
1410
"sourceType": "module"
1511
},
16-
"plugins": [
17-
"@typescript-eslint"
18-
],
12+
"plugins": ["@typescript-eslint"],
1913
"rules": {
20-
"semi": [
21-
"error",
22-
"always"
23-
]
14+
"no-unused-vars": "off",
15+
"@typescript-eslint/no-unused-vars": [
16+
"warn",
17+
{
18+
"varsIgnorePattern": "^_",
19+
"argsIgnorePattern": "^_"
20+
}
21+
],
22+
"@typescript-eslint/no-explicit-any": "off",
23+
"semi": ["error", "always"]
2424
}
25-
}
25+
}

.vscode/extensions.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
{
2-
"recommendations": ["ms-vscode.vscode-typescript-tslint-plugin"]
3-
}
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode"
5+
]
6+
}

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
".cabal"
6060
]
6161
},
62-
6362
{
6463
"id": "literate haskell",
6564
"aliases": [
@@ -1153,8 +1152,8 @@
11531152
"@types/node": "^20.11.17",
11541153
"@types/vscode": "^1.82.0",
11551154
"@types/which": "^3.0.3",
1156-
"@typescript-eslint/eslint-plugin": "^5.62.0",
1157-
"@typescript-eslint/parser": "^5.62.0",
1155+
"@typescript-eslint/eslint-plugin": "^6.21.0",
1156+
"@typescript-eslint/parser": "^6.21.0",
11581157
"@vscode/test-electron": "^2.3.8",
11591158
"eslint": "^8.56.0",
11601159
"eslint-webpack-plugin": "^4.0.1",

src/errors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Uri } from 'vscode';
22

3-
export class HlsError extends Error {}
3+
export class HlsError extends Error { }
44

55
export class MissingToolError extends HlsError {
66
public readonly tool: string;

src/hlsBinaries.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,13 @@ export async function findHaskellLanguageServer(
278278
const stackInstalled = latestStack ? await toolInstalled(context, logger, 'stack', latestStack) : undefined;
279279
const ghcInstalled = executableExists('ghc')
280280
? new InstalledTool(
281-
'ghc',
282-
await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false)
283-
)
281+
'ghc',
282+
await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false)
283+
)
284284
: // if recGHC is null, that means user disabled automatic handling,
285285
recGHC !== null
286-
? await toolInstalled(context, logger, 'ghc', recGHC)
287-
: undefined;
286+
? await toolInstalled(context, logger, 'ghc', recGHC)
287+
: undefined;
288288
const toInstall: InstalledTool[] = [hlsInstalled, cabalInstalled, stackInstalled, ghcInstalled].filter(
289289
(tool) => tool && !tool.installed
290290
) as InstalledTool[];
@@ -459,12 +459,12 @@ async function getLatestProjectHLS(
459459
// get project GHC version, but fallback to system ghc if necessary.
460460
const projectGhc = toolchainBindir
461461
? await getProjectGHCVersion(toolchainBindir, workingDir, logger).catch(async (e) => {
462-
logger.error(`${e}`);
463-
window.showWarningMessage(
464-
`I had trouble figuring out the exact GHC version for the project. Falling back to using 'ghc${exeExt}'.`
465-
);
466-
return await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);
467-
})
462+
logger.error(`${e}`);
463+
window.showWarningMessage(
464+
`I had trouble figuring out the exact GHC version for the project. Falling back to using 'ghc${exeExt}'.`
465+
);
466+
return await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);
467+
})
468468
: await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);
469469

470470
// first we get supported GHC versions from available HLS bindists (whether installed or not)
@@ -858,13 +858,13 @@ async function getReleaseMetadata(
858858
: undefined;
859859
const opts: https.RequestOptions = releasesUrl
860860
? {
861-
host: releasesUrl.host,
862-
path: releasesUrl.pathname,
863-
}
861+
host: releasesUrl.host,
862+
path: releasesUrl.pathname,
863+
}
864864
: {
865-
host: 'raw.githubusercontent.com',
866-
path: '/haskell/ghcup-metadata/master/hls-metadata-0.0.1.json',
867-
};
865+
host: 'raw.githubusercontent.com',
866+
path: '/haskell/ghcup-metadata/master/hls-metadata-0.0.1.json',
867+
};
868868

869869
const offlineCache = path.join(storagePath, 'ghcupReleases.cache.json');
870870

@@ -915,7 +915,7 @@ async function getReleaseMetadata(
915915

916916
window.showWarningMessage(
917917
"Couldn't get the latest haskell-language-server releases from GitHub, used local cache instead: " +
918-
githubError.message
918+
githubError.message
919919
);
920920
return cachedInfoParsed;
921921
} catch (fileError) {

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ export function resolvePATHPlaceHolders(path: string) {
197197
return path
198198
.replace('${HOME}', os.homedir)
199199
.replace('${home}', os.homedir)
200-
.replace('$PATH', process.env.PATH!)
201-
.replace('${PATH}', process.env.PATH!);
200+
.replace('$PATH', process.env.PATH ?? '$PATH')
201+
.replace('${PATH}', process.env.PATH ?? '${PATH}');
202202
}
203203

204204
// also honours serverEnvironment.PATH
@@ -207,7 +207,7 @@ export async function addPathToProcessPath(extraPath: string): Promise<string> {
207207
const serverEnvironment: IEnvVars = (await workspace.getConfiguration('haskell').get('serverEnvironment')) || {};
208208
const path: string[] = serverEnvironment.PATH
209209
? serverEnvironment.PATH.split(pathSep).map((p) => resolvePATHPlaceHolders(p))
210-
: process.env.PATH!.split(pathSep);
210+
: process.env.PATH?.split(pathSep) ?? [];
211211
path.unshift(extraPath);
212212
return path.join(pathSep);
213213
}

0 commit comments

Comments
 (0)