From d76b8662ed016fda6a3e5d96645b6b989301e2f3 Mon Sep 17 00:00:00 2001 From: Anders Eknert Date: Tue, 2 Apr 2024 22:04:09 +0200 Subject: [PATCH] Various fixes * Add dependabot config * Enable more linters and fix some issues * Only lint `src` directory * Add a few more categories Signed-off-by: Anders Eknert --- .eslintrc.yml | 24 ++- .github/dependabot.yml | 10 ++ .github/workflows/build.yaml | 2 +- package-lock.json | 322 +++++++++++++++++++++++++++++++++++ package.json | 6 +- src/extension.ts | 32 ++-- src/github-installer.ts | 1 + src/ls/clients/regal.ts | 11 +- src/ls/configure.ts | 5 +- src/opa.ts | 5 +- 10 files changed, 384 insertions(+), 34 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.eslintrc.yml b/.eslintrc.yml index ff6281c..cb423a9 100644 --- a/.eslintrc.yml +++ b/.eslintrc.yml @@ -10,10 +10,24 @@ parserOptions: sourceType: module plugins: - '@typescript-eslint' + - '@stylistic' rules: '@typescript-eslint/no-explicit-any': 'off' - '@typescript-eslint/no-var-requires': 'off' - '@typescript-eslint/no-unused-vars': 'off' - 'no-undef': 'off' - 'no-case-declarations': 'off' - 'require-yield': 'off' + '@typescript-eslint/no-unused-vars': + - error + - args: all + argsIgnorePattern: '^_' + caughtErrors: all + caughtErrorsIgnorePattern: '^_' + destructuredArrayIgnorePattern: '^_' + varsIgnorePattern: '^_' + ignoreRestSiblings: true + + # Style rules + # Only adding some rules here to start. + # See https://eslint.style/rules for a complete + # list, and add more when given time. + '@stylistic/arrow-parens': 'error' + '@stylistic/arrow-spacing': 'error' + '@stylistic/block-spacing': 'error' + '@stylistic/brace-style': 'error' diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..6ebae6b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "npm" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d5ed904..5a15b7c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -25,7 +25,7 @@ jobs: run: npm run compile - name: Run ESLint - run: npx eslint --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif . + run: npx eslint --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif src continue-on-error: true - name: Upload analysis results to GitHub diff --git a/package-lock.json b/package-lock.json index 4b4b770..c031e79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,8 @@ }, "devDependencies": { "@microsoft/eslint-formatter-sarif": "^3.0.0", + "@stylistic/eslint-plugin": "^1.7.0", + "@types/command-exists": "^1.2.3", "@types/mocha": "10.0.6", "@types/node": "20.11.13", "@types/vscode": "1.75.0", @@ -248,6 +250,326 @@ "node": ">= 8" } }, + "node_modules/@stylistic/eslint-plugin": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin/-/eslint-plugin-1.7.0.tgz", + "integrity": "sha512-ThMUjGIi/jeWYNvOdjZkoLw1EOVs0tEuKXDgWvTn8uWaEz55HuPlajKxjKLpv19C+qRDbKczJfzUODfCdME53A==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "1.7.0", + "@stylistic/eslint-plugin-jsx": "1.7.0", + "@stylistic/eslint-plugin-plus": "1.7.0", + "@stylistic/eslint-plugin-ts": "1.7.0", + "@types/eslint": "^8.56.2" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-js": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-js/-/eslint-plugin-js-1.7.0.tgz", + "integrity": "sha512-PN6On/+or63FGnhhMKSQfYcWutRlzOiYlVdLM6yN7lquoBTqUJHYnl4TA4MHwiAt46X5gRxDr1+xPZ1lOLcL+Q==", + "dev": true, + "dependencies": { + "@types/eslint": "^8.56.2", + "acorn": "^8.11.3", + "escape-string-regexp": "^4.0.0", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-jsx/-/eslint-plugin-jsx-1.7.0.tgz", + "integrity": "sha512-BACdBwXakQvjYIST5N2WWhRbvhRsIxa/F59BiZol+0IH4FSmDXhie7v/yaxDIIA9CbfElzOmIA5nWNYTVXcnwQ==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "^1.7.0", + "@types/eslint": "^8.56.2", + "estraverse": "^5.3.0", + "picomatch": "^4.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-jsx/node_modules/picomatch": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", + "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/@stylistic/eslint-plugin-plus": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-plus/-/eslint-plugin-plus-1.7.0.tgz", + "integrity": "sha512-AabDw8sXsc70Ydx3qnbeTlRHZnIwY6UKEenBPURPhY3bfYWX+/pDpZH40HkOu94v8D0DUrocPkeeEUxl4e0JDg==", + "dev": true, + "dependencies": { + "@types/eslint": "^8.56.2", + "@typescript-eslint/utils": "^6.21.0" + }, + "peerDependencies": { + "eslint": "*" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/scope-manager": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/utils": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-plus/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@stylistic/eslint-plugin-ts/-/eslint-plugin-ts-1.7.0.tgz", + "integrity": "sha512-QsHv98mmW1xaucVYQTyLDgEpybPJ/6jPPxVBrIchntWWwj74xCWKUiw79hu+TpYj/Pbhd9rkqJYLNq3pQGYuyA==", + "dev": true, + "dependencies": { + "@stylistic/eslint-plugin-js": "1.7.0", + "@types/eslint": "^8.56.2", + "@typescript-eslint/utils": "^6.21.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "peerDependencies": { + "eslint": ">=8.40.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/scope-manager": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", + "dev": true, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/typescript-estree": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", + "debug": "^4.3.4", + "globby": "^11.1.0", + "is-glob": "^4.0.3", + "minimatch": "9.0.3", + "semver": "^7.5.4", + "ts-api-utils": "^1.0.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/utils": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@types/json-schema": "^7.0.12", + "@types/semver": "^7.5.0", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "semver": "^7.5.4" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^7.0.0 || ^8.0.0" + } + }, + "node_modules/@stylistic/eslint-plugin-ts/node_modules/@typescript-eslint/visitor-keys": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", + "dev": true, + "dependencies": { + "@typescript-eslint/types": "6.21.0", + "eslint-visitor-keys": "^3.4.1" + }, + "engines": { + "node": "^16.0.0 || >=18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@types/command-exists": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@types/command-exists/-/command-exists-1.2.3.tgz", + "integrity": "sha512-PpbaE2XWLaWYboXD6k70TcXO/OdOyyRFq5TVpmlUELNxdkkmXU9fkImNosmXU1DtsNrqdUgWd/nJQYXgwmtdXQ==", + "dev": true + }, + "node_modules/@types/eslint": { + "version": "8.56.7", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.7.tgz", + "integrity": "sha512-SjDvI/x3zsZnOkYZ3lCt9lOZWZLB2jIlNKz+LBgCtDurK0JZcwucxYHn1w2BJkD34dgX9Tjnak0txtq4WTggEA==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", diff --git a/package.json b/package.json index 5cc7642..1abe060 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ ], "categories": [ "Programming Languages", - "Linters" + "Linters", + "Testing", + "Debuggers" ], "keywords": [ "open policy agent", @@ -183,6 +185,8 @@ }, "devDependencies": { "@microsoft/eslint-formatter-sarif": "^3.0.0", + "@stylistic/eslint-plugin": "^1.7.0", + "@types/command-exists": "^1.2.3", "@types/mocha": "10.0.6", "@types/node": "20.11.13", "@types/vscode": "1.75.0", diff --git a/src/extension.ts b/src/extension.ts index 4de45c9..9674098 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -17,7 +17,7 @@ export class JSONProvider implements vscode.TextDocumentContentProvider { private _onDidChange = new vscode.EventEmitter(); private content = ""; - public provideTextDocumentContent(uri: vscode.Uri): string { + public provideTextDocumentContent(_uri: vscode.Uri): string { return this.content; } @@ -60,7 +60,7 @@ export function activate(context: vscode.ExtensionContext) { // this will trigger the prompt to install OPA if missing, rather than waiting til on save // the manual running of a command - opa.runWithStatus(context, 'opa', ['version'], '', (code: number, stderr: string, stdout: string) => { }); + opa.runWithStatus(context, 'opa', ['version'], '', (_code: number, _stderr: string, _stdout: string) => { }); context.subscriptions.push(vscode.commands.registerCommand('opa.show.commands', () => { const extension = vscode.extensions.getExtension("tsandall.opa"); @@ -71,7 +71,7 @@ export function activate(context: vscode.ExtensionContext) { })); vscode.languages.registerDocumentFormattingEditProvider({ scheme: 'file', language: 'rego' }, { - provideDocumentFormattingEdits(document: vscode.TextDocument): vscode.TextEdit[] | Thenable { + provideDocumentFormattingEdits(_document: vscode.TextDocument): vscode.TextEdit[] | Thenable { const editor = vscode.window.activeTextEditor; if (!editor) { return []; @@ -89,7 +89,7 @@ export function activate(context: vscode.ExtensionContext) { } }); - vscode.workspace.onDidSaveTextDocument((document: vscode.TextDocument) => { + vscode.workspace.onDidSaveTextDocument((_document: vscode.TextDocument) => { const onFormat: boolean = vscode.workspace.getConfiguration('formatOnSave')['on']; if (onFormat !== true) { return; @@ -104,7 +104,7 @@ export function activate(context: vscode.ExtensionContext) { return; }); - vscode.workspace.onDidChangeConfiguration((event) => { + vscode.workspace.onDidChangeConfiguration((_event) => { // configureLanguageServers is run here to catch newly installed language servers, // after their paths are updated. configureLanguageServers(context); @@ -172,9 +172,9 @@ function removeCoverageOnDocumentChange(e: vscode.TextDocumentChangeEvent) { } } -function showCoverageForEditor(editor: vscode.TextEditor) { - Object.keys(fileCoverage).forEach(fileName => { - vscode.window.visibleTextEditors.forEach((value, index, obj) => { +function showCoverageForEditor(_editor: vscode.TextEditor) { + Object.keys(fileCoverage).forEach((fileName) => { + vscode.window.visibleTextEditors.forEach((value) => { if (value.document.fileName.endsWith(fileName)) { value.setDecorations(coveredHighlight, fileCoverage[fileName].covered); value.setDecorations(notCoveredHighlight, fileCoverage[fileName].notCovered); @@ -184,14 +184,14 @@ function showCoverageForEditor(editor: vscode.TextEditor) { } function showCoverageForWindow() { - vscode.window.visibleTextEditors.forEach((value, index, obj) => { + vscode.window.visibleTextEditors.forEach((value) => { showCoverageForEditor(value); }); } function removeCoverage() { - Object.keys(fileCoverage).forEach(fileName => { - vscode.window.visibleTextEditors.forEach((value, index, obj) => { + Object.keys(fileCoverage).forEach((fileName) => { + vscode.window.visibleTextEditors.forEach((value) => { if (value.document.fileName.endsWith(fileName)) { value.setDecorations(coveredHighlight, []); value.setDecorations(notCoveredHighlight, []); @@ -202,7 +202,7 @@ function removeCoverage() { } function setFileCoverage(result: any) { - Object.keys(result.files).forEach(fileName => { + Object.keys(result.files).forEach((fileName) => { const report = result.files[fileName]; if (!report) { return; @@ -280,7 +280,7 @@ function activateCheckFile(context: vscode.ExtensionContext) { args.push('--strict'); } - opa.runWithStatus(context, 'opa', args, '', (code: number, stderr: string, stdout: string) => { + opa.runWithStatus(context, 'opa', args, '', (_code: number, stderr: string, _stdout: string) => { const output = stderr; if (output.trim() !== '') { opaOutputShowError(output); @@ -351,7 +351,7 @@ function activateEvalPackage(context: vscode.ExtensionContext) { const provider = new JSONProvider(); const registration = vscode.workspace.registerTextDocumentContentProvider(outputUri.scheme, provider); - const evalPackageCommand = vscode.commands.registerCommand('opa.eval.package', onActiveWorkspaceEditor(outputUri, (editor: vscode.TextEditor, inWorkspace: boolean) => { + const evalPackageCommand = vscode.commands.registerCommand('opa.eval.package', onActiveWorkspaceEditor(outputUri, (editor: vscode.TextEditor, _inWorkspace: boolean) => { opa.parse(context, 'opa', opa.getDataDir(editor.document.uri), (pkg: string, _: string[]) => { @@ -707,7 +707,7 @@ function formatErrors(error: string): string { msg.push(`${location_prefix}: ${errors[i].code}: ${errors[i].message}`); } return msg.join('\n'); - } catch (e) { + } catch (_) { return error; } } @@ -754,7 +754,7 @@ class RegoDefinitionProvider implements vscode.DefinitionProvider { public provideDefinition( document: vscode.TextDocument, position: vscode.Position, - token: vscode.CancellationToken): Thenable { + _token: vscode.CancellationToken): Thenable { const args: string[] = ['oracle', 'find-definition', '--stdin-buffer']; ifInWorkspace(() => { diff --git a/src/github-installer.ts b/src/github-installer.ts index 6c33e3b..97ac21e 100644 --- a/src/github-installer.ts +++ b/src/github-installer.ts @@ -8,6 +8,7 @@ import { URL } from 'url'; import * as vscode from 'vscode'; import { opaOutputChannel } from './extension'; +// eslint-disable-next-line @typescript-eslint/no-var-requires const releaseDownloader = require('@fohlen/github-release-downloader'); const installDeclined: { [repo: string]: boolean } = {}; diff --git a/src/ls/clients/regal.ts b/src/ls/clients/regal.ts index af05671..0a759f1 100644 --- a/src/ls/clients/regal.ts +++ b/src/ls/clients/regal.ts @@ -10,13 +10,13 @@ import { CloseAction, } from 'vscode-languageclient/node'; import * as vscode from 'vscode'; +import * as semver from 'semver'; import { existsSync } from 'fs'; -const commandExistsSync = require('command-exists').sync; -const semver = require('semver'); - +import {sync as commandExistsSync} from 'command-exists'; import { promptForInstall } from '../../github-installer'; import { replaceWorkspaceFolderPathVariable } from '../../util'; import { opaOutputChannel } from '../../extension'; +import { execSync } from 'child_process'; let client: LanguageClient; let clientLock = false; @@ -78,7 +78,6 @@ function regalVersion(): string { let version = 'missing'; if (isInstalledRegal()) { - const execSync = require('child_process').execSync; const versionJSON = execSync(regalPath() + ' version --format=json').toString().trim(); const versionObj = JSON.parse(versionJSON); version = versionObj.version || 'unknown'; @@ -107,7 +106,7 @@ export function regalPath(): string { return 'regal'; } -export function activateRegal(context: ExtensionContext) { +export function activateRegal(_context: ExtensionContext) { // activateRegal is run when the config changes, but this happens a few times // at startup. We use clientLock to prevent the activation of multiple instances. if (clientLock) { @@ -145,7 +144,7 @@ export function activateRegal(context: ExtensionContext) { traceOutputChannel: outChan, revealOutputChannelOn: 0, errorHandler: { - error: (error: Error, message: Message, count: number): ErrorHandlerResult => { + error: (error: Error, message: Message, _count: number): ErrorHandlerResult => { console.error(error); console.error(message); return { diff --git a/src/ls/configure.ts b/src/ls/configure.ts index 0fd73d6..a778551 100644 --- a/src/ls/configure.ts +++ b/src/ls/configure.ts @@ -14,7 +14,7 @@ export function configureLanguageServers(context: vscode.ExtensionContext) { const configuration = vscode.workspace.getConfiguration('opa'); const configuredLanguageServers = configuration.get>('languageServers') || []; - // if the user has language servers set to an empty array this is + // if the user has language servers set to an empty array this is // taken as an indication that they don't want to be prompted to enable // any new ones if (configuration.get('languageServers') !== null && configuredLanguageServers.length === 0) { @@ -31,7 +31,7 @@ export function configureLanguageServers(context: vscode.ExtensionContext) { } switch (languageServerID) { - case 'regal': + case 'regal': { const isInstalled = isInstalledRegal(); const path = regalPath(); // if regal has been installed by the extension, it should be @@ -75,6 +75,7 @@ export function configureLanguageServers(context: vscode.ExtensionContext) { ); } }); + } } } } diff --git a/src/opa.ts b/src/opa.ts index 5c9ac35..5f5ace3 100644 --- a/src/opa.ts +++ b/src/opa.ts @@ -1,9 +1,8 @@ 'use strict'; import cp = require('child_process'); -const commandExistsSync = require('command-exists').sync; import * as vscode from 'vscode'; - +import {sync as commandExistsSync} from 'command-exists'; import { promptForInstall } from './github-installer'; import { getImports, getPackage, replaceWorkspaceFolderPathVariable } from './util'; import { existsSync } from 'fs'; @@ -323,7 +322,7 @@ export function runWithStatus(context: vscode.ExtensionContext | undefined, path stderr += data; }); - proc.on('exit', (code, signal) => { + proc.on('exit', (code) => { console.log("code:", code); console.log("stdout:", stdout); console.log("stderr:", stderr);