Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooling update #1043

Merged
merged 7 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"rules": {
"semi": [
"error",
"always"
]
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
"varsIgnorePattern": "^_",
"argsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-explicit-any": "off",
"semi": ["error", "always"]
}
}
}
7 changes: 5 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"recommendations": ["ms-vscode.vscode-typescript-tslint-plugin"]
}
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
".cabal"
]
},

{
"id": "literate haskell",
"aliases": [
Expand Down Expand Up @@ -1153,8 +1152,8 @@
"@types/node": "^20.11.17",
"@types/vscode": "^1.82.0",
"@types/which": "^3.0.3",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@vscode/test-electron": "^2.3.8",
"eslint": "^8.56.0",
"eslint-webpack-plugin": "^4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Uri } from 'vscode';

export class HlsError extends Error {}
export class HlsError extends Error { }

export class MissingToolError extends HlsError {
public readonly tool: string;
Expand Down
36 changes: 18 additions & 18 deletions src/hlsBinaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,13 @@ export async function findHaskellLanguageServer(
const stackInstalled = latestStack ? await toolInstalled(context, logger, 'stack', latestStack) : undefined;
const ghcInstalled = executableExists('ghc')
? new InstalledTool(
'ghc',
await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false)
)
'ghc',
await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false)
)
: // if recGHC is null, that means user disabled automatic handling,
recGHC !== null
? await toolInstalled(context, logger, 'ghc', recGHC)
: undefined;
? await toolInstalled(context, logger, 'ghc', recGHC)
: undefined;
const toInstall: InstalledTool[] = [hlsInstalled, cabalInstalled, stackInstalled, ghcInstalled].filter(
(tool) => tool && !tool.installed
) as InstalledTool[];
Expand Down Expand Up @@ -459,12 +459,12 @@ async function getLatestProjectHLS(
// get project GHC version, but fallback to system ghc if necessary.
const projectGhc = toolchainBindir
? await getProjectGHCVersion(toolchainBindir, workingDir, logger).catch(async (e) => {
logger.error(`${e}`);
window.showWarningMessage(
`I had trouble figuring out the exact GHC version for the project. Falling back to using 'ghc${exeExt}'.`
);
return await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);
})
logger.error(`${e}`);
window.showWarningMessage(
`I had trouble figuring out the exact GHC version for the project. Falling back to using 'ghc${exeExt}'.`
);
return await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);
})
: await callAsync(`ghc${exeExt}`, ['--numeric-version'], logger, undefined, undefined, false);

// first we get supported GHC versions from available HLS bindists (whether installed or not)
Expand Down Expand Up @@ -858,13 +858,13 @@ async function getReleaseMetadata(
: undefined;
const opts: https.RequestOptions = releasesUrl
? {
host: releasesUrl.host,
path: releasesUrl.pathname,
}
host: releasesUrl.host,
path: releasesUrl.pathname,
}
: {
host: 'raw.githubusercontent.com',
path: '/haskell/ghcup-metadata/master/hls-metadata-0.0.1.json',
};
host: 'raw.githubusercontent.com',
path: '/haskell/ghcup-metadata/master/hls-metadata-0.0.1.json',
};

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

Expand Down Expand Up @@ -915,7 +915,7 @@ async function getReleaseMetadata(

window.showWarningMessage(
"Couldn't get the latest haskell-language-server releases from GitHub, used local cache instead: " +
githubError.message
githubError.message
);
return cachedInfoParsed;
} catch (fileError) {
Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export function resolvePATHPlaceHolders(path: string) {
return path
.replace('${HOME}', os.homedir)
.replace('${home}', os.homedir)
.replace('$PATH', process.env.PATH!)
.replace('${PATH}', process.env.PATH!);
.replace('$PATH', process.env.PATH ?? '$PATH')
.replace('${PATH}', process.env.PATH ?? '${PATH}');
}

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