From 2ee8498c8d5fa7d79c58e88c8c064984028c420e Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 1 May 2024 17:34:54 +0100 Subject: [PATCH] eslint: address more exceptions Related: #1225 --- eslint.config.mjs | 7 +++---- .../src/services/executionEnvironment.ts | 2 +- packages/ansible-language-server/src/utils/docsFinder.ts | 9 ++++++--- .../contentCreator/createAnsibleCollectionPage.ts | 3 ++- src/features/contentCreator/createAnsibleProjectPage.ts | 4 ++-- src/features/lightspeed/playbookGeneration.ts | 6 ++++-- src/webview/apps/contentCreator/welcomePageApp.ts | 4 ++-- 7 files changed, 20 insertions(+), 15 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 005922870..096260833 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -50,7 +50,10 @@ export default tseslint.config( "@typescript-eslint/no-namespace": "error", "@typescript-eslint/no-non-null-assertion": "error", "@typescript-eslint/no-unused-vars": "error", + "no-case-declarations": "error", + "no-constant-condition": "error", "no-control-regex": "error", + "no-empty-function": "error", "no-prototype-builtins": "error", "tsdoc/syntax": "error", // Needed for tseslint.configs.strictTypeChecked @@ -62,10 +65,6 @@ export default tseslint.config( // "@typescript-eslint/restrict-template-expressions": "error", // "@typescript-eslint/no-unsafe-argument": "error", // "@typescript-eslint/no-unsafe-return": "error", - // Fix temporary off/warn made during eslint v9 upgrade: - "no-empty-function": "warn", - "no-case-declarations": "off", - "no-constant-condition": "off", }, }, ); diff --git a/packages/ansible-language-server/src/services/executionEnvironment.ts b/packages/ansible-language-server/src/services/executionEnvironment.ts index d6bcfcaab..e4bbc9f3e 100644 --- a/packages/ansible-language-server/src/services/executionEnvironment.ts +++ b/packages/ansible-language-server/src/services/executionEnvironment.ts @@ -548,7 +548,7 @@ export class ExecutionEnvironment { private isPluginDocCacheValid(hostCacheBasePath: string) { const markerFilePath = path.join(hostCacheBasePath, this.successFileMarker); - return true ? fs.existsSync(markerFilePath) : false; + return fs.existsSync(markerFilePath); } public get getBasicContainerAndImageDetails() { diff --git a/packages/ansible-language-server/src/utils/docsFinder.ts b/packages/ansible-language-server/src/utils/docsFinder.ts index ce4a7dc20..d80feeeb1 100644 --- a/packages/ansible-language-server/src/utils/docsFinder.ts +++ b/packages/ansible-language-server/src/utils/docsFinder.ts @@ -57,7 +57,7 @@ export async function findDocumentation( collection = "builtin"; break; case "collection": - case "collection_doc_fragment": + case "collection_doc_fragment": { const pathArray = file.split(path.sep); const pluginsDirIndex = pathArray.indexOf("plugins"); namespace = pathArray[pluginsDirIndex - 2]; @@ -70,6 +70,7 @@ export async function findDocumentation( collection = `${collection}.${subCollectionArray.join(".")}`; } break; + } } return new LazyModuleDocumentation( @@ -104,15 +105,17 @@ export async function findPluginRouting( for (const file of files) { let collection; switch (kind) { - case "builtin": + case "builtin": { collection = "ansible.builtin"; break; - case "collection": + } + case "collection": { const pathArray = file.split(path.sep); collection = `${pathArray[pathArray.length - 4]}.${ pathArray[pathArray.length - 3] }`; break; + } } const runtimeContent = await fs.promises.readFile(file, { encoding: "utf8", diff --git a/src/features/contentCreator/createAnsibleCollectionPage.ts b/src/features/contentCreator/createAnsibleCollectionPage.ts index 7d456c22f..a0ca07aa5 100644 --- a/src/features/contentCreator/createAnsibleCollectionPage.ts +++ b/src/features/contentCreator/createAnsibleCollectionPage.ts @@ -242,7 +242,7 @@ export class CreateAnsibleCollection { let payload; switch (command) { - case "open-explorer": + case "open-explorer": { payload = message.payload; const selectedUri = await this.openExplorerDialog( payload.selectOption, @@ -252,6 +252,7 @@ export class CreateAnsibleCollection { arguments: { selectedUri: selectedUri }, } as PostMessageEvent); return; + } case "check-ade-presence": await this.isADEPresent(webview); diff --git a/src/features/contentCreator/createAnsibleProjectPage.ts b/src/features/contentCreator/createAnsibleProjectPage.ts index 410263367..d2e691e00 100644 --- a/src/features/contentCreator/createAnsibleProjectPage.ts +++ b/src/features/contentCreator/createAnsibleProjectPage.ts @@ -231,7 +231,7 @@ export class CreateAnsibleProject { let payload; switch (command) { - case "open-explorer": + case "open-explorer": { payload = message.payload; const selectedUri = await this.openExplorerDialog( payload.selectOption, @@ -241,7 +241,7 @@ export class CreateAnsibleProject { arguments: { selectedUri: selectedUri }, } as PostMessageEvent); return; - + } case "init-create": payload = message.payload as AnsibleProjectFormInterface; await this.runInitCommand(payload, webview); diff --git a/src/features/lightspeed/playbookGeneration.ts b/src/features/lightspeed/playbookGeneration.ts index a9bf7a974..24fea796b 100644 --- a/src/features/lightspeed/playbookGeneration.ts +++ b/src/features/lightspeed/playbookGeneration.ts @@ -102,7 +102,7 @@ export async function showPlaybookGenerationPage( panel.webview.onDidReceiveMessage(async (message) => { const command = message.command; switch (command) { - case "generatePlaybook": + case "generatePlaybook": { const playbook = await generatePlaybook( // TODO message.content, @@ -114,7 +114,8 @@ export async function showPlaybookGenerationPage( panel?.dispose(); await openNewPlaybookEditor(playbook); break; - case "summarizeInput": + } + case "summarizeInput": { const summary = await summarizeInput( // TODO message.content, @@ -125,6 +126,7 @@ export async function showPlaybookGenerationPage( ); panel.webview.postMessage({ command: "summary", summary }); break; + } case "thumbsUp": case "thumbsDown": vscode.commands.executeCommand("ansible.lightspeed.thumbsUpDown"); diff --git a/src/webview/apps/contentCreator/welcomePageApp.ts b/src/webview/apps/contentCreator/welcomePageApp.ts index f032cc6d7..d1eb9622b 100644 --- a/src/webview/apps/contentCreator/welcomePageApp.ts +++ b/src/webview/apps/contentCreator/welcomePageApp.ts @@ -54,7 +54,7 @@ function updateAnsibleCreatorAvailabilityStatus() { const message = event.data; // The JSON data our extension sent switch (message.command) { - case "systemDetails": + case "systemDetails": { const systemDetails = message.arguments; const ansibleVersion = systemDetails["ansible version"]; const ansibleLocation = systemDetails["ansible location"]; @@ -114,7 +114,7 @@ function updateAnsibleCreatorAvailabilityStatus() { ansibleDevEnvironmentStatusText.innerHTML = `

[optional] ansible-dev-environment version: Not found

`; } installStatusDiv?.appendChild(ansibleDevEnvironmentStatusText); - + } //

✗ python version: ${pythonVersion}

//

✗ python location: ${pythonLocation}

//

✗ ansible-creator version: ${ansibleCreatorVersion}